From: bdemsky Date: Fri, 15 May 2009 22:05:27 +0000 (+0000) Subject: changes for alex X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=1ecb8886e5fc0db5b3bb638ee934a6552de4dfe9;p=IRC.git changes for alex --- diff --git a/Robust/src/Runtime/thread.c b/Robust/src/Runtime/thread.c index 3b717dff..e2d70acc 100644 --- a/Robust/src/Runtime/thread.c +++ b/Robust/src/Runtime/thread.c @@ -18,6 +18,8 @@ #ifdef STM #include "tm.h" #endif +#include + int threadcount; pthread_mutex_t gclock; @@ -114,13 +116,25 @@ transstart: pthread_exit(NULL); } -void threadhandler(int sig, siginfo_t *info, void *uap) { +void threadhandler(int sig, struct sigcontext ctx) { + void *buffer[100]; + char **strings; + int nptrs,j; + printf("We just took sig=%d\n",sig); printf("signal\n"); printf("To get stack trace, set breakpoint in threadhandler in gdb\n"); -#ifndef MAC - backtrace(); -#endif + nptrs = backtrace(buffer, 100); + buffer[1]=(void *)ctx.eip; + strings = backtrace_symbols(buffer, nptrs); + if (strings == NULL) { + perror("backtrace_symbols"); + exit(EXIT_FAILURE); + } + + for (j = 0; j < nptrs; j++) + printf("%s\n", strings[j]); + threadexit(); } @@ -144,8 +158,9 @@ void initializethreads() { processOptions(); initializeexithandler(); - sig.sa_sigaction=&threadhandler; - sig.sa_flags=SA_SIGINFO; + //deprecated use of sighandler, but apparently still works + sig.sa_handler=(void *)threadhandler; + sig.sa_flags=SA_RESTART; sigemptyset(&sig.sa_mask); /* Catch bus errors, segmentation faults, and floating point exceptions*/