For C:
(1) positive solution:
Mipsel-Linux-GCC backt. C-g-rdynamic-fexceptions
Cause:
-Fexceptions
Enable exception handling. generates extra code needed to propagate exceptions. for some targets, this implies GCC generates frame unwind information for all functions, which can produce significant data size overhead, although it does not affect execution. if
You do not specify this option, GCC enables it by default for versions like C ++ that normally require exception handling, and disables it for versions like C that do not normally require it. however, you may need to enable this option when compiling C code
That needs to interoperate properly with exception handlers written in C ++. You may also wish to disable this option if you are compiling older C ++ programs that don't use exception handling.
(2)
Mipsel-Linux-GCC backt. C-g-rdynamic-funwind-tables
(3)
Mipsel-Linux-GCC backt. C-g-rdynamic-fasynchronous-Unwind-tables
For C ++:
Mipsel-Linux-G ++ backt. C-g-rdynamic
The following is the implementation of backt. C:
# Include <execinfo. h> # include <stdio. h> # include <stdlib. h> # include <signal. h> # include <unistd. h> void print_bt () {void * array [10]; size_t size; char ** strings; size_t I; size = backtrace (array, 10); strings = backtrace_symbols (array, size); printf ("***** Obtained % zd stack frames. * *** \ n ", size); for (I = 0; I <size; I ++) printf (" % s \ n ", strings [I]); free (strings);} // segment error handling function void dump (int signo) {printf ("[***** Program passed ed signal SIGSEGV, segmentation fault. id = % d *****] \ n ", signo); print_bt (); exit (0);} void fun3 () {print_bt ();} void fun2 () {fun3 ();} void fun1 () {fun2 ();} int main (int argc, char * argv []) {signal (SIGSEGV, & dump); signal (SIGABRT, & dump); fun1 (); return 0 ;}
References:
Http://sourceware.org/ml/libc-ports/2006-04/msg00009.html
Http://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html