mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-20 09:58:19 +08:00
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.
This commit is contained in:
10
gdb/infrun.c
10
gdb/infrun.c
@ -1081,8 +1081,6 @@ follow_exec (ptid_t ptid, char *exec_file_target)
|
||||
struct inferior *inf = current_inferior ();
|
||||
int pid = ptid_get_pid (ptid);
|
||||
ptid_t process_ptid;
|
||||
char *exec_file_host;
|
||||
struct cleanup *old_chain;
|
||||
|
||||
/* This is an exec event that we actually wish to pay attention to.
|
||||
Refresh our symbol table to the newly exec'd program, remove any
|
||||
@ -1161,8 +1159,8 @@ follow_exec (ptid_t ptid, char *exec_file_target)
|
||||
|
||||
breakpoint_init_inferior (inf_execd);
|
||||
|
||||
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 we were unable to map the executable target pathname onto a host
|
||||
pathname, tell the user that. Otherwise GDB's subsequent behavior
|
||||
@ -1216,9 +1214,7 @@ follow_exec (ptid_t ptid, char *exec_file_target)
|
||||
Executable) main symbol file will only be computed by
|
||||
solib_create_inferior_hook below. breakpoint_re_set would fail
|
||||
to insert the breakpoints with the zero displacement. */
|
||||
try_open_exec_file (exec_file_host, inf, SYMFILE_DEFER_BP_RESET);
|
||||
|
||||
do_cleanups (old_chain);
|
||||
try_open_exec_file (exec_file_host.get (), inf, SYMFILE_DEFER_BP_RESET);
|
||||
|
||||
/* If the target can specify a description, read it. Must do this
|
||||
after flipping to the new executable (because the target supplied
|
||||
|
Reference in New Issue
Block a user