doczkal / rpms / abrt

Forked from rpms/abrt 4 years ago
Clone

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

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