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.
This commit is contained in:
Tom Tromey
2017-04-30 23:02:30 -06:00
parent 0d50bde32b
commit 773a1edcd1
24 changed files with 289 additions and 249 deletions

View File

@@ -5100,7 +5100,6 @@ procfs_info_proc (struct target_ops *ops, const char *args,
struct cleanup *old_chain;
procinfo *process = NULL;
procinfo *thread = NULL;
char **argv = NULL;
char *tmp = NULL;
int pid = 0;
int tid = 0;
@@ -5121,24 +5120,19 @@ procfs_info_proc (struct target_ops *ops, const char *args,
}
old_chain = make_cleanup (null_cleanup, 0);
if (args)
gdb_argv built_argv (args);
for (char *arg : argv)
{
argv = gdb_buildargv (args);
make_cleanup_freeargv (argv);
}
while (argv != NULL && *argv != NULL)
{
if (isdigit (argv[0][0]))
if (isdigit (arg[0]))
{
pid = strtoul (argv[0], &tmp, 10);
pid = strtoul (arg, &tmp, 10);
if (*tmp == '/')
tid = strtoul (++tmp, NULL, 10);
}
else if (argv[0][0] == '/')
else if (arg[0] == '/')
{
tid = strtoul (argv[0] + 1, NULL, 10);
tid = strtoul (arg + 1, NULL, 10);
}
argv++;
}
if (pid == 0)
pid = ptid_get_pid (inferior_ptid);