public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Michael Weghorn <m.weghorn@posteo.de>
To: gdb-patches@sourceware.org
Cc: Michael Weghorn <m.weghorn@posteo.de>
Subject: [PATCH 2/8] gdbsupport: Make escaping in construct_inferior_arguments optional
Date: Fri, 22 Oct 2021 07:19:27 +0000	[thread overview]
Message-ID: <20211022071933.3478427-3-m.weghorn@posteo.de> (raw)
In-Reply-To: <20211022071933.3478427-1-m.weghorn@posteo.de>

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<char * const> argv)
+construct_inferior_arguments (gdb::array_view<char * const> argv,
+                              bool escape_args)
 {
   std::string result;
 
@@ -124,8 +125,14 @@ construct_inferior_arguments (gdb::array_view<char * const> 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<char * const>);
+construct_inferior_arguments (gdb::array_view<char * const>,
+                              bool escape_args = true);
 
 #endif /* COMMON_COMMON_INFERIOR_H */
-- 
2.33.0


  parent reply	other threads:[~2021-10-22  7:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-22  7:19 [PATCH 0/8] Unify escaping/quoting of args in GDB/GDBserver Michael Weghorn
2021-10-22  7:19 ` [PATCH 1/8] gdbsupport: Extract escaping from 'construct_inferior_arguments' Michael Weghorn
2021-10-22  7:19 ` Michael Weghorn [this message]
2021-10-22  7:19 ` [PATCH 3/8] PR27989 PR28446 gdbserver: Only escape args passed directly on invocation Michael Weghorn
2021-10-22  7:19 ` [PATCH 4/8] PR28392 Add a '--no-escape-args' option for gdb and gdbserver Michael Weghorn
2021-10-22  7:19 ` [PATCH 5/8] Extract helper function from 'fork_inferior' Michael Weghorn
2021-10-22  7:19 ` [PATCH 6/8] Add a 'fork_inferior' overload taking vector of args Michael Weghorn
2021-10-22  7:19 ` [PATCH 7/8] gdbserver: Support args with spaces for no-startup-with-shell case Michael Weghorn
2021-10-22  7:19 ` [PATCH 8/8] gdb: Support some escaping of args with startup-with-shell being off Michael Weghorn
2021-12-06 10:47 ` [PING] [PATCH 0/8] Unify escaping/quoting of args in GDB/GDBserver Michael Weghorn
2021-12-13  7:49   ` [PING 2] " Michael Weghorn
2022-01-04  4:22     ` [PING 3] " Michael Weghorn
2022-01-04 14:26       ` Simon Marchi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211022071933.3478427-3-m.weghorn@posteo.de \
    --to=m.weghorn@posteo.de \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).