aboutsummaryrefslogtreecommitdiff
path: root/gdb/symmisc.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/symmisc.c
parentfdffd6f4118652bdfdff383943f13664af4b9a45 (diff)
downloadbinutils-ee0c32930c355b73172b2bef987e2a48ea909b12.zip
binutils-ee0c32930c355b73172b2bef987e2a48ea909b12.tar.gz
binutils-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/symmisc.c')
-rw-r--r--gdb/symmisc.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/gdb/symmisc.c b/gdb/symmisc.c
index cfdd5d9..c85f0b7 100644
--- a/gdb/symmisc.c
+++ b/gdb/symmisc.c
@@ -408,14 +408,12 @@ static void
maintenance_print_symbols (char *args, int from_tty)
{
struct ui_file *outfile = gdb_stdout;
- struct cleanup *cleanups;
char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL;
int i, outfile_idx;
dont_repeat ();
gdb_argv argv (args);
- cleanups = make_cleanup (null_cleanup, NULL);
for (i = 0; argv != NULL && argv[i] != NULL; ++i)
{
@@ -460,14 +458,12 @@ maintenance_print_symbols (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;
}
@@ -519,8 +515,6 @@ maintenance_print_symbols (char *args, int from_tty)
if (source_arg != NULL && !found)
error (_("No symtab for source file: %s"), source_arg);
}
-
- do_cleanups (cleanups);
}
/* Print symbol ARGS->SYMBOL on ARGS->OUTFILE. ARGS->DEPTH says how
@@ -709,7 +703,6 @@ static void
maintenance_print_msymbols (char *args, int from_tty)
{
struct ui_file *outfile = gdb_stdout;
- struct cleanup *cleanups;
char *objfile_arg = NULL;
struct objfile *objfile;
int i, outfile_idx;
@@ -717,7 +710,6 @@ maintenance_print_msymbols (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)
{
@@ -747,14 +739,12 @@ maintenance_print_msymbols (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;
}
@@ -765,8 +755,6 @@ maintenance_print_msymbols (char *args, int from_tty)
|| compare_filenames_for_search (objfile_name (objfile), objfile_arg))
dump_msymbols (objfile, outfile);
}
-
- do_cleanups (cleanups);
}
static void