diff options
author | Tom Tromey <tom@tromey.com> | 2017-04-30 23:02:30 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2017-08-03 07:59:08 -0600 |
commit | 773a1edcd1086fc76a91055bec67e2d14d76940d (patch) | |
tree | 4d82515964c139132435bfa57205f5f58c4ece48 /gdb/source.c | |
parent | 0d50bde32b92821c9f1f660d273e6c996d26dc9f (diff) | |
download | gdb-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/source.c')
-rw-r--r-- | gdb/source.c | 30 |
1 files changed, 6 insertions, 24 deletions
diff --git a/gdb/source.c b/gdb/source.c index 4cc862c..5473103 100644 --- a/gdb/source.c +++ b/gdb/source.c @@ -484,16 +484,12 @@ add_path (char *dirname, char **which_path, int parse_separators) if (parse_separators) { - char **argv, **argvp; - /* This will properly parse the space and tab separators and any quotes that may exist. */ - argv = gdb_buildargv (dirname); - - for (argvp = argv; *argvp; argvp++) - dirnames_to_char_ptr_vec_append (&dir_vec, *argvp); + gdb_argv argv (dirname); - freeargv (argv); + for (char *arg : argv) + dirnames_to_char_ptr_vec_append (&dir_vec, arg); } else VEC_safe_push (char_ptr, dir_vec, xstrdup (dirname)); @@ -1883,12 +1879,9 @@ static void show_substitute_path_command (char *args, int from_tty) { struct substitute_path_rule *rule = substitute_path_rules; - char **argv; char *from = NULL; - struct cleanup *cleanup; - argv = gdb_buildargv (args); - cleanup = make_cleanup_freeargv (argv); + gdb_argv argv (args); /* We expect zero or one argument. */ @@ -1912,8 +1905,6 @@ show_substitute_path_command (char *args, int from_tty) printf_filtered (" `%s' -> `%s'.\n", rule->from, rule->to); rule = rule->next; } - - do_cleanups (cleanup); } /* Implement the "unset substitute-path" command. */ @@ -1922,14 +1913,12 @@ static void unset_substitute_path_command (char *args, int from_tty) { struct substitute_path_rule *rule = substitute_path_rules; - char **argv = gdb_buildargv (args); + gdb_argv argv (args); char *from = NULL; int rule_found = 0; - struct cleanup *cleanup; /* This function takes either 0 or 1 argument. */ - cleanup = make_cleanup_freeargv (argv); if (argv != NULL && argv[0] != NULL && argv[1] != NULL) error (_("Incorrect usage, too many arguments in command")); @@ -1967,8 +1956,6 @@ unset_substitute_path_command (char *args, int from_tty) error (_("No substitution rule defined for `%s'"), from); forget_cached_source_info (); - - do_cleanups (cleanup); } /* Add a new source path substitution rule. */ @@ -1976,12 +1963,9 @@ unset_substitute_path_command (char *args, int from_tty) static void set_substitute_path_command (char *args, int from_tty) { - char **argv; struct substitute_path_rule *rule; - struct cleanup *cleanup; - argv = gdb_buildargv (args); - cleanup = make_cleanup_freeargv (argv); + gdb_argv argv (args); if (argv == NULL || argv[0] == NULL || argv [1] == NULL) error (_("Incorrect usage, too few arguments in command")); @@ -2008,8 +1992,6 @@ set_substitute_path_command (char *args, int from_tty) add_substitute_path_rule (argv[0], argv[1]); forget_cached_source_info (); - - do_cleanups (cleanup); } |