如何使用寄存器和原始堆栈在没有符号的情况下分析和调试 gdb 核心
在客户处,第三方软件崩溃了。进程和库被剥离(没有符号),调用堆栈没有提供任何有用的信息。我所拥有的只是可能不会被损坏的寄存器。这个第三方代码是用C编写的。
现在,我一直使用gdb来调试更简单的问题。但这有点复杂。我认为寄存器和原始堆栈信息可用于关联崩溃发生的位置,我需要这方面的帮助。
可能无法在客户站点部署未剥离的二进制文件,也不可能进行内部崩溃再现。另外,我对这个第三方代码不熟悉。
我还需要以下内容的指针/站点/文档:
1) ELF和各种节头。
2) 如何为库和进程创建符号文件(在编译期间)。
3)如何告诉gdb从符号文件中读取符号。
At a customer place a third party software has crashed. The process and the libraries are stripped (no symbols), the call stack does not give any useful information. All that I have is registers which may not be corrupted. This third party code has been written is C.
Now, I have used gdb till now to debug simpler issues. But this one is a bit complicated. I think register and raw stack information may be used to corelate where the crash occurred and I require help on this aspect.
It may not be possible to deploy a non-stripped binary at customer site, nor would it be possible to do inhouse crash reproduction. Also, I am not familiar with this third party code.
Also I require pointers/sites/documents for the following:
1) ELF and various section headers.
2) How to create a symbol file (during compilation) for a library and a process.
3) How to tell gdb to read symbols from a symbol file.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我们应该做的一件事是根据流程的非剥离/带符号版本打开核心文件。只要编译过程(编译器、优化标志等)相同并且您只保留所有这些调试信息,GDB 就应该能够为您提供您可以从内核期望的所有信息。
要使用调试信息(行、类型等的符号和小矮人)编译进程,您需要在编译器标志中添加
-g
。这同样适用于您的自定义库。对于系统库,有时(并非总是)可能是一致的,现代 Linux 发行版(至少是 Fedora)直接将它们提供给 gdb。
One thing we should be able to do is to open you core file against a non-stripped/with-symbols version of your process. As long as the compilation process (compiler, optimization flags, etc.) is the same and you just keep all these debugging information, GDB should be able to provide you with all the information you can expect from a core.
To compile your process with the debugging information (symbols and dwarfs for lines, types, ...), you need to add
-g
in your compiler flags. The same applies for your custom libraries.For the system libraries, it might be conviant sometime (not always), modern Linux distributions (at least Fedora) directly provide them to gdb.