CONFIG_DYNAMIC_DEBUG 是配置动态输出,它依赖于 CONFIG_DEBUG_FS,而 CONFIG_DEBUG_FS 是debugfs 文件系统。debugfs默认会挂载到 /sys/kernel/debug,如果没有挂载,可以执行以下命令挂载: $ mount -t debugfs none /sys/kernel/debug dynamic debug 的使用 这里我讲pr_debug和pr_devel的使用方法 pr_debug pr_debug...
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */ #definepr_debug(fmt, ...) \ dynamic_pr_debug(fmt, ##__VA_ARGS__) #elifdefined(DEBUG) #definepr_debug(fmt, ...) \ printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) #else #definepr_debug(fmt, ...
CONFIG_DYNAMIC_DEBUG is set, then all pr_debug()/dev_dbg() and print_hex_dump_debug()/print_hex_dump_bytes() calls can be dynamically enabled per-callsite. If CONFIG_DYNAMIC_DEBUG is not set, print_hex_dump_debug() is just shortcut for print_hex_dump(KERN_DEBUG). For print_hex_...
Linuxprintk的⽇志级别和pr_debug 1. 查看⽇志级别 # cat /proc/sys/kernel/printk 7417 四个数值分别表⽰。控制台⽇志级别 默认消息⽇志级别(未明确指定⽇志级别的消息)最⼩控制台⽇志级别 默认控制台⽇志级别 ⽇志级别的定义在include/linux/kern_levels.h。数值越⼩,级别越...
内核中有很多pr_debug(例如arch/powerpc/sysdev/fsl_pci.c)。默认不会输出日志输出到控制台(console),需要手动打开。 打开方式: 定义DEBUG 宏 默认内核 printk loglevel大于7 开启DEBUG宏 内核源码include/printk.h文件定义了pr_debug。 /* If you are writing a driver, please use dev_dbg instead */ ...
{pr_info("probe_sched_switch: pid [%d] -> [%d] \\n",prev->tgid,next->tgid);}struct tracepoints_table{constchar*name;void*fct;struct tracepoint*value;char init;};struct tracepoints_table interests[]={{.name="sched_switch",.fct=probe_sched_switch}};#defineFOR_EACH_INTEREST(i)\\...
();//执行一次hub事件函数wait_event_interruptible(khubd_wait,!list_empty(&hub_event_list)||kthread_should_stop());//(1).每次执行一次hub事件,都会进入一次等待事件中断函数try_to_freeze();}while(!kthread_should_stop()||!list_empty(&hub_event_list));pr_debug("%s: khubd exiting\n",usb...
**要使用动态输出,必须在内核配置时打开CONFIG_DYNAMIC_DEBUG宏。**内核代码里使用了大量的pr_debug()/dev_dbg()函数来输出信息,这些就使用了动态输出技术,**另外还需要系统挂载debugfs文件系统。(其实这里就设计到了debugfs) (动态输出的意思就是你可以想打开看谁就看谁,但是对于全局的来说,你设置了这个函数,它...
CONFIG_DEBUG_KERNEL=y CONFIG_KLLSYMS=y CONFIG_SPINLOCK_SLEEP=y 四 引发bug并打印信息 1 BUG()和BUG_ON() 一些内核调用可以用来方便标记bug,提供断言并输出信息。最常用的两个是BUG()和BUG_ON()。 定义在中: #ifndef HAVE_ARCH_BUG#defineBUG() do {printk("BUG: failure at %s:%d/%s()!", __...