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

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