可以使用libSegFault.so来获取SIGABRT的回溯吗? [英] Can one use libSegFault.so to get backtraces for SIGABRT?
问题描述
魔咒
LD_PRELOAD=/lib/libSegFault.so someapp
使用libSegFault.so运行someapp
,从而提供关于SIGSEGV的回溯信息,如很多 地方.
runs someapp
with libSegFault.so providing backtrace information on a SIGSEGV as described in many different places.
除了使用类似signal(7)
的方法导致SIGABRT
调用SIGSEGV
处理程序外,还有什么方法可以使libSegFault为assert(3)
失败提供回溯信息?
Other than using signal(7)
-like approaches to cause SIGABRT
to invoke the SIGSEGV
handler, is there some way to get libSegFault to provide backtrace information for assert(3)
failures?
推荐答案
env SEGFAULT_SIGNALS="abrt segv" LD_PRELOAD=/lib/libSegFault.so someapp
请注意,预加载库的实际路径可能有所不同.在我的机器上,我会使用
Note that the actual path to the preload library may differ. On my machine, I'd use
env SEGFAULT_SIGNALS="abrt segv" LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so some-64bit-app
或
env SEGFAULT_SIGNALS="abrt segv" LD_PRELOAD=/lib/i386-linux-gnu/libSegFault.so some-32bit-app
取决于我正在运行的应用程序是编译为64位还是32位. (您可以使用file
进行检查.)
depending whether the application I was running was compiled 64-bit or 32-bit. (You can use file
to check.)
源告诉我们三个定义libSegFault.so
行为方式的环境变量:
The source tells us there are three environment variables that define how libSegFault.so
behaves:
-
SEGFAULT_SIGNALS
:引起堆栈跟踪的信号列表. 默认值为SIGSEGV
.定义但为空的SEGFAULT_SIGNALS
表示没有信号引起堆栈跟踪. 在具有SIGBUS信号的系统上,支持的值为segv
,ill
,abrt
,fpe
,bus
,在具有SIGSTKFLT信号的系统上为stkflt
,而对于所有这些都为all
.
SEGFAULT_SIGNALS
: The list of signals that cause a stack trace. The default isSIGSEGV
. A defined but emptySEGFAULT_SIGNALS
means no signals cause a stack trace. The supported values aresegv
,ill
,abrt
,fpe
,bus
on systems that have the SIGBUS signal,stkflt
on systems that have the SIGSTKFLT signal, andall
for all of these.
SEGFAULT_USE_ALTSTACK
:如果在环境中定义,libSegFault.so
将使用altenate堆栈作为堆栈跟踪信号.
如果您要调试堆栈损坏,这可能会派上用场.
SEGFAULT_USE_ALTSTACK
: If defined in the environment, libSegFault.so
uses an altenate stack for the stack trace signals.
This may come in handy if you are debugging stack corruption.
SEGFAULT_OUTPUT_NAME
:如果在环境中定义,则堆栈跟踪将被写入此文件,而不是标准错误.
SEGFAULT_OUTPUT_NAME
: If defined in the environment, the stack trace is written to this file instead of standard error.
说实话,我最初是通过使用strings /lib/libSegFault.so | sed -e '/[^0-9A-Z_]/ d'
检查库来找到这些的.所有标准库(libSegFault.so
已成为GNU C库的一部分)都可以通过环境变量进行调整,因此使用类似该命令的内容来转储任何看起来像环境变量名称的字符串是一种快速查找要查找内容的方法.在"SEGFAULT_SIGNALS" "SEGFAULT_OUTPUT_NAME"
上进行网络搜索会产生许多有用的链接;看到它已成为GNU C库的一部分,我去了
To be honest, I found these initially by examining the library with strings /lib/libSegFault.so | sed -e '/[^0-9A-Z_]/ d'
. All standard libraries (libSegFault.so
having become a part of GNU C library) are tunable via environment variables, so using something like that command to dump any strings that look like environment variable names is a quick way to find stuff to search for. Doing a web search on "SEGFAULT_SIGNALS" "SEGFAULT_OUTPUT_NAME"
produces a number of useful links; seeing that it was part of the GNU C library nowadays, I went to the source git archives, found the actual source file for the library, and posted my answer.
这篇关于可以使用libSegFault.so来获取SIGABRT的回溯吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!