aboutsummaryrefslogtreecommitdiff
path: root/gdb/exec.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-11-10 13:07:46 -0700
committerTom Tromey <tom@tromey.com>2018-02-14 08:09:52 -0700
commit797bc1cb25b9dbdbc663cf711aecb0acc2450276 (patch)
tree8a38a8625056ea60dcaea4458a6dead3b9ba86c1 /gdb/exec.c
parent12ef3f5a7c5a6b89964842fd3da047b8d07dec91 (diff)
downloadgdb-797bc1cb25b9dbdbc663cf711aecb0acc2450276.zip
gdb-797bc1cb25b9dbdbc663cf711aecb0acc2450276.tar.gz
gdb-797bc1cb25b9dbdbc663cf711aecb0acc2450276.tar.bz2
Return unique_xmalloc_ptr from some solib.c functions
This changes a couple of solib.c functions -- exec_file_find and solib_find -- to return a unique_xmalloc_ptr, and then fixes up the users. This allows the removal of some cleanups. This also changes solib_bfd_open to not take ownership of its argument. I think this change is somewhat cleaner. gdb/ChangeLog 2018-02-14 Tom Tromey <tom@tromey.com> * solist.h (exec_file_find, solib_find): Return unique_xmalloc_ptr. (solib_bfd_fopen): Take a const char *. * solib.c (solib_find_1): Return unique_xmalloc_ptr. (exec_file_find, solib_find): Likewise. (solib_bfd_fopen): Do not take ownership of "pathname". (solib_bfd_open): Use unique_xmalloc_ptr. * solib-darwin.c (darwin_bfd_open): Use unique_xmalloc_ptr. * solib-aix.c (solib_aix_bfd_open): Use unique_xmalloc_ptr. * infrun.c (follow_exec): Use unique_xmalloc_ptr. * exec.c (exec_file_locate_attach): Use unique_xmalloc_ptr.
Diffstat (limited to 'gdb/exec.c')
-rw-r--r--gdb/exec.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/gdb/exec.c b/gdb/exec.c
index c8c32ec..15f85a2 100644
--- a/gdb/exec.c
+++ b/gdb/exec.c
@@ -190,8 +190,7 @@ try_open_exec_file (const char *exec_file_host, struct inferior *inf,
void
exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
{
- char *exec_file_target, *exec_file_host;
- struct cleanup *old_chain;
+ char *exec_file_target;
symfile_add_flags add_flags = 0;
/* Do nothing if we already have an executable filename. */
@@ -209,8 +208,8 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
return;
}
- exec_file_host = exec_file_find (exec_file_target, NULL);
- old_chain = make_cleanup (xfree, exec_file_host);
+ gdb::unique_xmalloc_ptr<char> exec_file_host
+ = exec_file_find (exec_file_target, NULL);
if (defer_bp_reset)
add_flags |= SYMFILE_DEFER_BP_RESET;
@@ -219,8 +218,7 @@ exec_file_locate_attach (int pid, int defer_bp_reset, int from_tty)
add_flags |= SYMFILE_VERBOSE;
/* Attempt to open the exec file. */
- try_open_exec_file (exec_file_host, current_inferior (), add_flags);
- do_cleanups (old_chain);
+ try_open_exec_file (exec_file_host.get (), current_inferior (), add_flags);
}
/* Set FILENAME as the new exec file.