From 773a1edcd1086fc76a91055bec67e2d14d76940d Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sun, 30 Apr 2017 23:02:30 -0600 Subject: 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 * 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. --- gdb/symmisc.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'gdb/symmisc.c') diff --git a/gdb/symmisc.c b/gdb/symmisc.c index 32a5331..cfdd5d9 100644 --- a/gdb/symmisc.c +++ b/gdb/symmisc.c @@ -407,7 +407,6 @@ dump_symtab (struct symtab *symtab, struct ui_file *outfile) static void maintenance_print_symbols (char *args, int from_tty) { - char **argv; struct ui_file *outfile = gdb_stdout; struct cleanup *cleanups; char *address_arg = NULL, *source_arg = NULL, *objfile_arg = NULL; @@ -415,8 +414,8 @@ maintenance_print_symbols (char *args, int from_tty) dont_repeat (); - argv = gdb_buildargv (args); - cleanups = make_cleanup_freeargv (argv); + gdb_argv argv (args); + cleanups = make_cleanup (null_cleanup, NULL); for (i = 0; argv != NULL && argv[i] != NULL; ++i) { @@ -709,7 +708,6 @@ print_symbol (void *args) static void maintenance_print_msymbols (char *args, int from_tty) { - char **argv; struct ui_file *outfile = gdb_stdout; struct cleanup *cleanups; char *objfile_arg = NULL; @@ -718,8 +716,8 @@ maintenance_print_msymbols (char *args, int from_tty) dont_repeat (); - argv = gdb_buildargv (args); - cleanups = make_cleanup_freeargv (argv); + gdb_argv argv (args); + cleanups = make_cleanup (null_cleanup, NULL); for (i = 0; argv != NULL && argv[i] != NULL; ++i) { @@ -944,14 +942,11 @@ maintenance_expand_symtabs (char *args, int from_tty) { struct program_space *pspace; struct objfile *objfile; - struct cleanup *cleanups; - char **argv; char *regexp = NULL; /* We use buildargv here so that we handle spaces in the regexp in a way that allows adding more arguments later. */ - argv = gdb_buildargv (args); - cleanups = make_cleanup_freeargv (argv); + gdb_argv argv (args); if (argv != NULL) { @@ -988,8 +983,6 @@ maintenance_expand_symtabs (char *args, int from_tty) ALL_DOMAIN); } } - - do_cleanups (cleanups); } -- cgit v1.1