简体   繁体   English

在内核崩溃后获取 Linux 内核调试信息

[英]Getting Linux kernel debug information after a kernel crash

Is there a way to get kernel previous debug information after kernel crash occurs.有没有办法在内核崩溃发生后获取内核以前的调试信息。

I am trying to develop a kernel module which basically captures IP packets in the IP layer inside the kernel network stack and after some modification I have to send the same packet back to the NIC for transmission.我正在尝试开发一个内核模块,它基本上在内核网络堆栈内的 IP 层中捕获 IP 数据包,经过一些修改后,我必须将相同的数据包发送回 NIC 进行传输。

During all these processes I'm writing debug information with the help of printk() .在所有这些过程中,我都在printk()的帮助下编写调试信息。 But if any thing goes wrong and a kernel failure occurs, we have to restart the system.但是如果出现任何问题并且发生内核故障,我们必须重新启动系统。 Is there a way to get my previous debug information, because after rebooting the debug information is not present as I try to get it by dmesg command?有没有办法获取我以前的调试信息,因为重新启动后调试信息不​​存在,因为我尝试通过dmesg命令获取它?

Actually, the /var/log/dmesg file contains the current boot print message log.实际上, /var/log/dmesg文件包含当前引导打印消息日志。 The /var/log/kern.log file contains your previous boot kernel print message log in Ubuntu . /var/log/kern.log文件包含您之前在Ubuntu 中的引导内核打印消息日志。 In other Linux flavours it will contain in the /var/log/messages file in Fedora, etc..在其他 Linux 版本中,它将包含在 Fedora 等的/var/log/messages文件中。

Kernel log messages can be viewed in /var/log/dmesg files even after restart of the system.即使在系统重新启动后,也可以在/var/log/dmesg文件中查看内核日志消息。

There will be so many files with dmesg.X, and those files are previous kernel logs. dmesg.X 会有很多文件,这些文件是以前的内核日志。 dmesg is the latest file. dmesg是最新的文件。

See difference between dmesg and /var/log/kern.log查看dmesg 和 /var/log/kern.log 之间的区别

您可以尝试通过键盘或串行控制台输入神奇的 SysRq键序列来与挂起的系统进行交互。

Recent versions of Linux support crash dumps .最新版本的 Linux 支持故障转储 When successful, these will include a full dump of memory, including kernel log messages and stack traces.成功后,这些将包括完整的内存转储,包括内核日志消息和堆栈跟踪。

Actually, the crash information (dmesg) is present in the location /var/crash/.实际上,崩溃信息 (dmesg) 存在于位置 /var/crash/ 中。 Here we have the folders for every system crash.在这里,我们有每个系统崩溃的文件夹。 Folder names like 127.0.0.1-date-time.文件夹名称如 127.0.0.1-date-time。 vmcore-dmesg.txt are present inside the folders. vmcore-dmesg.txt 存在于文件夹中。 From these file, we have get the dmesg which are executed before the crash.从这些文件中,我们得到了崩溃前执行的 dmesg。

GNOME Logs is a very useful software for that. GNOME Logs 是一个非常有用的软件。 You can limit the log messages to the last session and easily read what the last messages before the crash were.您可以将日志消息限制到最后一个会话,并轻松阅读崩溃前的最后一条消息。

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

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