Linux內核日誌開關
1、讓pr_debug能輸出
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -59,7 +59,7 @@
/* We show everything that is MOREimportant than this.. */
#define MINIMUM_CONSOLE_LOGLEVEL 1 /*Minimum loglevel we let people use */
-#define DEFAULT_CONSOLE_LOGLEVEL 7 /*anything MORE serious than KERN_DEBUG */
+#define DEFAULT_CONSOLE_LOGLEVEL 8 /*anything MORE serious than KERN_DEBUG */
int console_printk[4] = {
DEFAULT_CONSOLE_LOGLEVEL, /* console_loglevel */
2、讓模塊內代碼都能輸出
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
EXTRA_CFLAGS += -DDEBUG
3、讓每個文件輸出
--- a/drivers/of/Makefile
+++ b/drivers/of/Makefile
文件include之前加define DEBUG
或者Makefile裏面增加
pr_debug() Some files call pr_debug(), which is ordinarily an empty macro that discards its arguments at compile time. To enable debugging output, build the appropriate file with -DDEBUG by adding CFLAGS_[filename].o := -DDEBUG to the makefile. For example, to see all attempts to spawn a usermode helper (such as /sbin/hotplug), add to lib/Makefile the line: CFLAGS_kobject_uevent.o := -DDEBUG Then boot the new kernel, do something that spawns a usermode helper, and use the "dmesg" command to view the pr_debug() output.
4、內核打印控制
d,lx,ld,,lu,這幾個都是輸出32位的
hd,hx,hu,這幾個都是輸出16位數據的,
hhd,hhx,hhu,這幾個都是輸出8位的,
lld,ll,llu,llx,這幾個都是輸出64位的,