开发者

Linux C and C++: what else should I be logging when handling signals like SIGSEGV?

开发者 https://www.devze.com 2023-01-21 22:35 出处:网络
Working on some linux (Ubuntu) systems, running some in-house C and C++ apps (gcc). There is a long list of signals which are handled, such as SIGSEGV and SIGINT.On signal, the callstack is obtained

Working on some linux (Ubuntu) systems, running some in-house C and C++ apps (gcc).

There is a long list of signals which are handled, such as SIGSEGV and SIGINT. On signal, the callstack is obtained using backtrace(3) and backgrace_symbols(3). For C++ the function names are even demangled with abi::__cxa_demangle().

My question is: when these signals come up, what other C/C++ API is there which would give us more useful information to log for debugging after-the-fact? Or is the backtrace the only 's开发者_JS百科exy' thing to do?


You may want to enable core dumps... ulimit -c unlimited or similar. Then you can load the core file into GDB and see what happened to the program.

0

精彩评论

暂无评论...
验证码 换一张
取 消