【发布时间】:2012-05-04 16:38:59
【问题描述】:
在我的共享库中获得SEGSEGV 后,我正在尝试获取堆栈跟踪并将其保存到文件中。共享库是闭源产品的插件。所有这些都适用于生产,我无法直接访问它。
我的代码捕获SIGSEGV 信号,打印堆栈跟踪并退出。我有这样的事情:
/opt/ecelerity/libexec/site/ec_attachextensions.so [0x2aecc2019f11] /opt/ecelerity/libexec/site/ec_attachextensions.so [0x2aecc2019f11] /opt/ecelerity/libexec/site/ec_attachextensions.so [0x2aecc2019fee] /opt/ecelerity/libexec/site/ec_attachextensions.so [0x2aecc201a587]
/opt/ecelerity/sbin/ecelerity [0x501235]
/opt/ecelerity/sbin/ecelerity(sieve_seng_execute+0x82) [0x506d32] /opt/ecelerity/libexec/validate/sieve.so [0x2aecc2862c9e] /opt/ecelerity/sbin/ecelerity(validate_data+0xa5) [0x4a90d5] /opt/ecelerity/sbin/ecelerity(esmtp_message_factory+0x154e) [0x46eace] /opt/ecelerity/sbin/ecelerity(schedule_event_and_dispatch+0x6a) [0x49c59a]
问题是我不能在其中包含函数的名称和偏移量以进行共享
图书馆。据我了解,我可以在以下帮助下找到给定地址的函数名/文件名
addr2line 实用程序后我会在/proc/$PID/maps 中找到库偏移量。
之后我正在执行类似的操作:
addr2line -e /opt/ecelerity/libexec/site/ec_attachextensions.so (LIBRARY_OFFSET_FROM_MAPS_FILE - 0x2aecc2019f11)
其中0x2aecc2019f11 是上面堆栈跟踪中的地址。我想知道有什么方法可以在不接触地图文件的情况下在堆栈跟踪中获取函数名称?换句话说,我该如何编程? dladdr 会在这里提供帮助吗(dladdr 无法从backtrace 函数提供的地址中获取函数名称在我的情况下)?
【问题讨论】:
标签: c++ linux stack-trace x86-64 backtrace