简体   繁体   English

将libc回溯转换为源行号

[英]Convert a libc backtrace to a source line number

I have an MPI application with which combines both C and Fortran sources. 我有一个MPI应用程序,它结合了C和Fortran源。 Occasionally it crashes due to a memory related bug, but I am having trouble finding the bug (it is somewhere in someone else's code, which at the moment I'm not very familiar with). 偶尔它会因为与内存相关的bug而崩溃,但是我无法找到这个bug(这是在别人的代码中的某个地方,目前我并不是很熟悉)。 I haven't yet been able to catch it with gdb, but sometimes a glibc backtrace is output as shown below. 我还没有能够用gdb捕获它,但有时会输出glibc backtrace,如下所示。

The bug is probably close to "(main_main_+0x3bca)[0x804d5ce]", (but with a memory error, I know this may not be the case). 该错误可能接近“(main_main_ + 0x3bca)[0x804d5ce]”,(但有内存错误,我知道情况可能并非如此)。 My question is, does anyone know how to convert +0x3bca or 0x804d5ce into a particular line of the code? 我的问题是,有没有人知道如何将+ 0x3bca或0x804d5ce转换为代码的特定行?

Any other suggestions on tracking down the bug would also be appreciated. 关于追踪错误的任何其他建议也将受到赞赏。 I'm quite familiar with the basics of gdb. 我非常熟悉gdb的基础知识。

*** glibc detected *** /home/.../src/finite_element: munmap_chunk(): invalid pointer: 0x09d83018 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x73e42)[0xb7409e42]
/lib/i386-linux-gnu/libc.so.6(+0x74525)[0xb740a525]
/home/.../src/finite_element(main_main_+0x3bca)[0x804d5ce]
/home/.../src/finite_element[0x804e195]
/home/.../src/finite_element(main+0x34)[0x804e1e8]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf3)[0xb73af4d3]
/home/davepc/finite-element/src/finite_element[0x8049971]
======= Memory map: ========
08048000-08056000 r-xp 00000000 08:05 1346306    /home/.../src/finite_element
08056000-08057000 r--p 0000d000 08:05 1346306    /home/.../src/finite_element
08057000-08058000 rw-p 0000e000 08:05 1346306    /home/.../src/finite_element
09d1b000-09d8f000 rw-p 00000000 00:00 0          [heap]
b2999000-b699b000 rw-s 00000000 08:03 15855      /tmp/openmpi-sessions-_0/37612/1/shared_mem_pool.babel
b699b000-b6b1d000 rw-p 00000000 00:00 0 
b6b31000-b6b3d000 r-xp 00000000 08:03 407798     /usr/lib/openmpi/lib/openmpi/mca_osc_rdma.so
b6b3d000-b6b3e000 r--p 0000b000 08:03 407798     /usr/lib/openmpi/lib/openmpi/mca_osc_rdma.so
b6b3e000-b6b3f000 rw-p 0000c000 08:03 407798     /usr/lib/openmpi/lib/openmpi/mca_osc_rdma.so
<snip>

Thank you... 谢谢...

If you are in gdb and you have debugging symbols, it is quite easy. 如果你在gdb并且你有调试符号,这很容易。 Use list . 使用list

(gdb) list *0x804d5ce

This should give you the line of code, and show you the source if it is able to find the source file. 这应该为您提供代码行,并显示源代码是否能够找到源文件。

Without gdb you could try to use addr2line : 没有gdb你可以尝试使用addr2line

$ addr2line -e finite_element 0x804d5ce

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

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