printk 不适用于内核调试
我在内核代码中放置了一些调试消息。 已检查/var/log/messages、dmesg,那里没有这样的转储。 syslogd 正在机器上运行,
我还将 /proc/sys/kernel/printk 更改为 8 4 1 7
知道问题出在哪里吗?
I put some debugging messages in the kernel code.
have checked /var/log/messages, dmesg and there is no such dump there.
syslogd is running on the machine
i also changed /proc/sys/kernel/printk to
8 4 1 7
any idea what can be the problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
直到昨天我遇到了同样的问题,当时我发现了一些有趣的事情。最近Linux内核已经采用pr_**代替printk(3.5版本及更高版本)。
我尝试在 3.3 版本的内核上使用 printk 运行基本模块程序。 3.7及以上版本相同。
前者工作正常。后来只是没有在 dmesg 或
/var/log/messages
上显示 printk。然而,用 pr_info 宏替换 printk,就完成了工作。(之前在 include/linux/kernel.h 中发现的其他变体还有 pr_err、pr_notice 等,现在移至 < em>include/linux/printk.h)虽然 pr_** 宏已经很老了,但由于 Joe Perches 发起了上述更改,我们更好地学习内核方式!
(参考:pr_info())
I faced the same problem until yesterday, when i found something interesting. Lately linux kernel has been adopting pr_** instead of printk (3.5 version and later).
I have tried running a basic module program with printk on 3.3 version of the kernel & the same on 3.7 and above.
Former works fine. Later just doesn't show up the printk's on dmesg or
/var/log/messages
. However replacing the printk with pr_info macro,did the job. (other variants are also there pr_err, pr_notice etc found in include/linux/kernel.h earlier now moved to include/linux/printk.h)Although, pr_** macro's are quite old, thanks to campaign by Joe Perches, who has initiated the above mentioned change, we better learn the kernel ways !
(Reference: pr_info())
最简单的解释是您的
printk()
没有被调用。保持简单并在调试此问题时坚持检查
dmesg(1)
输出 - 所有syslog(3)
/var/log/messages
和基于控制台的输出与甚至没有出现在内核消息缓冲区中的消息问题是分开的。The easiest explanation is your
printk()
is not being called.Keep it simple and stick to checking
dmesg(1)
output while you're debugging this problem -- all thesyslog(3)
/var/log/messages
and the console based output are separate from the issue of the messages not even showing up in the kernel's message buffer.