printk 不适用于内核调试

发布于 2024-12-14 14:22:31 字数 146 浏览 2 评论 0原文

我在内核代码中放置了一些调试消息。 已检查/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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

痴情 2024-12-21 14:22:31

直到昨天我遇到了同样的问题,当时我发现了一些有趣的事情。最近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())

那些过往 2024-12-21 14:22:31

最简单的解释是您的 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 the syslog(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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文