aboutsummaryrefslogtreecommitdiff
path: root/gdb/symfile.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-04-30 23:02:30 -0600
committerTom Tromey <tom@tromey.com>2017-08-03 07:59:08 -0600
commit773a1edcd1086fc76a91055bec67e2d14d76940d (patch)
tree4d82515964c139132435bfa57205f5f58c4ece48 /gdb/symfile.c
parent0d50bde32b92821c9f1f660d273e6c996d26dc9f (diff)
downloadgdb-773a1edcd1086fc76a91055bec67e2d14d76940d.zip
gdb-773a1edcd1086fc76a91055bec67e2d14d76940d.tar.gz
gdb-773a1edcd1086fc76a91055bec67e2d14d76940d.tar.bz2
Introduce gdb_argv, a class wrapper for buildargv
This introduces gdb_argv, a class wrapping an "argv" pointer; that is, a pointer to a NULL-terminated array of char*, where both the array and each non-NULL element in the array are xmalloc'd. This patch then changes most users of gdb_buildargv to use gdb_argv instead. ChangeLog 2017-08-03 Tom Tromey <tom@tromey.com> * utils.h (struct gdb_argv_deleter): New. (gdb_argv): New class. * utils.c (gdb_argv::reset): New method. * tracepoint.c (delete_trace_variable_command): Use gdb_argv. * tracefile.c (tsave_command): Use gdb_argv. * top.c (new_ui_command): Use gdb_argv. * symmisc.c (maintenance_print_symbols) (maintenance_print_msymbols, maintenance_expand_symtabs): Use gdb_argv. * symfile.c (symbol_file_command, generic_load) (remove_symbol_file_command): Use gdb_argv. * stack.c (backtrace_command): Use gdb_argv. * source.c (add_path, show_substitute_path_command) (unset_substitute_path_command, set_substitute_path_command): Use gdb_argv. * skip.c (skip_command): Use gdb_argv. Use gdb_buildargv. * ser-mingw.c (pipe_windows_open): Use gdb_argv. * remote.c (extended_remote_run, remote_put_command) (remote_get_command, remote_delete_command): Use gdb_argv. * remote-sim.c (gdbsim_load, gdbsim_create_inferior) (gdbsim_open): Use gdb_argv. * python/py-cmd.c (gdbpy_string_to_argv): Use gdb_argv. * psymtab.c (maintenance_print_psymbols): Use gdb_argv. * procfs.c (procfs_info_proc): Use gdb_argv. * interps.c (interpreter_exec_cmd): Use gdb_argv. * infrun.c (handle_command): Use gdb_argv. * inferior.c (add_inferior_command, clone_inferior_command): Use gdb_argv. * guile/scm-string.c (gdbscm_string_to_argv): Use gdb_argv. * exec.c (exec_file_command): Use gdb_argv. * cli/cli-cmds.c (alias_command): Use gdb_argv. * compile/compile.c (build_argc_argv): Use gdb_argv.
Diffstat (limited to 'gdb/symfile.c')
-rw-r--r--gdb/symfile.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/gdb/symfile.c b/gdb/symfile.c
index 9cbd6e5..67a3976 100644
--- a/gdb/symfile.c
+++ b/gdb/symfile.c
@@ -1639,7 +1639,6 @@ symbol_file_command (char *args, int from_tty)
}
else
{
- char **argv = gdb_buildargv (args);
objfile_flags flags = OBJF_USERLOADED;
symfile_add_flags add_flags = 0;
struct cleanup *cleanups;
@@ -1648,26 +1647,22 @@ symbol_file_command (char *args, int from_tty)
if (from_tty)
add_flags |= SYMFILE_VERBOSE;
- cleanups = make_cleanup_freeargv (argv);
- while (*argv != NULL)
+ gdb_argv built_argv (args);
+ for (char *arg : built_argv)
{
- if (strcmp (*argv, "-readnow") == 0)
+ if (strcmp (arg, "-readnow") == 0)
flags |= OBJF_READNOW;
- else if (**argv == '-')
- error (_("unknown option `%s'"), *argv);
+ else if (*arg == '-')
+ error (_("unknown option `%s'"), arg);
else
{
- symbol_file_add_main_1 (*argv, add_flags, flags);
- name = *argv;
+ symbol_file_add_main_1 (arg, add_flags, flags);
+ name = arg;
}
-
- argv++;
}
if (name == NULL)
error (_("no symbol file name was specified"));
-
- do_cleanups (cleanups);
}
}
@@ -2061,25 +2056,23 @@ void
generic_load (const char *args, int from_tty)
{
char *filename;
- struct cleanup *old_cleanups = make_cleanup (null_cleanup, 0);
+ struct cleanup *old_cleanups;
struct load_section_data cbdata;
struct load_progress_data total_progress;
struct ui_out *uiout = current_uiout;
CORE_ADDR entry;
- char **argv;
memset (&cbdata, 0, sizeof (cbdata));
memset (&total_progress, 0, sizeof (total_progress));
cbdata.progress_data = &total_progress;
- make_cleanup (clear_memory_write_data, &cbdata.requests);
+ old_cleanups = make_cleanup (clear_memory_write_data, &cbdata.requests);
if (args == NULL)
error_no_arg (_("file to load"));
- argv = gdb_buildargv (args);
- make_cleanup_freeargv (argv);
+ gdb_argv argv (args);
filename = tilde_expand (argv[0]);
make_cleanup (xfree, filename);
@@ -2227,7 +2220,6 @@ add_symbol_file_command (char *args, int from_tty)
int i;
int expecting_sec_name = 0;
int expecting_sec_addr = 0;
- char **argv;
struct objfile *objf;
objfile_flags flags = OBJF_USERLOADED | OBJF_SHARED;
symfile_add_flags add_flags = 0;
@@ -2254,8 +2246,7 @@ add_symbol_file_command (char *args, int from_tty)
if (args == NULL)
error (_("add-symbol-file takes a file name and an address"));
- argv = gdb_buildargv (args);
- make_cleanup_freeargv (argv);
+ gdb_argv argv (args);
for (arg = argv[0], argcnt = 0; arg != NULL; arg = argv[++argcnt])
{
@@ -2375,7 +2366,6 @@ add_symbol_file_command (char *args, int from_tty)
static void
remove_symbol_file_command (char *args, int from_tty)
{
- char **argv;
struct objfile *objf = NULL;
struct cleanup *my_cleanups;
struct program_space *pspace = current_program_space;
@@ -2387,7 +2377,7 @@ remove_symbol_file_command (char *args, int from_tty)
my_cleanups = make_cleanup (null_cleanup, NULL);
- argv = gdb_buildargv (args);
+ gdb_argv argv (args);
if (strcmp (argv[0], "-a") == 0)
{