From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by sourceware.org (Postfix) with ESMTPS id 1E8E43857C76 for ; Fri, 22 Oct 2021 07:20:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 1E8E43857C76 Received: from submission (posteo.de [89.146.220.130]) by mout02.posteo.de (Postfix) with ESMTPS id C3F98240105 for ; Fri, 22 Oct 2021 09:20:06 +0200 (CEST) Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4HbG2Z1S2vz6tmf; Fri, 22 Oct 2021 09:20:06 +0200 (CEST) From: Michael Weghorn To: gdb-patches@sourceware.org Cc: Michael Weghorn Subject: [PATCH 2/8] gdbsupport: Make escaping in construct_inferior_arguments optional Date: Fri, 22 Oct 2021 07:19:27 +0000 Message-Id: <20211022071933.3478427-3-m.weghorn@posteo.de> In-Reply-To: <20211022071933.3478427-1-m.weghorn@posteo.de> References: <20211022071933.3478427-1-m.weghorn@posteo.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Fri, 22 Oct 2021 07:20:09 -0000 Add a new bool param 'escape_args' to 'construct_inferior_arguments' that specifies whether or not the arguments should be escaped for the case that the debuggee is run in a shell. The new param defaults to 'true' so the behaviour of existing uses of the function remains unchanged. Uses of the function with 'escape_args=false' will be added in follow-up commits. --- gdbsupport/common-inferior.cc | 13 ++++++++++--- gdbsupport/common-inferior.h | 9 ++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/gdbsupport/common-inferior.cc b/gdbsupport/common-inferior.cc index d6b99a89a81..ca2355332d3 100644 --- a/gdbsupport/common-inferior.cc +++ b/gdbsupport/common-inferior.cc @@ -102,7 +102,8 @@ escape_arg_as_necessary (char * arg) /* See common-inferior.h. */ std::string -construct_inferior_arguments (gdb::array_view argv) +construct_inferior_arguments (gdb::array_view argv, + bool escape_args) { std::string result; @@ -124,8 +125,14 @@ construct_inferior_arguments (gdb::array_view argv) error (_("can't handle command-line " "argument containing whitespace")); } - - result += escape_arg_as_necessary (argv[i]); + if (escape_args) + { + result += escape_arg_as_necessary (argv[i]); + } + else + { + result += argv[i]; + } } return result; diff --git a/gdbsupport/common-inferior.h b/gdbsupport/common-inferior.h index 8f104b6c632..db7bf82f08a 100644 --- a/gdbsupport/common-inferior.h +++ b/gdbsupport/common-inferior.h @@ -64,9 +64,12 @@ extern bool startup_with_shell; extern std::string escape_arg_as_necessary (char * arg); -/* Compute command-line string given argument vector. This does the - same shell processing as fork_inferior. */ +/* Compute command-line string given argument vector. + + ESCAPE_ARGS specifies whether the arguments should be escaped for the case + that the debuggee is run in a shell. */ extern std::string -construct_inferior_arguments (gdb::array_view); +construct_inferior_arguments (gdb::array_view, + bool escape_args = true); #endif /* COMMON_COMMON_INFERIOR_H */ -- 2.33.0