Talk:Obtaining a stack trace in C upon SIGSEGV

From TLUGWiki

Jump to: navigation, search

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.

Personal tools