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]
问题是我不能在其中包含共享库的函数名称和偏移量。据我了解,在找到/proc/$PID/maps
.
之后,我正在执行类似的操作:
addr2line -e /opt/ecelerity/libexec/site/ec_attachextensions.so (LIBRARY_OFFSET_FROM_MAPS_FILE - 0x2aecc2019f11)
0x2aecc2019f11
上面堆栈跟踪的地址在哪里。我想知道有什么方法可以在不接触地图文件的情况下在堆栈跟踪中获取函数名称?换句话说,我该如何编程?在这里会dladdr
有所帮助(在我的情况下dladdr
,无法从函数提供的地址获取函数名称backtrace
)?