static struct sigaction ms_pipe_old_action;
static void _ms_signal_handler(int signo);
-static void _ms_signal_backtrace(void *arg);
static void _ms_signal_sigaction(int signo, siginfo_t *si, void *arg);
static void _ms_signal_handler(int signo)
raise(signo);
}
-static void _ms_signal_backtrace(void *arg)
-{
- void *trace[MUSE_MSG_LEN];
- int tracesize;
- int idx;
- char **strings = NULL;
- ucontext_t *uctxt = NULL;
- Dl_info info;
- char *sym_addr = NULL;
-
- if (!arg)
- return;
-
- tracesize = backtrace(trace, MUSE_MSG_LEN);
- if (tracesize <= 0)
- return;
-
- uctxt = (ucontext_t *)arg;
-
-#if defined(REG_EIP)
- trace[1] = (void *) uctxt->uc_mcontext.gregs[REG_EIP];
-#elif defined(REG_RIP)
- trace[1] = (void *) uctxt->uc_mcontext.gregs[REG_RIP];
-#endif
-
- strings = backtrace_symbols(trace, tracesize);
- if (!strings)
- return;
-
- /* skip the first stack frame because it just points here. */
- for (idx = 1; idx < tracesize; idx++) {
- sym_addr = g_strstr_len(strings[idx], strlen(strings[idx]), "[0x");
-
- memset(&info, 0, sizeof(info));
- if (sym_addr && dladdr((const void *)strtoul(sym_addr + 1, NULL, 16), &info) && info.dli_sname)
- LOGE("[%u] %s %s", idx - 1, strings[idx], info.dli_sname);
- else
- LOGE("[%u] %s", idx - 1, strings[idx]);
- }
-
- free(strings);
-}
-
static void _ms_signal_sigaction(int signo, siginfo_t *si, void *arg)
{
muse_return_if_fail(si);
ms_remove_ready_file();
ms_config_remove_lockfile();
- _ms_signal_backtrace(arg);
_ms_signal_handler(signo);
}