This is the mail archive of the gdb-cvs@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[binutils-gdb] Remove a cleanup from trace_dump_actions


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=15b6611c69f6fdb7a20cd50d33d9acf8c5c32037

commit 15b6611c69f6fdb7a20cd50d33d9acf8c5c32037
Author: Tom Tromey <tom@tromey.com>
Date:   Fri May 18 14:23:27 2018 -0600

    Remove a cleanup from trace_dump_actions
    
    This changes trace_dump_actions to use std::string, removing a
    cleanup.
    
    Tested by the buildbot.
    
    ChangeLog
    2018-05-21  Tom Tromey  <tom@tromey.com>
    
    	* tracepoint.c (trace_dump_actions): Use std::string.

Diff:
---
 gdb/ChangeLog    |  4 ++++
 gdb/tracepoint.c | 24 ++++++------------------
 2 files changed, 10 insertions(+), 18 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 8c6e5ff..e0a6ed4 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
 2018-05-21  Tom Tromey  <tom@tromey.com>
 
+	* tracepoint.c (trace_dump_actions): Use std::string.
+
+2018-05-21  Tom Tromey  <tom@tromey.com>
+
 	* symfile.c (reread_symbols): Use std::string for original_name.
 
 2018-05-21  Tom Tromey  <tom@tromey.com>
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index e170d70..9261fe2 100644
--- a/gdb/tracepoint.c
+++ b/gdb/tracepoint.c
@@ -2679,9 +2679,6 @@ trace_dump_actions (struct command_line *action,
 	     STEPPING_ACTIONS should be equal.  */
 	  if (stepping_frame == stepping_actions)
 	    {
-	      char *cmd = NULL;
-	      struct cleanup *old_chain
-		= make_cleanup (free_current_contents, &cmd);
 	      int trace_string = 0;
 
 	      if (*action_exp == '/')
@@ -2706,31 +2703,22 @@ trace_dump_actions (struct command_line *action,
 		    info_args_command (NULL, from_tty);
 		  else
 		    {		/* variable */
+		      std::string contents;
+		      const char *exp = action_exp;
 		      if (next_comma != NULL)
 			{
 			  size_t len = next_comma - action_exp;
-
-			  cmd = (char *) xrealloc (cmd, len + 1);
-			  memcpy (cmd, action_exp, len);
-			  cmd[len] = 0;
+			  contents = std::string (action_exp, len);
+			  exp = contents.c_str ();
 			}
-		      else
-			{
-			  size_t len = strlen (action_exp);
 
-			  cmd = (char *) xrealloc (cmd, len + 1);
-			  memcpy (cmd, action_exp, len + 1);
-			}
-
-		      printf_filtered ("%s = ", cmd);
-		      output_command_const (cmd, from_tty);
+		      printf_filtered ("%s = ", exp);
+		      output_command_const (exp, from_tty);
 		      printf_filtered ("\n");
 		    }
 		  action_exp = next_comma;
 		}
 	      while (action_exp && *action_exp == ',');
-
-	      do_cleanups (old_chain);
 	    }
 	}
     }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]