aboutsummaryrefslogtreecommitdiff
path: root/gdb
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2018-08-29 23:05:54 -0600
committerTom Tromey <tom@tromey.com>2018-09-13 16:22:34 -0600
commit97e67fc62045723db7af6d323ce9c428666ab6f5 (patch)
treec34d83790ee9520856f90f239045b625c28adb08 /gdb
parent803c08d083556154cd4d27368e58b359e9de8b93 (diff)
downloadgdb-97e67fc62045723db7af6d323ce9c428666ab6f5.zip
gdb-97e67fc62045723db7af6d323ce9c428666ab6f5.tar.gz
gdb-97e67fc62045723db7af6d323ce9c428666ab6f5.tar.bz2
Remove cleanup from try_open_exec_file
This removes a cleanup from try_open_exec_file, using std::string to manage the storage instead. gdb/ChangeLog 2018-09-13 Tom Tromey <tom@tromey.com> * exec.c (try_open_exec_file): Use std::string.
Diffstat (limited to 'gdb')
-rw-r--r--gdb/ChangeLog4
-rw-r--r--gdb/exec.c11
2 files changed, 9 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index d087871..f110b64 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,9 @@
2018-09-13 Tom Tromey <tom@tromey.com>
+ * exec.c (try_open_exec_file): Use std::string.
+
+2018-09-13 Tom Tromey <tom@tromey.com>
+
* utils.h (gdb_bfd_errmsg): Return std::string.
* exec.c (exec_file_attach): Update.
* compile/compile-object-load.c (compile_object_load): Update.
diff --git a/gdb/exec.c b/gdb/exec.c
index 6e44b0e..615fb2b 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. */