doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

Blame SOURCES/0076-Revert-gdb-disable-loading-of-auto-loaded-files.patch

baab13
From f02866555da23e00ad3a76a8d540bd83804c439f Mon Sep 17 00:00:00 2001
baab13
From: Jakub Filak <jfilak@redhat.com>
baab13
Date: Wed, 19 Nov 2014 07:19:29 +0100
baab13
Subject: [ABRT PATCH 76/78] Revert "gdb: disable loading of auto-loaded files"
baab13
baab13
This reverts commit 5a2f83cd86ce824167fa7ea8e5357c014034ed46.
baab13
baab13
Turning auto-load off also turns the pretty printer off.
baab13
baab13
Unfortunately, we must trust to providers of the auto-loaded scripts and
baab13
we must be fixing root causes and not treating symptoms.
baab13
baab13
Related: #1128637
baab13
---
baab13
 src/lib/hooklib.c | 40 +++++++++++++++++++---------------------
baab13
 1 file changed, 19 insertions(+), 21 deletions(-)
baab13
baab13
diff --git a/src/lib/hooklib.c b/src/lib/hooklib.c
baab13
index 21ad9e0..4a50727 100644
baab13
--- a/src/lib/hooklib.c
baab13
+++ b/src/lib/hooklib.c
baab13
@@ -252,12 +252,10 @@ char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char
baab13
     /* Let user know what's going on */
baab13
     log(_("Generating backtrace"));
baab13
 
baab13
-    char *args[23];
baab13
+    char *args[21];
baab13
     args[0] = (char*)"gdb";
baab13
     args[1] = (char*)"-batch";
baab13
     args[2] = (char*)"-ex";
baab13
-    args[3] = (char*)"set auto-load off";
baab13
-    args[4] = (char*)"-ex";
baab13
     struct strbuf *set_debug_file_directory = strbuf_new();
baab13
     if(debuginfo_dirs == NULL)
baab13
     {
baab13
@@ -280,7 +278,7 @@ char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char
baab13
             p = colon_or_nul;
baab13
         }
baab13
     }
baab13
-    args[5] = strbuf_free_nobuf(set_debug_file_directory);
baab13
+    args[3] = strbuf_free_nobuf(set_debug_file_directory);
baab13
 
baab13
     /* "file BINARY_FILE" is needed, without it gdb cannot properly
baab13
      * unwind the stack. Currently the unwind information is located
baab13
@@ -302,27 +300,27 @@ char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char
baab13
      * TODO: check mtimes on COREFILE and BINARY_FILE and not supply
baab13
      * BINARY_FILE if it is newer (to at least avoid gdb complaining).
baab13
      */
baab13
-    args[6] = (char*)"-ex";
baab13
-    args[7] = xasprintf("file %s", executable);
baab13
+    args[4] = (char*)"-ex";
baab13
+    args[5] = xasprintf("file %s", executable);
baab13
     free(executable);
baab13
 
baab13
-    args[8] = (char*)"-ex";
baab13
-    args[9] = xasprintf("core-file %s/"FILENAME_COREDUMP, dump_dir_name);
baab13
+    args[6] = (char*)"-ex";
baab13
+    args[7] = xasprintf("core-file %s/"FILENAME_COREDUMP, dump_dir_name);
baab13
 
baab13
+    args[8] = (char*)"-ex";
baab13
+    /*args[9] = ... see below */
baab13
     args[10] = (char*)"-ex";
baab13
-    /*args[11] = ... see below */
baab13
-    args[12] = (char*)"-ex";
baab13
-    args[13] = (char*)"info sharedlib";
baab13
+    args[11] = (char*)"info sharedlib";
baab13
     /* glibc's abort() stores its message in __abort_msg variable */
baab13
+    args[12] = (char*)"-ex";
baab13
+    args[13] = (char*)"print (char*)__abort_msg";
baab13
     args[14] = (char*)"-ex";
baab13
-    args[15] = (char*)"print (char*)__abort_msg";
baab13
+    args[15] = (char*)"print (char*)__glib_assert_msg";
baab13
     args[16] = (char*)"-ex";
baab13
-    args[17] = (char*)"print (char*)__glib_assert_msg";
baab13
+    args[17] = (char*)"info all-registers";
baab13
     args[18] = (char*)"-ex";
baab13
-    args[19] = (char*)"info all-registers";
baab13
-    args[20] = (char*)"-ex";
baab13
-    args[21] = (char*)"disassemble";
baab13
-    args[22] = NULL;
baab13
+    args[19] = (char*)"disassemble";
baab13
+    args[20] = NULL;
baab13
 
baab13
     /* Get the backtrace, but try to cap its size */
baab13
     /* Limit bt depth. With no limit, gdb sometimes OOMs the machine */
baab13
@@ -332,9 +330,9 @@ char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char
baab13
     char *bt = NULL;
baab13
     while (1)
baab13
     {
baab13
-        args[11] = xasprintf("%s backtrace %u%s", thread_apply_all, bt_depth, full);
baab13
+        args[9] = xasprintf("%s backtrace %u%s", thread_apply_all, bt_depth, full);
baab13
         bt = exec_vp(args, /*redirect_stderr:*/ 1, timeout_sec, NULL);
baab13
-        free(args[11]);
baab13
+        free(args[9]);
baab13
         if ((bt && strnlen(bt, 256*1024) < 256*1024) || bt_depth <= 32)
baab13
         {
baab13
             break;
baab13
@@ -359,7 +357,7 @@ char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char
baab13
          * End of assembler dump.
baab13
          * (IOW: "empty" dump)
baab13
          */
baab13
-        args[21] = (char*)"disassemble $pc-20, $pc+64";
baab13
+        args[19] = (char*)"disassemble $pc-20, $pc+64";
baab13
 
baab13
         if (bt_depth <= 64 && thread_apply_all[0] != '\0')
baab13
         {
baab13
@@ -375,9 +373,9 @@ char *get_backtrace(const char *dump_dir_name, unsigned timeout_sec, const char
baab13
         }
baab13
     }
baab13
 
baab13
+    free(args[3]);
baab13
     free(args[5]);
baab13
     free(args[7]);
baab13
-    free(args[9]);
baab13
     return bt;
baab13
 }
baab13
 
baab13
-- 
baab13
1.8.3.1
baab13