[RFA,1/5] Use std::string in break-catch-sig.c

Message ID 1474566656-15389-2-git-send-email-tom@tromey.com
State New, archived
Headers

Commit Message

Tom Tromey Sept. 22, 2016, 5:50 p.m. UTC
  This changes one spot in break-catch-sig.c to use std::string,
removing some cleanups.

2016-09-22  Tom Tromey  <tom@tromey.com>

	* break-catch-sig.c: Include <string>.
	(signal_catchpoint_print_one): Use std::string.
---
 gdb/ChangeLog         |  5 +++++
 gdb/break-catch-sig.c | 17 ++++++-----------
 2 files changed, 11 insertions(+), 11 deletions(-)
  

Comments

Yao Qi Sept. 23, 2016, 9:49 a.m. UTC | #1
On Thu, Sep 22, 2016 at 6:50 PM, Tom Tromey <tom@tromey.com> wrote:
> This changes one spot in break-catch-sig.c to use std::string,
> removing some cleanups.
>
> 2016-09-22  Tom Tromey  <tom@tromey.com>
>
>         * break-catch-sig.c: Include <string>.
>         (signal_catchpoint_print_one): Use std::string.

Patch is good to me.
  

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index ea14f04..f9924e5 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@ 
+2016-09-22  Tom Tromey  <tom@tromey.com>
+
+	* break-catch-sig.c: Include <string>.
+	(signal_catchpoint_print_one): Use std::string.
+
 2016-09-22  Edjunior Barbosa Machado  <emachado@linux.vnet.ibm.com>
 
 	* rs6000-tdep.c (ppc_process_record_op31): Fix
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);
-      ui_out_field_string (uiout, "what", (const char *) obstack_base (&text));
-      do_cleanups (cleanup);
+      ui_out_field_string (uiout, "what", text.c_str ());
     }
   else
     ui_out_field_string (uiout, "what",