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

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