cedric pushed a commit to branch master.

http://git.enlightenment.org/core/enlightenment.git/commit/?id=147f088efae2885c52d6f4a71bdac9f9945f7138

commit 147f088efae2885c52d6f4a71bdac9f9945f7138
Author: Cedric BAIL <[email protected]>
Date:   Thu Dec 19 16:39:46 2013 +0900

    gdb: detect that the file was generated properly.
    
    This is a workaround kernel that prevent ptrace to another process.
---
 src/bin/e_alert_main.c |  4 ++--
 src/bin/e_start_main.c | 17 ++++++++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/src/bin/e_alert_main.c b/src/bin/e_alert_main.c
index 5cd1890..1513a91 100644
--- a/src/bin/e_alert_main.c
+++ b/src/bin/e_alert_main.c
@@ -81,9 +81,9 @@ main(int argc, char **argv)
         else if (i == 2)
           pid = atoi(argv[i]);  // E's pid
         else if (i == 3)
-          backtrace_str = argv[i];
-        else if (i == 4)
           exit_gdb = atoi(argv[i]);
+        else if (i == 4)
+          backtrace_str = argv[i];
      }
 
    fprintf(stderr, "exit_gdb: %i\n", exit_gdb);
diff --git a/src/bin/e_start_main.c b/src/bin/e_start_main.c
index 7b0c8c3..fa28cc8 100644
--- a/src/bin/e_start_main.c
+++ b/src/bin/e_start_main.c
@@ -563,8 +563,11 @@ main(int argc, char **argv)
 #endif
                             /* And call gdb if available */
                             r = 0;
+
                             if (home)
                               {
+                                struct stat st;
+
                                  /* call e_sys gdb */
                                  snprintf(buffer, sizeof(buffer),
                                           "gdb "
@@ -585,20 +588,24 @@ main(int argc, char **argv)
                                           "%s/.e-crashdump.txt",
                                           home);
 
-                                 backtrace_str = strdup(buffer);
+                                /* 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);
                                  r = WEXITSTATUS(r);
                               }
 
                             /* call e_alert */
                             snprintf(buffer, 4096,
                                      backtrace_str ?
-                                     
"%s/enlightenment/utils/enlightenment_alert %i %i '%s' %i" :
-                                     
"%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 %i",
                                      eina_prefix_lib_get(pfx),
                                      sig.si_signo == SIGSEGV && 
remember_sigusr1 ? SIGILL : sig.si_signo,
                                      child,
-                                     backtrace_str,
-                                     r);
+                                     r,
+                                     backtrace_str);
                             r = system(buffer);
 
                             /* kill e */

-- 


Reply via email to