]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Minor cleanups in ada-nested.exp
authorTom Tromey <tromey@adacore.com>
Wed, 15 Nov 2023 14:50:19 +0000 (07:50 -0700)
committerTom Tromey <tromey@adacore.com>
Wed, 15 Nov 2023 16:23:15 +0000 (09:23 -0700)
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

index 1a02f4f352ec42783ca05683395a05f279a3ff91..99741402aed594cb6f9a3a521863184f62d6b972 100644 (file)
@@ -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,8 +78,10 @@ foreach var [dict get $refs body variables] {
        "i" {
            gdb_assert {[dict get $var value] == "1"} "check value of i"
        }
-       "x" {
-           gdb_assert {[dict get $var value] == "12"} "check value of 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 $name"
        }
        "outer_arg" {
            gdb_assert {[dict get $var value] == "1"} "check value of outer_arg"