简体   繁体   English

如何保存或从控制台长期看到Linux内核BUG消息?

[英]How can I save or longly see linux kernel BUG message from console?

I'm trying to develop device driver for the linux kernel, but I have a problem with debugging bug message. 我正在尝试为linux内核开发设备驱动程序,但是我在调​​试错误消息时遇到了问题。

I'm working on the desktop (x64) with linux kernel (ubuntu 14.04, and I tried ubuntu server 14.04 too). 我正在使用Linux内核(ubuntu 14.04,也尝试过ubuntu server 14.04)的桌面(x64)。 And, I'm using tty console (ctrl+alt+f1) to take the test, because tty console always print printk message when I enable log level to 7. 而且,我使用tty控制台(ctrl + alt + f1)进行测试,因为当我将日志级别设置为7时,tty控制台始终会打印printk消息。

My problem is, first I have a bug on my developing device driver code, and second, I can't get the actual cause of bug because I cannot view the all bug message except last-left few bug message. 我的问题是,首先,我正在开发的设备驱动程序代码中存在一个错误,其次,我无法获得实际的错误原因,因为除最后左几条错误消息外,我无法查看所有错误消息。

I tried ssh for debugging, (test PC is ssh server, and ssh client pulls dmesg or ftrace printk message from ssh) but ssh server died earlier than kernel bug message, so that I only could see the bug message from my monitor with tty console. 我尝试使用ssh进行调试((测试PC是ssh服务器,并且ssh客户端从ssh提取dmesg或ftrace printk消息),但ssh服务器早于内核错误消息而死,因此我只能从使用tty控制台从监视器中看到该错误消息。 。

I also tried to use smaller size console font, but that was just temporal solution. 我也尝试使用较小尺寸的控制台字体,但这只是临时解决方案。

So, my question is, there are any debugging techniques that fit with this problem? 因此,我的问题是,是否有任何适合该问题的调试技术?

like, stop printing kernel bug message after first bug message, or redirect tty console to other PC using hardware or something.. 例如,在出现第一个错误消息后停止打印内核错误消息,或者使用硬件或其他方式将tty控制台重定向到其他PC。

Please help me with solution Thanks, 请帮我解决问题,谢谢

You can redirect various system log streams (including those appearing in dmesg) to any terminal or file by modifying the rsyslog.conf . 您可以通过修改rsyslog.conf将各种系统日志流(包括出现在dmesg中的日志流)重定向到任何终端或文件。

Check in you already have a line similar to 签入您已经有一条类似于

kern.* /some/file

/some/file should contain the messages send to dmesg . /some/file应该包含发送到dmesg的消息。 If no such line exists, create one. 如果不存在这样的行,请创建一个。 If that doesn't work for some reason, replace kern.* with *.* and try that way. 如果由于某些原因不能解决问题,请用*.*替换kern.* *.*并尝试这种方式。

You could also push the contents of dmesg to a file with a command like so dmesg > /var/log/dmesg which could be done regularly by Cron. 您还可以使用诸如dmesg > /var/log/dmesg类的命令将dmesg的内容推送到文件中,这可由Cron定期完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM