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

Message ID 20260506202804.1681886-4-simon.marchi@polymtl.ca
State New
Headers
Series gdb/testsuite: allow passing inferior arguments with native-gdbserver board |

Commit Message

Simon Marchi May 6, 2026, 8:27 p.m. UTC
  From: Simon Marchi <simon.marchi@polymtl.ca>

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
---
 gdb/testsuite/lib/gdb.exp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
  

Comments

Tankut Baris Aktemur May 12, 2026, 1:02 p.m. UTC | #1
AMD General

Hi Simon,

> From: Simon Marchi <simon.marchi@polymtl.ca>
>
> 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
> ---
>  gdb/testsuite/lib/gdb.exp | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
> index 601896457fea..60bcb582aeef 100644
> --- a/gdb/testsuite/lib/gdb.exp
> +++ b/gdb/testsuite/lib/gdb.exp
> @@ -809,6 +809,7 @@ proc runto { linespec args } {
>         {no-delete-breakpoints}
>         {message}
>         {no-message}
> +       {inferior-args ""}

I think this needs to be documented in the proc comment.

-Baris
  

Patch

diff --git a/gdb/testsuite/lib/gdb.exp b/gdb/testsuite/lib/gdb.exp
index 601896457fea..60bcb582aeef 100644
--- a/gdb/testsuite/lib/gdb.exp
+++ b/gdb/testsuite/lib/gdb.exp
@@ -809,6 +809,7 @@  proc runto { linespec args } {
 	{no-delete-breakpoints}
 	{message}
 	{no-message}
+	{inferior-args ""}
     }
 
     if {!${no-delete-breakpoints}} {
@@ -842,7 +843,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.