aboutsummaryrefslogtreecommitdiff
path: root/gdb/solib.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-07-31 15:49:21 -0600
committerTom Tromey <tom@tromey.com>2017-08-05 15:52:49 -0600
commitee0c32930c355b73172b2bef987e2a48ea909b12 (patch)
tree0264ee39289e77f768f898ca1dd0109bf92d0b58 /gdb/solib.c
parentfdffd6f4118652bdfdff383943f13664af4b9a45 (diff)
downloadfsf-binutils-gdb-ee0c32930c355b73172b2bef987e2a48ea909b12.zip
fsf-binutils-gdb-ee0c32930c355b73172b2bef987e2a48ea909b12.tar.gz
fsf-binutils-gdb-ee0c32930c355b73172b2bef987e2a48ea909b12.tar.bz2
Use gdb::unique_xmalloc_ptr when calling tilde_expand
This patch changes most sites calling tilde_expand to use gdb::unique_xmalloc_ptr, rather than a cleanup. It also changes scan_expression_with_cleanup to return a unique pointer, because the patch was already touching code in that area. Regression tested on the buildbot. ChangeLog 2017-08-05 Tom Tromey <tom@tromey.com> * compile/compile-object-load.c (compile_object_load): Use gdb::unique_xmalloc_ptr. * cli/cli-dump.c (scan_filename): Rename from scan_filename_with_cleanup. Change return type. (scan_expression): Rename from scan_expression_with_cleanup. Change return type. (dump_memory_to_file, dump_value_to_file, restore_command): Use gdb::unique_xmalloc_ptr. Update. * cli/cli-cmds.c (find_and_open_script): Use gdb::unique_xmalloc_ptr. * tracefile-tfile.c (tfile_open): Use gdb::unique_xmalloc_ptr. * symmisc.c (maintenance_print_symbols) (maintenance_print_msymbols): Use gdb::unique_xmalloc_ptr. * symfile.c (symfile_bfd_open, generic_load) (add_symbol_file_command, remove_symbol_file_command): Use gdb::unique_xmalloc_ptr. * source.c (openp): Use gdb::unique_xmalloc_ptr. * psymtab.c (maintenance_print_psymbols): Use gdb::unique_xmalloc_ptr. * corelow.c (core_open): Use gdb::unique_xmalloc_ptr. * breakpoint.c (save_breakpoints): Use gdb::unique_xmalloc_ptr. * solib.c (solib_map_sections): Use gdb::unique_xmalloc_ptr. (reload_shared_libraries_1): Likewise.
Diffstat (limited to 'gdb/solib.c')
-rw-r--r--gdb/solib.c24
1 files changed, 7 insertions, 17 deletions
diff --git a/gdb/solib.c b/gdb/solib.c
index 5b538eb..c8fe4d2 100644
--- a/gdb/solib.c
+++ b/gdb/solib.c
@@ -546,14 +546,10 @@ static int
solib_map_sections (struct so_list *so)
{
const struct target_so_ops *ops = solib_ops (target_gdbarch ());
- char *filename;
struct target_section *p;
- struct cleanup *old_chain;
- filename = tilde_expand (so->so_name);
- old_chain = make_cleanup (xfree, filename);
- gdb_bfd_ref_ptr abfd (ops->bfd_open (filename));
- do_cleanups (old_chain);
+ gdb::unique_xmalloc_ptr<char> filename (tilde_expand (so->so_name));
+ gdb_bfd_ref_ptr abfd (ops->bfd_open (filename.get ()));
if (abfd == NULL)
return 0;
@@ -1301,28 +1297,24 @@ static void
reload_shared_libraries_1 (int from_tty)
{
struct so_list *so;
- struct cleanup *old_chain = make_cleanup (null_cleanup, NULL);
if (print_symbol_loading_p (from_tty, 0, 0))
printf_unfiltered (_("Loading symbols for shared libraries.\n"));
for (so = so_list_head; so != NULL; so = so->next)
{
- char *filename, *found_pathname = NULL;
+ char *found_pathname = NULL;
int was_loaded = so->symbols_loaded;
symfile_add_flags add_flags = SYMFILE_DEFER_BP_RESET;
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
- filename = tilde_expand (so->so_original_name);
- make_cleanup (xfree, filename);
- gdb_bfd_ref_ptr abfd (solib_bfd_open (filename));
+ gdb::unique_xmalloc_ptr<char> filename
+ (tilde_expand (so->so_original_name));
+ gdb_bfd_ref_ptr abfd (solib_bfd_open (filename.get ()));
if (abfd != NULL)
- {
- found_pathname = xstrdup (bfd_get_filename (abfd.get ()));
- make_cleanup (xfree, found_pathname);
- }
+ found_pathname = bfd_get_filename (abfd.get ());
/* If this shared library is no longer associated with its previous
symbol file, close that. */
@@ -1364,8 +1356,6 @@ reload_shared_libraries_1 (int from_tty)
solib_read_symbols (so, add_flags);
}
}
-
- do_cleanups (old_chain);
}
static void