From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 115700 invoked by alias); 5 Jun 2017 16:21:45 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 115663 invoked by uid 89); 5 Jun 2017 16:21:43 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 05 Jun 2017 16:21:41 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id DAB2C824; Mon, 5 Jun 2017 16:21:44 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com DAB2C824 Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx05.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=palves@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com DAB2C824 Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0C9705DD60; Mon, 5 Jun 2017 16:21:43 +0000 (UTC) Subject: Re: [RFA 22/23] Make gdb_buildargv return a unique pointer To: Tom Tromey , gdb-patches@sourceware.org References: <20170503224626.2818-1-tom@tromey.com> <20170503224626.2818-23-tom@tromey.com> From: Pedro Alves Message-ID: <1b605c61-d219-5ecc-c68f-91f76ed3cf65@redhat.com> Date: Mon, 05 Jun 2017 16:21:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <20170503224626.2818-23-tom@tromey.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-06/txt/msg00121.txt.bz2 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 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 > > * 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