[RFA] Remove a cleanup from trace_dump_actions
Tom Tromey
tom@tromey.com
Sat May 19 16:06:00 GMT 2018
This changes trace_dump_actions to use std::string, removing a
cleanup.
Tested by the buildbot.
gdb/ChangeLog
2018-05-19 Tom Tromey <tom@tromey.com>
* tracepoint.c (trace_dump_actions): Use std::string.
---
gdb/ChangeLog | 4 ++++
gdb/tracepoint.c | 20 ++++----------------
2 files changed, 8 insertions(+), 16 deletions(-)
diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c
index e170d704bc..d83af78dd5 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,20 +2703,13 @@ trace_dump_actions (struct command_line *action,
info_args_command (NULL, from_tty);
else
{ /* variable */
+ std::string contents;
+ const char *cmd = 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;
- }
- else
- {
- size_t len = strlen (action_exp);
-
- cmd = (char *) xrealloc (cmd, len + 1);
- memcpy (cmd, action_exp, len + 1);
+ contents = std::string (action_exp, len);
+ cmd = contents.c_str ();
}
printf_filtered ("%s = ", cmd);
@@ -2729,8 +2719,6 @@ trace_dump_actions (struct command_line *action,
action_exp = next_comma;
}
while (action_exp && *action_exp == ',');
-
- do_cleanups (old_chain);
}
}
}
--
2.13.6
More information about the Gdb-patches
mailing list