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

时间:2021-12-28 18:12:48

I'm trying to develop device driver for the linux kernel, but I have a problem with debugging bug message.

我正在尝试为linux内核开发设备驱动程序,但我在调试bug消息时遇到问题。

I'm working on the desktop (x64) with linux kernel (ubuntu 14.04, and I tried ubuntu server 14.04 too). 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.

我在桌面(x64)上使用linux内核(ubuntu 14.04,我也尝试过ubuntu服务器14.04)。并且,我使用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服务器早于内核bug消息死了,所以我只能通过tty控制台看到我的监视器的bug消息。

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..

比如,在第一个bug消息之后停止打印内核bug消息,或者使用硬件或其他东西将tty控制台重定向到其他PC。

Please help me with solution Thanks,

请帮我解决方案谢谢,

1 个解决方案

#1


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. If no such line exists, create one. If that doesn't work for some reason, replace kern.* with *.* and try that way.

/ some / file应该包含发送到dmesg的消息。如果不存在此类行,请创建一行。如果由于某种原因这不起作用,用*。*替换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定期完成。

#1


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. If no such line exists, create one. If that doesn't work for some reason, replace kern.* with *.* and try that way.

/ some / file应该包含发送到dmesg的消息。如果不存在此类行,请创建一行。如果由于某种原因这不起作用,用*。*替换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定期完成。