From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [RFA 04/10] Use std::string in mi_cmd_interpreter_exec
Date: Tue, 29 Aug 2017 19:25:00 -0000 [thread overview]
Message-ID: <20170829192524.29971-5-tom@tromey.com> (raw)
In-Reply-To: <20170829192524.29971-1-tom@tromey.com>
Change mi_cmd_interpreter_exec to use std::string, removing a cleanup.
ChangeLog
2017-08-29 Tom Tromey <tom@tromey.com>
* mi/mi-interp.c (mi_cmd_interpreter_exec): Use std::string.
---
gdb/ChangeLog | 4 ++++
gdb/mi/mi-interp.c | 12 ++++--------
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 9c8bb47..b13ce63 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2017-08-29 Tom Tromey <tom@tromey.com>
+ * mi/mi-interp.c (mi_cmd_interpreter_exec): Use std::string.
+
+2017-08-29 Tom Tromey <tom@tromey.com>
+
* mi/mi-cmd-env.c (env_execute_cli_command): Use
gdb::unique_xmalloc_ptr.
diff --git a/gdb/mi/mi-interp.c b/gdb/mi/mi-interp.c
index 959ae37..6b6d8f0 100644
--- a/gdb/mi/mi-interp.c
+++ b/gdb/mi/mi-interp.c
@@ -206,8 +206,6 @@ mi_cmd_interpreter_exec (const char *command, char **argv, int argc)
{
struct interp *interp_to_use;
int i;
- char *mi_error_message = NULL;
- struct cleanup *old_chain;
if (argc < 2)
error (_("-interpreter-exec: "
@@ -231,24 +229,22 @@ mi_cmd_interpreter_exec (const char *command, char **argv, int argc)
/* Now run the code. */
- old_chain = make_cleanup (null_cleanup, 0);
+ std::string mi_error_message;
for (i = 1; i < argc; i++)
{
struct gdb_exception e = interp_exec (interp_to_use, argv[i]);
if (e.reason < 0)
{
- mi_error_message = xstrdup (e.message);
- make_cleanup (xfree, mi_error_message);
+ mi_error_message = e.message;
break;
}
}
mi_remove_notify_hooks ();
- if (mi_error_message != NULL)
- error ("%s", mi_error_message);
- do_cleanups (old_chain);
+ if (!mi_error_message.empty ())
+ error ("%s", mi_error_message.c_str ());
}
/* This inserts a number of hooks that are meant to produce
--
2.9.4
next prev parent reply other threads:[~2017-08-29 19:25 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-08-29 19:25 [RFA 00/10] some string cleanup removal Tom Tromey
2017-08-29 19:25 ` [RFA 09/10] Use std::string and unique_xmalloc_ptr in compile/ code Tom Tromey
2017-08-30 18:24 ` Keith Seitz
2017-08-29 19:25 ` [RFA 05/10] Use unique_xmalloc_ptr in cd_command Tom Tromey
2017-08-29 19:25 ` Tom Tromey [this message]
2017-08-29 19:25 ` [RFA 06/10] Use std::string in do_set_command Tom Tromey
2017-08-29 19:25 ` [RFA 01/10] Return std::string from memory_error_message Tom Tromey
2017-08-29 19:25 ` [RFA 07/10] Use std::string and unique_xmalloc_ptr in demangle_command Tom Tromey
2017-08-29 19:25 ` [RFA 08/10] Return std::string from perror_string Tom Tromey
2017-08-29 19:36 ` [RFA 02/10] Use std::string thread.c Tom Tromey
2017-08-29 19:37 ` [RFA 10/10] Use std::string in reopen_exec_file Tom Tromey
2017-08-29 19:37 ` [RFA 03/10] Use unique_xmalloc_ptr in env_execute_cli_command Tom Tromey
2017-09-01 8:50 ` [RFA 00/10] some string cleanup removal Simon Marchi
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=20170829192524.29971-5-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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).