printk not working for kernel debgugging

℡╲_俬逩灬. 提交于 2019-12-10 21:20:12

问题


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?


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/8090944/printk-not-working-for-kernel-debgugging

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!