printk not working for kernel debgugging

2019-07-08 05:11发布

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?

2条回答
别忘想泡老子
2楼-- · 2019-07-08 05:31

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())

查看更多
3楼-- · 2019-07-08 05:44

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.

查看更多
登录 后发表回答