Talk:Obtaining a stack trace in C upon SIGSEGV
From TLUGWiki
[edit] static handler
Hi!
any special reason why the handler is static?
bye, kolja
jkroon:
Yes, there is no need to expose the symbol outside of the source file. It just helps to keep your name-space clean (as an end result the code exposes no symbols via the object so there is absolutely no way for my function names to conflict with anything that you declare/define elsewhere).
[edit] non-x86
Hi!
It's very nice stuff and works fine on x86. But on x86_64/EMT64 I got segmentation fault inside signal handler. Could you help me, what should I change to get working code ?
jkroon:
I am not sure what's going wrong, works fine here, if you can supply a test-case that'll break it, I'll be able to figure out where it's going wrong.
[edit] compiler errors
HI, I am getting the following compiler error when trying to build sigsegv program
sigsegv.cpp:13:1: warning: "_GNU_SOURCE" redefined <command line>:1:1: warning: this is the location of the previous definition sigsegv.cpp: In function `void signal_segv(int, siginfo_t*, void*)': sigsegv.cpp:78: error: `__cxa_demangle' was not declared in this scope sigsegv.cpp:87: error: invalid use of `void' sigsegv.cpp:78: warning: unused variable '__cxa_demangle'
Can you provide me any help? thanks
arnie
jkroon:
Hi, firstly, it's "C" code, not C++, so rename the file to end with .c, not .cpp.
Secondly, I've now wrapped the #define _GNU_SOURCE into an #ifndef which should get rid of the error.

