[binutils-gdb] gdb/testsuite: add -inferior-args option to runto

Simon Marchi via Gdb-cvs <[email protected]> Fri, 19 Jun 2026 20:09:13 +0000 (GMT)
Newsgroups gmane.comp.gdb.cvs
Message-ID <[email protected]>
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=9a277306d60e096f145ce9bfe82aaeafe71675d3

commit 9a277306d60e096f145ce9bfe82aaeafe71675d3
Author: Simon Marchi <[email protected]>
Date:   Wed May 6 16:27:51 2026 -0400

    gdb/testsuite: add -inferior-args option to runto
    
    Add a new -inferior-args option to proc runto, to allow passing
    arguments to the test program.  Its value is forwarded to gdb_run_cmd,
    which does the right thing, including with the native-gdbserver board,
    where arguments need to be passed on the gdbserver command line.
    
    The option is named -inferior-args (rather than the shorter -args)
    because parse_args sets a variable in the caller's scope using the
    option name.  Naming it "-args" would clash with the "args" parameter.
    
    Subsequent patches use this new option.
    
    Change-Id: If2483c22302ed432ccd6cebef8d235e3e1d35bb8
    Reviewed-By: Tankut Baris Aktemur <[email protected]>

Diff:
---
 gdb/testsuite/lib/gdb.exp | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 31bb1c0fe59..d8619ded236 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -817,16 +817,22 @@ proc gdb_breakpoint { linespec args } {
 # just compare to "function" because it might be a fully qualified,
 # single quoted C++ function specifier.
 #
-# If there are additional arguments, pass them to gdb_breakpoint.
-# We recognize -no-message/-message ourselves as well as -no-delete-breakpoints.
+# This proc recognizes the -no-message/-message, -no-delete-breakpoints
+# and -inferior-args options.  If there are additional arguments, pass
+# them to gdb_breakpoint.
 #
 # -no-message is messed up here, like gdb_breakpoint: to preserve
 # historical usage fails are always printed by default.
 # -no-message: turns off printing of fails (and passes, but they're already off)
 # -message: turns on printing of passes (and fails, but they're already on)
 #
-# The 'no-delete-brekpoints' option stops this proc from deleting all
+# The -no-delete-breakpoints option stops this proc from deleting all
 # breakpoints.
+#
+# The -inferior-args option allows to specify arguments to pass to the
+# inferior.  For example, this would pass three arguments:
+#
+#     runto func -inferior-args "one two three"
 
 proc runto { linespec args } {
     global gdb_prompt
@@ -838,6 +844,7 @@ proc runto { linespec args } {
 	{no-delete-breakpoints}
 	{message}
 	{no-message}
+	{inferior-args ""}
     }
 
     if {!${no-delete-breakpoints}} {
@@ -871,7 +878,7 @@ proc runto { linespec args } {
 	return 0
     }
 
-    gdb_run_cmd
+    gdb_run_cmd ${inferior-args}
 
     # the "at foo.c:36" output we get with -g.
     # the "in func" output we get without -g.