我有一个可加载内核模块,它的初始化如下所示
static int __init id_init(void)
{
struct identity *temp;
/* some code which is not relevant to the question */
temp = identity_find(3);
pr_debug("id 3 = %s\n", temp->name);
temp = identity_find(42);
if (temp == NULL)
pr_debug("id 42 not found\n");
/* some code which is not relevant to the question */
return 0;
}
我在使用的内核版本上启用了动态调试 - 即CONFIG_DYNAMIC_DEBUG=y
。
在模块的Makefile中,我添加了一行CFLAGS_[id].o := -DDEBUG
,其中id.c
是文件名。
现在,我在此模块进行insmod后检查了/sys/kernel/debug/dynamic_debug/control
,在其中找到以下行:
/home/pauldc/Programming/Kernel/id/id.c:69 [id]id_init =_ "id 42 not found\012"
/home/pauldc/Programming/Kernel/id/id.c:65 [id]id_init =_ "id 3 = %s\012"
即使我做了这一切,令我失望的是,在dmesg输出中我仍然找不到上述两个pr_debug语句。那么我错过了什么或者做错了什么呢?
dyndbg
参数。如果您已经编译,请使用<NAME>.dyndbg
,其中<NAME>是您的模块名称,根据Makefile相应地使用。 - 0andriy