简体   繁体   English

linux内核模块生成的核心文件

[英]Core files generated by linux kernel modules

I am trying to load a kernel module (out-of-tree) and dmesg shows a panic. 我正在尝试加载内核模块(树外),并且dmesg出现了紧急情况。 The kernel is still up though. 虽然内核仍然启动。 I guess the module panic'd. 我猜模块恐慌了。

Where to find the core file? 在哪里可以找到核心文件? I want to use gdb and see whats the problem. 我想使用gdb看看有什么问题。

Where to find the core file? 在哪里可以找到核心文件?

Core files are strictly a user-space concept. 核心文件严格来说是用户空间的概念。

I want to use gdb and see whats the problem. 我想使用gdb看看有什么问题。

You may be looking for KGDB and/or Kdump/Kexec . 您可能正在寻找KGDB和/或Kdump / Kexec

there won't be a core file. 不会有核心文件。 You should follow the stack trace in kernel messages. 您应该遵循内核消息中的堆栈跟踪。 type dmesg to see it. 输入dmesg以查看它。

Normally, whenever the coredump was generated, it will state "core dumped". 通常,无论何时生成coredump,它都会声明“ core dumped”。 This could be one high level easy way to confirm whether coredump got generated however, this statement alone cannot guarantee on coredump file availability. 这可能是确认是否生成了coredump的一种高级简便方法,但是,仅此语句不能保证coredump文件的可用性。 The location where coredump is generated is specified through core_pattern to kernel via sysctl. 生成coredump的位置通过sysctl通过core_pattern指定给内核。 You need to check the information present in core_pattern of your system. 您需要检查系统的core_pattern中存在的信息。 Also, note that in case of Ubuntu, it appears that the coredump file size is kept as zero by default which will avoid generation of coredump. 另外,请注意,对于Ubuntu,默认情况下,coredump文件大小似乎保持为零,这将避免生成coredump。 So, you might need to check the corefile size ulimit and change it to 'ulimit -c unlimited', if it is zero. 因此,您可能需要检查核心文件大小ulimit并将其更改为'ulimit -c unlimited'(如果为零)。 The manpage http://man7.org/linux/man-pages/man5/core.5.html explains about various reasons due to which coredump shall not get generated. 联机帮助页http://man7.org/linux/man-pages/man5/core.5.html解释了由于各种原因而导致无法生成coredump的各种原因。

However, from your explanation, it appears that you are facing 'kernel oops' as the kernel is still up(unstable state) even though a particular module got panic'd/killed. 但是,从您的解释来看,您似乎正面临“内核崩溃”,因为即使特定的模块出现了紧急情况/已被杀死,内核仍处于启动状态(不稳定状态)。 In such cases, kernel shall print an oops message. 在这种情况下,内核将输出oops消息。 Refer to link https://www.kernel.org/doc/Documentation/oops-tracing.txt that has information regarding the kernel oops messages. 请参阅链接https://www.kernel.org/doc/Documentation/oops-tracing.txt ,其中包含有关内核oops消息的信息。

Abstract from the link: Normally the Oops text is read from the kernel buffers by klogd and handed to syslogd which writes it to a syslog file, typically /var/log/messages (depends on /etc/syslog.conf). 链接的摘要:通常,通过klogd从内核缓冲区读取Oops文本,并将其交给syslogd,然后将其写入syslog文件,该文件通常为/ var / log / messages(取决于/etc/syslog.conf)。 Sometimes klogd dies, in which case you can run dmesg > file to read the data from the kernel buffers and save it. 有时klogd死亡,在这种情况下,您可以运行dmesg> file从内核缓冲区读取数据并保存。 Or you can cat /proc/kmsg > file, however you have to break in to stop the transfer, kmsg is a "never ending file". 或者,您可以使用cat / proc / kmsg>文件,但是您必须闯入才能停止传输,kmsg是“永无止境的文件”。

printk is used for generating the oops messages. printk用于生成oops消息。 printk does tagging of severity by means of different loglevels /priorities and allows the classification of messages according to their severity. printk通过不同的日志级别/优先级来标记严重性,并允许根据消息的严重性对消息进行分类。 (Different priorities are defined in file linux/kernel.h or linux/kern_levels.h, in form of macros like KERN_EMERG, KERN_ALERT, KERN_CRIT etc..)So, you may need to check the default logging levels in system by using cat /proc/sys/kernel/printk and change it as per your requirement. (以KERN_EMERG,KERN_ALERT,KERN_CRIT等宏的形式在文件linux / kernel.h或linux / kern_levels.h中定义了不同的优先级。)因此,您可能需要使用cat /检查系统中的默认日志记录级别。 proc / sys / kernel / printk并根据您的要求进行更改。 Also, check whether the logging daemons are up and incase you want to debug kernel, ensure that the kernel is compiled with CONFIG_DEBUG_INFO. 另外,检查日志记录守护程序是否已启动,以及是否要调试内核,请确保使用CONFIG_DEBUG_INFO编译内核。

The method to use GDB to find the location where the kernel panicked or oopsed in ubuntu is in the link https://wiki.ubuntu.com/Kernel/KernelDebuggingTricks which can be one of the method that can be used by you for debugging kernel oops. 使用GDB查找在ubuntu中惊慌或被举动的内核的位置的方法位于链接https://wiki.ubuntu.com/Kernel/KernelDebuggingTricks ,这可能是您调试内核时可以使用的方法之一哎呀。

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

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