This is the mail archive of the crossgcc@sources.redhat.com mailing list for the crossgcc project.
See the CrossGCC FAQ for lots more information.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
For those who don't know about it yet: We're using glibc's backtrace() call ( http://www.gnu.org/manual/glibc-2.2.3/html_chapter/libc_33.html ) with good results on ppc with HardHat 2.0's glibc. It lets me add a built-in lightweight stack dump to my production programs (not that my programs crash, but it'd be nice to have a backtrace if I ever have to debug a crash on a system without a debugger). I'm attaching a little demo program for backtrace(). Compile with -g, run it, and send its output through binutil's addr2line. Try it on your PC first to see what the expected results are. And on a related note: We've also built our own glibc on sh4, but backtrace() isn't so happy there; it doesn't produce usable results. We're using glibc2.2.4 (with the Debian patch from the dodes project). Are there other sh4 users here? Are you using something more up to date than glibc2.2.4? And does the backtrace demo work for you? Thanks, Dan -- Dan Kegel http://www.kegel.com http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045
#include <stdio.h> #include <signal.h> #include <execinfo.h> void handler() { int i; void *bt[128]; int bt_size; printf("\n########## Backtrace ##########\n"); bt_size = backtrace(bt, sizeof(bt) / sizeof(void *)); printf("Number of elements in backtrace: %d\n", bt_size); for (i = 0; i < bt_size; i++) { printf("%p\n", bt[i]); } printf("Handler done.\n"); } void g() { abort(); } void f() { g(); } int main(int argc, char **argv) { struct sigaction SignalAction; SignalAction.sa_sigaction = handler; sigemptyset(&SignalAction.sa_mask); SignalAction.sa_flags = SA_SIGINFO; sigaction(SIGSEGV, &SignalAction, NULL); sigaction(SIGABRT, &SignalAction, NULL); f(); }
------ Want more information? See the CrossGCC FAQ, http://www.objsw.com/CrossGCC/ Want to unsubscribe? Send a note to crossgcc-unsubscribe@sources.redhat.com
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |