在相当旧的 Linux 系统上,我无法获取 gdb 之后可以读取的核心转储。内核版本是3.8.13,libc版本是2.3.4。 ulimit -c
设置为无限制且 /proc/sys/kernel/core_pattern
指向有效的可写文件位置。当我中止任何进程( kill -6 PID
)时,它会在指定的位置生成一个核心文件。但是,当稍后尝试使用 gdb -core filename
读取核心文件时我总是收到错误消息“无法从内存中读取有效的对象文件图像。”此消息的确切含义是什么以及导致它的原因是什么?我还将 /proc/<pid>/coredump_filter
中的所有位设置为 1但这并没有帮助。
进一步我发现,当我将 gdb 附加到进程,然后使用命令 generate-core-file
从 gdb 创建核心文件时它生成一个核心文件,我可以将其读入 gdb,而不会收到此警告。我尝试将核心文件加载到gdb版本6.3.50和版本7.10-1ubuntu中。
最佳答案
However when trying to read the core file later using
gdb -core filename
I always get the error message "Failed to read a valid object file image from memory."
您很可能会忽略该警告。
在gdb -core filename
之后你想做什么?您可能想要gdb ./a.out core
(这会产生相同的警告,但应该为您提供一个可用的GDB session )。
what causes “Failed to read a valid object file image from memory.”
某些版本的 GDB 不理解 VDSO ,它出现在共享对象的加载程序列表中,但不是一个,并发出上面的警告。可以忽略此警告。
关于linux - GDB和corefiles是什么原因导致 "Failed to read a valid object file image from memory.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41267200/