[Bug python/21366] Python script causes GDB core dump

dwjbosman at yahoo dot com sourceware-bugzilla@sourceware.org
Tue Apr 11 10:03:00 GMT 2017


https://sourceware.org/bugzilla/show_bug.cgi?id=21366

--- Comment #3 from Dinne Bosman <dwjbosman at yahoo dot com> ---
The diff between the working and next non working commit:

git diff
3e25a500a1ba05587389737e7c617e5ae6dd2bcf..5809899dad253e2fefcb6f7ae57a6f43cfa4e3c5
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index fe3ea42..8c8b18a 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,10 @@
 2016-09-23  Tom Tromey  <tom@tromey.com>

+       * break-catch-sig.c: Include <string>.
+       (signal_catchpoint_print_one): Use std::string.
+
+2016-09-23  Tom Tromey  <tom@tromey.com>
+
        * utils.c (struct restore_ui_out_closure): Remove.
        * objfiles.h (terminate_minimal_symbol_table): Don't declare.

diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c
index 06ee44c..296f900 100644
--- a/gdb/break-catch-sig.c
+++ b/gdb/break-catch-sig.c
@@ -28,7 +28,8 @@
 #include "valprint.h"
 #include "cli/cli-utils.h"
 #include "completer.h"
-#include "gdb_obstack.h"
+
+#include <string>

 #define INTERNAL_SIGNAL(x) ((x) == GDB_SIGNAL_TRAP || (x) == GDB_SIGNAL_INT)

@@ -265,11 +266,7 @@ signal_catchpoint_print_one (struct breakpoint *b,
     {
       int i;
       gdb_signal_type iter;
-      struct obstack text;
-      struct cleanup *cleanup;
-
-      obstack_init (&text);
-      cleanup = make_cleanup_obstack_free (&text);
+      std::string text;

       for (i = 0;
            VEC_iterate (gdb_signal_type, c->signals_to_be_caught, i, iter);
@@ -278,12 +275,10 @@ signal_catchpoint_print_one (struct breakpoint *b,
          const char *name = signal_to_name_or_int (iter);

          if (i > 0)
-           obstack_grow (&text, " ", 1);
-         obstack_grow (&text, name, strlen (name));
+           text += " ";
+         text += name;
         }
-      obstack_grow (&text, "", 1);
-      do_cleanups (cleanup);iout, "what", (const char *) obstack_base
(&text));--More--
+      ui_out_field_string (uiout, "what", text.c_str ());
     }
   else
     ui_out_field_string (uiout, "what",


The changes seem minor. So in the non working version I started undoing changes
to see if the modified GDB would work. At the end the change that made the
difference is just the declaration of

 std::string text;

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the Gdb-prs mailing list