为什么Linux内核的pr_debug没有给出任何输出? [英] Why is pr_debug of the Linux kernel not giving any output?
问题描述
我有一个可加载的内核模块,其初始化如下所示
I have a loadable kernel module and its init is as given below
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
.
Also I have enabled dynamic debugging enabled on the kernel version I am using - i.e CONFIG_DYNAMIC_DEBUG=y
.
在模块的Makefile中,添加了CFLAGS_[id].o := -DDEBUG
行,其中id.c
是文件名.
And in the Makefile of the module I have added a line CFLAGS_[id].o := -DDEBUG
where id.c
is the file name.
现在,我在执行本模块的insmod后检查了/sys/kernel/debug/dynamic_debug/control
,在其中找到了以下几行
Now I checked in the /sys/kernel/debug/dynamic_debug/control
after doing insmod of this module, in which I found the below lines
/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语句.那我想念什么或做错什么了?
Even after doing all this, to my disappointment I could not find the above two pr_debug statements in the output of dmesg. So what am I missing or doing wrong?
推荐答案
假定filename.c
是模块源文件,请在Makefile中添加以下内容.
Add following to Makefile, assuming filename.c
is the module source file.
CFLAGS_filename.o := -DDEBUG
不是
CFLAGS_[filename].o := -DDEBUG
引用 https://www.kernel.org/doc/local/pr_debug. txt
这篇关于为什么Linux内核的pr_debug没有给出任何输出?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!