public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Minor cleanups in ada-nested.exp
@ 2023-11-15 15:01 Tom Tromey
  2023-11-15 15:40 ` Tom de Vries
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2023-11-15 15:01 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

This changes ada-nested.exp to fix a test name (the test expects three
variables but is named "two"), and to iterate over all the variables
that are found.  It also adds a workaround to a problem Tom de Vries
found with an older version of GNAT -- it emits a duplicate "x".
---
 gdb/testsuite/gdb.dap/ada-nested.exp | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/gdb/testsuite/gdb.dap/ada-nested.exp b/gdb/testsuite/gdb.dap/ada-nested.exp
index 1a02f4f352e..1f425a73667 100644
--- a/gdb/testsuite/gdb.dap/ada-nested.exp
+++ b/gdb/testsuite/gdb.dap/ada-nested.exp
@@ -60,13 +60,15 @@ lassign $scopes args locals _ignore
 gdb_assert {[dict get $args name] == "Arguments"} "argument scope"
 gdb_assert {[dict get $locals name] == "Locals"} "local scope"
 
-gdb_assert {[dict get $locals namedVariables] == 3} "two locals"
+set num_vars [dict get $locals namedVariables]
+# Some versions of GNAT emit an extra 'x' in scope.
+gdb_assert {$num_vars == 3 || $num_vars == 4} "correct number of locals"
 
 set num [dict get $locals variablesReference]
 set refs [lindex [dap_check_request_and_response "fetch variables" \
 		      "variables" \
-		      [format {o variablesReference [i %d] count [i 3]} \
-			   $num]] \
+		      [format {o variablesReference [i %d] count [i %d]} \
+			   $num $num_vars]] \
 	      0]
 
 foreach var [dict get $refs body variables] {
@@ -76,7 +78,9 @@ foreach var [dict get $refs body variables] {
 	"i" {
 	    gdb_assert {[dict get $var value] == "1"} "check value of i"
 	}
-	"x" {
+	"x" - "x #2" {
+	    # Some versions of GNAT erroneously emit a duplicate 'x'.
+	    # Work around it here.
 	    gdb_assert {[dict get $var value] == "12"} "check value of x"
 	}
 	"outer_arg" {
-- 
2.41.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Minor cleanups in ada-nested.exp
  2023-11-15 15:01 [PATCH v2] Minor cleanups in ada-nested.exp Tom Tromey
@ 2023-11-15 15:40 ` Tom de Vries
  2023-11-15 16:22   ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Tom de Vries @ 2023-11-15 15:40 UTC (permalink / raw)
  To: Tom Tromey, gdb-patches

On 11/15/23 16:01, Tom Tromey wrote:
> This changes ada-nested.exp to fix a test name (the test expects three
> variables but is named "two"), and to iterate over all the variables
> that are found.  It also adds a workaround to a problem Tom de Vries
> found with an older version of GNAT -- it emits a duplicate "x".

I applied the patch and get a DUPLICATE message:
...
Running /data/vries/gdb/src/gdb/testsuite/gdb.dap/ada-nested.exp ...
DUPLICATE: gdb.dap/ada-nested.exp: check value of x

		=== gdb Summary ===

# of expected passes		17
# of duplicate test names	1
...

Otherwise LGTM.

Thanks,
- Tom

> ---
>   gdb/testsuite/gdb.dap/ada-nested.exp | 12 ++++++++----
>   1 file changed, 8 insertions(+), 4 deletions(-)
> 
> diff --git a/gdb/testsuite/gdb.dap/ada-nested.exp b/gdb/testsuite/gdb.dap/ada-nested.exp
> index 1a02f4f352e..1f425a73667 100644
> --- a/gdb/testsuite/gdb.dap/ada-nested.exp
> +++ b/gdb/testsuite/gdb.dap/ada-nested.exp
> @@ -60,13 +60,15 @@ lassign $scopes args locals _ignore
>   gdb_assert {[dict get $args name] == "Arguments"} "argument scope"
>   gdb_assert {[dict get $locals name] == "Locals"} "local scope"
>   
> -gdb_assert {[dict get $locals namedVariables] == 3} "two locals"
> +set num_vars [dict get $locals namedVariables]
> +# Some versions of GNAT emit an extra 'x' in scope.
> +gdb_assert {$num_vars == 3 || $num_vars == 4} "correct number of locals"
>   
>   set num [dict get $locals variablesReference]
>   set refs [lindex [dap_check_request_and_response "fetch variables" \
>   		      "variables" \
> -		      [format {o variablesReference [i %d] count [i 3]} \
> -			   $num]] \
> +		      [format {o variablesReference [i %d] count [i %d]} \
> +			   $num $num_vars]] \
>   	      0]
>   
>   foreach var [dict get $refs body variables] {
> @@ -76,7 +78,9 @@ foreach var [dict get $refs body variables] {
>   	"i" {
>   	    gdb_assert {[dict get $var value] == "1"} "check value of i"
>   	}
> -	"x" {
> +	"x" - "x #2" {
> +	    # Some versions of GNAT erroneously emit a duplicate 'x'.
> +	    # Work around it here.
>   	    gdb_assert {[dict get $var value] == "12"} "check value of x"
>   	}
>   	"outer_arg" {


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] Minor cleanups in ada-nested.exp
  2023-11-15 15:40 ` Tom de Vries
@ 2023-11-15 16:22   ` Tom Tromey
  0 siblings, 0 replies; 3+ messages in thread
From: Tom Tromey @ 2023-11-15 16:22 UTC (permalink / raw)
  To: Tom de Vries; +Cc: Tom Tromey, gdb-patches

>>>>> "Tom" == Tom de Vries <tdevries@suse.de> writes:

Tom> I applied the patch and get a DUPLICATE message:
Tom> ...
Tom> Running /data/vries/gdb/src/gdb/testsuite/gdb.dap/ada-nested.exp ...
Tom> DUPLICATE: gdb.dap/ada-nested.exp: check value of x

Oops, sorry about that.

I've fixed that & now I'm going to push this.
Will backport as well.

Tom

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-11-15 16:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-15 15:01 [PATCH v2] Minor cleanups in ada-nested.exp Tom Tromey
2023-11-15 15:40 ` Tom de Vries
2023-11-15 16:22   ` Tom Tromey

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).