static struct sigaction ms_xcpu_old_action;
static struct sigaction ms_pipe_old_action;
-static GMutex signal_lock;
-
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);
ucontext_t *uctxt = NULL;
Dl_info info;
char *sym_addr = NULL;
- char err_msg[MUSE_MSG_LEN_MAX] = {'\0',};
-
- muse_return_if_fail(arg);
-
- g_mutex_lock(&signal_lock);
- LOGE("----------BEGIN MUSE DYING MESSAGE----------");
+ if (!arg)
+ return;
tracesize = backtrace(trace, MUSE_MSG_LEN);
- if (tracesize < 0) {
- strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
- LOGE("backtrace error: %s", err_msg);
- }
+ if (tracesize <= 0)
+ return;
uctxt = (ucontext_t *)arg;
- #if defined(REG_EIP)
+#if defined(REG_EIP)
trace[1] = (void *) uctxt->uc_mcontext.gregs[REG_EIP];
- #elif defined(REG_RIP)
+#elif defined(REG_RIP)
trace[1] = (void *) uctxt->uc_mcontext.gregs[REG_RIP];
- #endif
+#endif
+
strings = backtrace_symbols(trace, tracesize);
- if (!strings) {
- strerror_r(errno, err_msg, MUSE_MSG_LEN_MAX);
- LOGE("backtrace_symbols error: %s", err_msg);
- } else {
- /* 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);
+ 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]);
}
- LOGE("----------END MUSE DYING MESSAGE----------");
-
- g_mutex_unlock(&signal_lock);
+ free(strings);
}
static void _ms_signal_sigaction(int signo, siginfo_t *si, void *arg)