From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id 52ADB388A801 for ; Wed, 13 May 2020 00:52:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 52ADB388A801 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [10.0.0.193] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 4E1061E79B; Tue, 12 May 2020 20:52:26 -0400 (EDT) Subject: Re: [PATCH v3 5/6] [PR gdbserver/25893]: Use construct_inferior_arguments which handles special chars To: Michael Weghorn , gdb-patches@sourceware.org References: <20200429111638.1327262-1-m.weghorn@posteo.de> <20200512154211.1311364-1-m.weghorn@posteo.de> <20200512154211.1311364-5-m.weghorn@posteo.de> From: Simon Marchi Message-ID: <75e9c38c-9e19-4c2a-7512-47f74890eb3e@simark.ca> Date: Tue, 12 May 2020 20:52:25 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200512154211.1311364-5-m.weghorn@posteo.de> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 May 2020 00:52:28 -0000 On 2020-05-12 11:42 a.m., Michael Weghorn via Gdb-patches wrote: > Use the construct_inferior_arguments function instead of > stringify_argv to construct a string from the program > arguments in those places where that one is then passed > to fork_inferior (linux-low, lyn-low), since > construct_inferior_arguments properly takes care of > special characters, while stringify_argv does not. > Using construct_inferior_arguments seems "natural", since its > documentation also mentions that it "does the > same shell processing as fork_inferior". > > Since construct_inferior_args has been extended to do > proper quoting for Windows shells in commit > 5d60742e2dd3c9b475dce54b56043a358751bbb8 > ("Fix quoting of special characters for the MinGW build.", > 2012-06-12), use it for the Windows case as well. > (I could not test that case myself, though.) > > Adapt handling of empty args in function 'handle_v_run' > in gdbserver/server.cc to just insert an empty string > for an empty arg, since that one is now properly handled > in 'construct_inferior_arguments' already (and inserting > a "''" string in 'handle_v_run' would otherwise > cause that one to be treated as a string literally > containing two quote characters, which > 'construct_inferior_args' would preserve by adding > extra escaping). > > This makes gdbserver properly handle program args containing special > characters (like spaces), e.g. (example from PR25893) > > $ gdbserver localhost:50505 myprogram "hello world" > > now properly handles "hello world" as a single arg, not two separate > ones ("hello", "world"). > > 2020-05-12 Michael Weghorn > > PR gdbserver/25893 > * linux-low.cc (linux_process_target::create_inferior), > lynx-low.cc (lynx_process_target::create_inferior), > win32-low.cc (win32_process_target::create_inferior): Use > construct_inferior_arguments instead of stringify_argv > to get string representation which properly escapes > special characters. > * server.cc (handle_v_run): Just pass empty program arg > as such, since any further processing is now handled via > construct_inferior_arguments This patch LGTM. Simon