gdb: detect that the file was generated properly.

This is a workaround kernel that prevent ptrace to another process.
This commit is contained in:
Cedric BAIL 2013-12-19 16:39:46 +09:00
parent fd271ba0c8
commit 147f088efa
2 changed files with 14 additions and 7 deletions

View File

@ -81,9 +81,9 @@ main(int argc, char **argv)
else if (i == 2) else if (i == 2)
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];
else if (i == 4)
exit_gdb = atoi(argv[i]); exit_gdb = atoi(argv[i]);
else if (i == 4)
backtrace_str = argv[i];
} }
fprintf(stderr, "exit_gdb: %i\n", exit_gdb); fprintf(stderr, "exit_gdb: %i\n", exit_gdb);

View File

@ -563,8 +563,11 @@ main(int argc, char **argv)
#endif #endif
/* And call gdb if available */ /* And call gdb if available */
r = 0; r = 0;
if (home) if (home)
{ {
struct stat st;
/* call e_sys gdb */ /* call e_sys gdb */
snprintf(buffer, sizeof(buffer), snprintf(buffer, sizeof(buffer),
"gdb " "gdb "
@ -585,6 +588,10 @@ main(int argc, char **argv)
"%s/.e-crashdump.txt", "%s/.e-crashdump.txt",
home); home);
/* Check the file was correctly generated (may fail on crappy kernel with ptrace
diable). In which case a manual : echo 0 > /proc/sys/kernel/yama/ptrace_scope
as root is necessary. */
if (!stat(buffer, &st))
backtrace_str = strdup(buffer); backtrace_str = strdup(buffer);
r = WEXITSTATUS(r); r = WEXITSTATUS(r);
} }
@ -592,13 +599,13 @@ main(int argc, char **argv)
/* call e_alert */ /* call e_alert */
snprintf(buffer, 4096, snprintf(buffer, 4096,
backtrace_str ? backtrace_str ?
"%s/enlightenment/utils/enlightenment_alert %i %i '%s' %i" : "%s/enlightenment/utils/enlightenment_alert %i %i %i '%s'" :
"%s/enlightenment/utils/enlightenment_alert %i %i '%s' %i", "%s/enlightenment/utils/enlightenment_alert %i %i %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, r,
r); backtrace_str);
r = system(buffer); r = system(buffer);
/* kill e */ /* kill e */