e: detect when sysactions.conf doesn't let us run gdb.

SVN revision: 79731
This commit is contained in:
Cedric BAIL 2012-11-27 03:48:05 +00:00
parent 003fa1bfbd
commit 85b27ab7e3
2 changed files with 27 additions and 5 deletions

View File

@ -58,6 +58,7 @@ static int ret = 0, sig = 0;
static pid_t pid; static pid_t pid;
static Eina_Bool tainted = EINA_TRUE; static Eina_Bool tainted = EINA_TRUE;
static const char *backtrace_str = NULL; static const char *backtrace_str = NULL;
static int exit_gdb = 0;
int int
main(int argc, char **argv) main(int argc, char **argv)
@ -81,8 +82,12 @@ main(int argc, char **argv)
pid = atoi(argv[i]); // E's pid pid = atoi(argv[i]); // E's pid
else if (i == 3) else if (i == 3)
backtrace_str = argv[i]; 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"); tmp = getenv("E17_TAINTED");
if (tmp && !strcmp(tmp, "NO")) if (tmp && !strcmp(tmp, "NO"))
tainted = EINA_FALSE; tainted = EINA_FALSE;
@ -540,7 +545,18 @@ _e_alert_draw_text(void)
if (!tainted) 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), snprintf(msg, sizeof(msg),
"This is not meant to happen and is likely a sign of \n" "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" "This is not meant to happen and is likely a sign of \n"
"a bug in Enlightenment or the libraries it relies \n" "a bug in Enlightenment or the libraries it relies \n"
"on. You can gdb attach to this process (%d) now \n" "on. You can gdb attach to this process (%d) now \n"
"to try debug it or you could exit, or just hit \n" "to try debug it or you could logout, or just hit \n"
"restart to try and get your desktop back the way \n" "recover to try and get your desktop back the way \n"
"it was.\n" "it was.\n"
"\n" "\n"
"Please compile latest svn E17 and EFL with\n" "Please compile latest svn E17 and EFL with\n"

View File

@ -248,6 +248,7 @@ main(int argc, char **argv)
Eina_Bool restart = EINA_TRUE; Eina_Bool restart = EINA_TRUE;
#endif #endif
/* Setup USR1 to detach from the child process and let it get gdb by advanced users */
action.sa_sigaction = _sigusr1; action.sa_sigaction = _sigusr1;
action.sa_flags = SA_RESETHAND; action.sa_flags = SA_RESETHAND;
sigemptyset(&action.sa_mask); sigemptyset(&action.sa_mask);
@ -505,6 +506,7 @@ main(int argc, char **argv)
ptrace(PT_DETACH, child, NULL, back); ptrace(PT_DETACH, child, NULL, back);
#endif #endif
/* And call gdb if available */ /* And call gdb if available */
r = 0;
if (home) if (home)
{ {
/* call e_sys gdb */ /* call e_sys gdb */
@ -523,15 +525,19 @@ main(int argc, char **argv)
home); home);
backtrace_str = strdup(buffer); backtrace_str = strdup(buffer);
r = WEXITSTATUS(r);
} }
/* call e_alert */ /* call e_alert */
snprintf(buffer, 4096, 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), eina_prefix_lib_get(pfx),
sig.si_signo == SIGSEGV && remember_sigusr1 ? SIGILL : sig.si_signo, sig.si_signo == SIGSEGV && remember_sigusr1 ? SIGILL : sig.si_signo,
child, child,
backtrace_str); backtrace_str,
r);
r = system(buffer); r = system(buffer);
/* kill e */ /* kill e */