public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@adacore.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH] Turn set_inferior_args_vector into method of inferior
Date: Fri, 14 Apr 2023 13:19:06 -0600	[thread overview]
Message-ID: <20230414191906.480316-1-tromey@adacore.com> (raw)

This patch turns set_inferior_args_vector into an overload of
inferior::set_args.

Regression tested on x86-64 Fedora 36.
---
 gdb/infcmd.c   | 8 --------
 gdb/inferior.c | 8 ++++++++
 gdb/inferior.h | 5 +++--
 gdb/main.c     | 3 ++-
 4 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/gdb/infcmd.c b/gdb/infcmd.c
index 103899432f7..2b5815f09e3 100644
--- a/gdb/infcmd.c
+++ b/gdb/infcmd.c
@@ -128,14 +128,6 @@ show_inferior_tty_command (struct ui_file *file, int from_tty,
 		"is \"%s\".\n"), inferior_tty.c_str ());
 }
 
-void
-set_inferior_args_vector (int argc, char **argv)
-{
-  gdb::array_view<char * const> args (argv, argc);
-  std::string n = construct_inferior_arguments (args);
-  current_inferior ()->set_args (std::move (n));
-}
-
 /* Notice when `set args' is run.  */
 
 static void
diff --git a/gdb/inferior.c b/gdb/inferior.c
index 6eb9f3ff23b..4a2baf19c87 100644
--- a/gdb/inferior.c
+++ b/gdb/inferior.c
@@ -164,6 +164,14 @@ inferior::tty ()
   return m_terminal;
 }
 
+/* See inferior.h.  */
+
+void
+inferior::set_args (gdb::array_view<char * const> args)
+{
+  set_args (construct_inferior_arguments (args));
+}
+
 void
 inferior::add_continuation (std::function<void ()> &&cont)
 {
diff --git a/gdb/inferior.h b/gdb/inferior.h
index 633916eb7c1..5da7c62473b 100644
--- a/gdb/inferior.h
+++ b/gdb/inferior.h
@@ -225,8 +225,6 @@ extern void post_create_inferior (int from_tty);
 
 extern void attach_command (const char *, int);
 
-extern void set_inferior_args_vector (int, char **);
-
 extern void registers_info (const char *, int);
 
 extern void continue_1 (int all_threads);
@@ -523,6 +521,9 @@ class inferior : public refcounted_object,
     m_args = std::move (args);
   };
 
+  /* Set the argument string from some strings.  */
+  void set_args (gdb::array_view<char * const> args);
+
   /* Get the argument string to use when running this inferior.
 
      No arguments is represented by an empty string.  */
diff --git a/gdb/main.c b/gdb/main.c
index 0bf6f98a797..9fb6dceb9ca 100644
--- a/gdb/main.c
+++ b/gdb/main.c
@@ -1064,7 +1064,8 @@ captured_main_1 (struct captured_main_args *context)
       symarg = argv[optind];
       execarg = argv[optind];
       ++optind;
-      set_inferior_args_vector (argc - optind, &argv[optind]);
+      current_inferior ()->set_args
+	(gdb::array_view<char * const> (&argv[optind], argc - optind));
     }
   else
     {
-- 
2.39.1


             reply	other threads:[~2023-04-14 19:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-14 19:19 Tom Tromey [this message]
2023-05-01 17:09 ` Tom Tromey

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=20230414191906.480316-1-tromey@adacore.com \
    --to=tromey@adacore.com \
    --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).