summaryrefslogtreecommitdiff
path: root/gdb/compile
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/compile
parentfdffd6f4118652bdfdff383943f13664af4b9a45 (diff)
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/compile')
-rw-r--r--gdb/compile/compile-object-load.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/gdb/compile/compile-object-load.c b/gdb/compile/compile-object-load.c
index 473e664aba..41d5fc347f 100644
--- a/gdb/compile/compile-object-load.c
+++ b/gdb/compile/compile-object-load.c
@@ -624,44 +624,45 @@ compile_object_load (const compile_file_names &file_names,
unsigned dptr_type_len = TYPE_LENGTH (dptr_type);
struct compile_module *retval;
struct type *regs_type, *out_value_type = NULL;
- char *filename, **matching;
+ char **matching;
struct objfile *objfile;
int expect_parameters;
struct type *expect_return_type;
struct munmap_list *munmap_list_head = NULL;
- filename = tilde_expand (file_names.object_file ());
- cleanups = make_cleanup (xfree, filename);
+ gdb::unique_xmalloc_ptr<char> filename
+ (tilde_expand (file_names.object_file ()));
- gdb_bfd_ref_ptr abfd (gdb_bfd_open (filename, gnutarget, -1));
+ gdb_bfd_ref_ptr abfd (gdb_bfd_open (filename.get (), gnutarget, -1));
if (abfd == NULL)
error (_("\"%s\": could not open as compiled module: %s"),
- filename, bfd_errmsg (bfd_get_error ()));
+ filename.get (), bfd_errmsg (bfd_get_error ()));
if (!bfd_check_format_matches (abfd.get (), bfd_object, &matching))
error (_("\"%s\": not in loadable format: %s"),
- filename, gdb_bfd_errmsg (bfd_get_error (), matching));
+ filename.get (), gdb_bfd_errmsg (bfd_get_error (), matching));
if ((bfd_get_file_flags (abfd.get ()) & (EXEC_P | DYNAMIC)) != 0)
- error (_("\"%s\": not in object format."), filename);
+ error (_("\"%s\": not in object format."), filename.get ());
setup_sections_data.last_size = 0;
setup_sections_data.last_section_first = abfd->sections;
setup_sections_data.last_prot = -1;
setup_sections_data.last_max_alignment = 1;
setup_sections_data.munmap_list_headp = &munmap_list_head;
- make_cleanup (munmap_listp_free_cleanup, &munmap_list_head);
+ cleanups = make_cleanup (munmap_listp_free_cleanup, &munmap_list_head);
bfd_map_over_sections (abfd.get (), setup_sections, &setup_sections_data);
setup_sections (abfd.get (), NULL, &setup_sections_data);
storage_needed = bfd_get_symtab_upper_bound (abfd.get ());
if (storage_needed < 0)
error (_("Cannot read symbols of compiled module \"%s\": %s"),
- filename, bfd_errmsg (bfd_get_error ()));
+ filename.get (), bfd_errmsg (bfd_get_error ()));
/* SYMFILE_VERBOSE is not passed even if FROM_TTY, user is not interested in
"Reading symbols from ..." message for automatically generated file. */
- objfile = symbol_file_add_from_bfd (abfd.get (), filename, 0, NULL, 0, NULL);
+ objfile = symbol_file_add_from_bfd (abfd.get (), filename.get (),
+ 0, NULL, 0, NULL);
cleanups_free_objfile = make_cleanup_free_objfile (objfile);
func_sym = lookup_global_symbol_from_objfile (objfile,
@@ -713,7 +714,7 @@ compile_object_load (const compile_file_names &file_names,
number_of_symbols = bfd_canonicalize_symtab (abfd.get (), symbol_table);
if (number_of_symbols < 0)
error (_("Cannot parse symbols of compiled module \"%s\": %s"),
- filename, bfd_errmsg (bfd_get_error ()));
+ filename.get (), bfd_errmsg (bfd_get_error ()));
missing_symbols = 0;
for (symp = symbol_table; symp < symbol_table + number_of_symbols; symp++)
@@ -762,7 +763,7 @@ compile_object_load (const compile_file_names &file_names,
default:
warning (_("Could not find symbol \"%s\" "
"for compiled module \"%s\"."),
- sym->name, filename);
+ sym->name, filename.get ());
missing_symbols++;
}
}