aboutsummaryrefslogtreecommitdiff
path: root/gdb/psymtab.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/psymtab.c
parentfdffd6f4118652bdfdff383943f13664af4b9a45 (diff)
downloadgdb-ee0c32930c355b73172b2bef987e2a48ea909b12.zip
gdb-ee0c32930c355b73172b2bef987e2a48ea909b12.tar.gz
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/psymtab.c')
-rw-r--r--gdb/psymtab.c14
1 files changed, 4 insertions, 10 deletions
diff --git a/gdb/psymtab.c b/gdb/psymtab.c
index a3762b5..8283545 100644
--- a/gdb/psymtab.c
+++ b/gdb/psymtab.c
@@ -1906,7 +1906,6 @@ static void
maintenance_print_psymbols (char *args, int from_tty)
{
struct ui_file *outfile = gdb_stdout;
- struct cleanup *cleanups;
char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL;
struct objfile *objfile;
struct partial_symtab *ps;
@@ -1917,7 +1916,6 @@ maintenance_print_psymbols (char *args, int from_tty)
dont_repeat ();
gdb_argv argv (args);
- cleanups = make_cleanup (null_cleanup, NULL);
for (i = 0; argv != NULL && argv[i] != NULL; ++i)
{
@@ -1962,14 +1960,12 @@ maintenance_print_psymbols (char *args, int from_tty)
if (argv != NULL && argv[outfile_idx] != NULL)
{
- char *outfile_name;
-
if (argv[outfile_idx + 1] != NULL)
error (_("Junk at end of command"));
- outfile_name = tilde_expand (argv[outfile_idx]);
- make_cleanup (xfree, outfile_name);
- if (!arg_outfile.open (outfile_name, FOPEN_WT))
- perror_with_name (outfile_name);
+ gdb::unique_xmalloc_ptr<char> outfile_name
+ (tilde_expand (argv[outfile_idx]));
+ if (!arg_outfile.open (outfile_name.get (), FOPEN_WT))
+ perror_with_name (outfile_name.get ());
outfile = &arg_outfile;
}
@@ -2060,8 +2056,6 @@ maintenance_print_psymbols (char *args, int from_tty)
if (source_arg != NULL)
error (_("No partial symtab for source file: %s"), source_arg);
}
-
- do_cleanups (cleanups);
}
/* List all the partial symbol tables whose names match REGEXP (optional). */