From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 4/4] Remove cleanup from try_open_exec_file
Date: Mon, 03 Sep 2018 19:03:00 -0000 [thread overview]
Message-ID: <20180903190250.11599-5-tom@tromey.com> (raw)
In-Reply-To: <20180903190250.11599-1-tom@tromey.com>
This removes a cleanup from try_open_exec_file, using std::string to
manage the storage instead.
gdb/ChangeLog
2018-09-03 Tom Tromey <tom@tromey.com>
* exec.c (try_open_exec_file): Use std::string.
---
gdb/ChangeLog | 4 ++++
gdb/exec.c | 11 +++++------
2 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/gdb/exec.c b/gdb/exec.c
index 6e44b0e821b..615fb2b5dbc 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -149,11 +149,8 @@ void
try_open_exec_file (const char *exec_file_host, struct inferior *inf,
symfile_add_flags add_flags)
{
- struct cleanup *old_chain;
struct gdb_exception prev_err = exception_none;
- old_chain = make_cleanup (free_current_contents, &prev_err.message);
-
/* exec_file_attach and symbol_file_add_main may throw an error if the file
cannot be opened either locally or remotely.
@@ -165,6 +162,7 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf,
Even without a symbol file, the remote-based debugging session should
continue normally instead of ending abruptly. Hence we catch thrown
errors/exceptions in the following code. */
+ std::string saved_message;
TRY
{
/* We must do this step even if exec_file_host is NULL, so that
@@ -180,7 +178,10 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf,
/* Save message so it doesn't get trashed by the catch below. */
if (err.message != NULL)
- prev_err.message = xstrdup (err.message);
+ {
+ saved_message = err.message;
+ prev_err.message = saved_message.c_str ();
+ }
}
END_CATCH
@@ -197,8 +198,6 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf,
}
END_CATCH
}
-
- do_cleanups (old_chain);
}
/* See gdbcore.h. */
--
2.13.6
next prev parent reply other threads:[~2018-09-03 19:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-03 19:03 [PATCH 0/4] Some cleanup removal Tom Tromey
2018-09-03 19:02 ` [PATCH 1/4] Remove cleanup from add_path Tom Tromey
2018-09-03 19:03 ` [PATCH 2/4] Remove cleanup from procfs.c Tom Tromey
2018-09-04 10:50 ` Rainer Orth
2018-09-04 16:56 ` Tom Tromey
2018-09-03 19:03 ` [PATCH 3/4] Return std::string from gdb_bfd_errmsg Tom Tromey
2018-09-03 19:03 ` Tom Tromey [this message]
2018-09-04 9:37 ` [PATCH 0/4] Some cleanup removal Rainer Orth
2018-09-04 16:58 ` Tom Tromey
2018-09-04 18:30 ` Rainer Orth
2018-09-13 22:41 ` 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=20180903190250.11599-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).