Remove a cleanup from trace_dump_actions
authorTom Tromey <tom@tromey.com>
Fri, 18 May 2018 20:23:27 +0000 (14:23 -0600)
committerTom Tromey <tom@tromey.com>
Mon, 21 May 2018 15:53:15 +0000 (09:53 -0600)
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.

gdb/ChangeLog
gdb/tracepoint.c

index 8c6e5ff4683ccdd7669b7720d863152dda81b405..e0a6ed4051272cbf120ca45921ff15f9f2167f00 100644 (file)
@@ -1,3 +1,7 @@
+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.
index e170d704bc9193fb10a9320d879fe0ddcada030f..9261fe2a27f8ab142d3dc4dac73217cd17682c4b 100644 (file)
@@ -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);
            }
        }
     }