From 85b27ab7e37710bd7beb94970bc2429658ee9193 Mon Sep 17 00:00:00 2001 From: Cedric BAIL Date: Tue, 27 Nov 2012 03:48:05 +0000 Subject: [PATCH] e: detect when sysactions.conf doesn't let us run gdb. SVN revision: 79731 --- src/bin/e_alert_main.c | 22 +++++++++++++++++++--- src/bin/e_start_main.c | 10 ++++++++-- 2 files changed, 27 insertions(+), 5 deletions(-) diff --git a/src/bin/e_alert_main.c b/src/bin/e_alert_main.c index a9044370c..d455b0758 100644 --- a/src/bin/e_alert_main.c +++ b/src/bin/e_alert_main.c @@ -58,6 +58,7 @@ static int ret = 0, sig = 0; static pid_t pid; static Eina_Bool tainted = EINA_TRUE; static const char *backtrace_str = NULL; +static int exit_gdb = 0; int main(int argc, char **argv) @@ -81,8 +82,12 @@ main(int argc, char **argv) pid = atoi(argv[i]); // E's pid else if (i == 3) backtrace_str = argv[i]; + else if (i == 4) + exit_gdb = atoi(argv[i]); } + fprintf(stderr, "exit_gdb: %i\n", exit_gdb); + tmp = getenv("E17_TAINTED"); if (tmp && !strcmp(tmp, "NO")) tainted = EINA_FALSE; @@ -540,7 +545,18 @@ _e_alert_draw_text(void) if (!tainted) { - if (backtrace_str) + if (exit_gdb) + { + snprintf(msg, sizeof(msg), + "This is not meant to happen and is likely a sign of \n" + "a bug in Enlightenment or the libraries it relies \n" + "on. We were not able to generate a backtrace, check \n" + "if your 'sysactions.conf' has an 'gdb' action line.\n" + "\n" + "Please compile latest svn E17 and EFL with\n" + "-g and -ggdb3 in your CFLAGS.\n"); + } + else if (backtrace_str) { snprintf(msg, sizeof(msg), "This is not meant to happen and is likely a sign of \n" @@ -559,8 +575,8 @@ _e_alert_draw_text(void) "This is not meant to happen and is likely a sign of \n" "a bug in Enlightenment or the libraries it relies \n" "on. You can gdb attach to this process (%d) now \n" - "to try debug it or you could exit, or just hit \n" - "restart to try and get your desktop back the way \n" + "to try debug it or you could logout, or just hit \n" + "recover to try and get your desktop back the way \n" "it was.\n" "\n" "Please compile latest svn E17 and EFL with\n" diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c index e801443cb..5287b5c7e 100644 --- a/src/bin/e_start_main.c +++ b/src/bin/e_start_main.c @@ -248,6 +248,7 @@ main(int argc, char **argv) Eina_Bool restart = EINA_TRUE; #endif + /* Setup USR1 to detach from the child process and let it get gdb by advanced users */ action.sa_sigaction = _sigusr1; action.sa_flags = SA_RESETHAND; sigemptyset(&action.sa_mask); @@ -505,6 +506,7 @@ main(int argc, char **argv) ptrace(PT_DETACH, child, NULL, back); #endif /* And call gdb if available */ + r = 0; if (home) { /* call e_sys gdb */ @@ -523,15 +525,19 @@ main(int argc, char **argv) home); backtrace_str = strdup(buffer); + r = WEXITSTATUS(r); } /* call e_alert */ snprintf(buffer, 4096, - backtrace_str ? "%s/enlightenment/utils/enlightenment_alert %i %i %s" : "%s/enlightenment/utils/enlightenment_alert %i %i %s", + backtrace_str ? + "%s/enlightenment/utils/enlightenment_alert %i %i '%s' %i" : + "%s/enlightenment/utils/enlightenment_alert %i %i '%s' %i", eina_prefix_lib_get(pfx), sig.si_signo == SIGSEGV && remember_sigusr1 ? SIGILL : sig.si_signo, child, - backtrace_str); + backtrace_str, + r); r = system(buffer); /* kill e */