This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFA 22/23] Make gdb_buildargv return a unique pointer


On 05/03/2017 11:46 PM, Tom Tromey wrote:
> This introduces gdb_argv_up, a unique pointer 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 gdb_buildargv to return a gdb_argv_up and
> fixes all the users.  It also changes skip.c to use gdb_buildargv
> (previously it was the only direct caller of buildargv, other than
> gdb_buildargv itself).
> 
> One future change that might make sense would be to add begin and end
> functions, so that an argv could be iterated over.  I didn't look into
> this too much; and perhaps replacing some uses with
> std::vector<std::string> would be even better.

I suspect that making gdb_argv_up a class (class gdb_argv) that wraps
the array instead of making it a unique pointer may make users a
little bit clearer.  I.e., gdb_buildargv would be converted to a
ctor, and we'd add e.g., a "count()" and "release()" methods.

Meanwhile ...

> 
> 2017-05-02  Tom Tromey  <tom@tromey.com>
> 
> 	* utils.h (struct gdb_argv_deleter): New.
> 	(gdb_argv_up): New typedef.
> 	(gdb_buildargv): Change return type.
> 	* utils.c (gdb_buildargv): Return gdb_argv_up.
> 	* tracepoint.c (delete_trace_variable_command): Update.
> 	* tracefile.c (tsave_command): Update.
> 	* top.c (new_ui_command): Update.
> 	* symmisc.c (maintenance_print_symbols)
> 	(maintenance_print_msymbols, maintenance_expand_symtabs): Update.
> 	* symfile.c (symbol_file_command, generic_load)
> 	(remove_symbol_file_command): Update.
> 	* stack.c (backtrace_command): Update.
> 	* source.c (add_path, show_substitute_path_command)
> 	(unset_substitute_path_command, set_substitute_path_command):
> 	Update.
> 	* skip.c (skip_command): Update.  Use gdb_buildargv.
> 	* ser-mingw.c (pipe_windows_open): Update.
> 	* remote.c (extended_remote_run, remote_put_command)
> 	(remote_get_command, remote_delete_command): Update.
> 	* remote-sim.c (gdbsim_load, gdbsim_create_inferior)
> 	(gdbsim_open): Update.
> 	* python/py-cmd.c (gdbpy_string_to_argv): Update.
> 	* psymtab.c (maintenance_print_psymbols): Update.
> 	* procfs.c (procfs_info_proc): Update.
> 	* interps.c (interpreter_exec_cmd): Update.
> 	* infrun.c (handle_command): Update.
> 	* inferior.c (add_inferior_command, clone_inferior_command):
> 	Update.
> 	* guile/scm-string.c (gdbscm_string_to_argv): Update.
> 	* exec.c (exec_file_command): Update.
> 	* compile/compile.c (build_argc_argv): Update.
> 	* cli/cli-cmds.c (alias_command): Update.

LGTM.

Thanks,
Pedro Alves


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]