-/* signal seg reaches, this function will run */
-static void ms_signal_segv(int signum, siginfo_t * info, void * ptr) {
- int i;
-
- UNUSED_ARGUMENT(signum);
- UNUSED_ARGUMENT(info);
- UNUSED_ARGUMENT(ptr);
-
- pthread_mutex_lock(&ms_global.quit_mutex);
- fprintf(stderr, "Segmentation fault occurred.\n");
-
-#if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64)
- int f = 0;
- Dl_info dlinfo;
- void **bp = 0;
- void *ip = 0;
-#else
- void *bt[20];
- char **strings;
- int sz;
-#endif
-
-#if defined(SIGSEGV_STACK_X86) || defined(SIGSEGV_STACK_IA64)
-#if defined(SIGSEGV_STACK_IA64)
- ip = (void*)ucontext->uc_mcontext.gregs[REG_RIP];
- bp = (void**)ucontext->uc_mcontext.gregs[REG_RBP];
-#elif defined(SIGSEGV_STACK_X86)
- ip = (void*)ucontext->uc_mcontext.gregs[REG_EIP];
- bp = (void**)ucontext->uc_mcontext.gregs[REG_EBP];
-#endif
-
- fprintf(stderr, "Stack trace:\n");
- while(bp && ip) {
- if(!dladdr(ip, &dlinfo))
- break;