From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA] Remove a cleanup from trace_dump_actions
Date: Sat, 19 May 2018 16:06:00 -0000 [thread overview]
Message-ID: <20180519151757.18031-1-tom@tromey.com> (raw)
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
next reply other threads:[~2018-05-19 15:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-19 16:06 Tom Tromey [this message]
2018-05-20 23:58 ` Simon Marchi
2018-05-21 16:04 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180519151757.18031-1-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox