[RFA] Remove a cleanup from trace_dump_actions
Commit Message
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(-)
Comments
On 2018-05-19 11:17 AM, Tom Tromey wrote:
> This changes trace_dump_actions to use std::string, removing a
> cleanup.
LGTM, but I would suggest finding another name for cmd, to avoid
shadowing the other cmd variable.
Simon
>>>>> "Simon" == Simon Marchi <simark@simark.ca> writes:
Simon> On 2018-05-19 11:17 AM, Tom Tromey wrote:
>> This changes trace_dump_actions to use std::string, removing a
>> cleanup.
Simon> LGTM, but I would suggest finding another name for cmd, to avoid
Simon> shadowing the other cmd variable.
I renamed it to "exp", since it is an expression, not a command.
Tom
@@ -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);
}
}
}