]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Allow unqualified names in Ada tests
authorTom Tromey <tromey@adacore.com>
Fri, 23 Aug 2024 19:08:42 +0000 (13:08 -0600)
committerTom Tromey <tromey@adacore.com>
Thu, 6 Mar 2025 21:17:17 +0000 (14:17 -0700)
Currently, when a type is declared in a subprogram that isn't part of
a package, gdb will give this type a qualified name.  E.g., in the
program for gdb.ada/arr_arr.exp:

    procedure Foo is
       type Array2_First is array (24 .. 26) of Integer;

gdb will name this type 'foo.array2_first'.

However, with some coming changes to GNAT (and with the remainder of
this series applied as well), this will no longer happen.  Instead,
such types will be given their local name.  IMO this makes more sense
anyway.

This patch updates most of the Ada tests to allow either form in the
spots where it matters.  Both are accepted so that the tests continue
to work with older versions of GNAT.  (A few tests are handled in
separate patches; this patch only contains the straightforward
changes.)

14 files changed:
gdb/testsuite/gdb.ada/access_to_unbounded_array.exp
gdb/testsuite/gdb.ada/arr_arr.exp
gdb/testsuite/gdb.ada/arrayptr.exp
gdb/testsuite/gdb.ada/dyn-range.exp
gdb/testsuite/gdb.ada/local-enum.exp
gdb/testsuite/gdb.ada/mi_string_access.exp
gdb/testsuite/gdb.ada/mi_var_access.exp
gdb/testsuite/gdb.ada/null_overload.exp
gdb/testsuite/gdb.ada/packed_array.exp
gdb/testsuite/gdb.ada/py_range.exp
gdb/testsuite/gdb.ada/rec_comp.exp
gdb/testsuite/gdb.ada/unc_arr_ptr_in_var_rec.exp
gdb/testsuite/gdb.ada/variant_record_packed_array.exp
gdb/testsuite/gdb.ada/whatis_array_val.exp

index eeaceb018ed880160066ab3422ff2765a719d40f..fa807c588eed64300575f9055a7adc43c3bd84ef 100644 (file)
@@ -31,6 +31,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
     set bp_location [gdb_get_line_number "BREAK" ${testdir}/foo.adb]
     runto "foo.adb:$bp_location"
 
-    gdb_test "print Aos(1)" " = \\(foo.string_access\\) $hex"
-    gdb_test "print Aos(2)" " = \\(foo.string_access\\) $hex"
+    # Accept "foo." prefix for older versions of GNAT.
+    gdb_test "print Aos(1)" " = \\((foo.)?string_access\\) $hex"
+    gdb_test "print Aos(2)" " = \\((foo.)?string_access\\) $hex"
 }
index dc641ae6dffa4caff7cd5e016ba3b52cc2fad092..146e6da262d5d076973411880d9c9f2f4f0fe983 100644 (file)
@@ -30,5 +30,6 @@ if {![runto "foo.adb:$bp_location"]} {
   return
 }
 
+# Accept "foo." prefix for older versions of GNAT.
 gdb_test "ptype a2" \
-         " = array \\(1 \\.\\. 2\\) of foo.array2_first"
+    " = array \\(1 \\.\\. 2\\) of (foo.)?array2_first"
index b8c2eab09c4e43a72555b40916cc3f2696bed847..7998a614a1f25ab15dcb8274e358cf324b9a3a3b 100644 (file)
@@ -33,14 +33,15 @@ foreach_gnat_encoding scenario flags {all minimal} {
        return
     }
 
+    # Accept "foo." prefix for older versions of GNAT.
     gdb_test "print string_p" \
-       "= \\(foo\\.string_access\\) 0x\[0-9a-zA-Z\]+"
+       "= \\((foo\\.)?string_access\\) 0x\[0-9a-zA-Z\]+"
 
     gdb_test "print string_p(3..4)" "= \"ll\""
 
-    gdb_test "print null_string" "= \\(foo\\.string_access\\) 0x0"
+    gdb_test "print null_string" "= \\((foo\\.)?string_access\\) 0x0"
 
-    gdb_test "print arr_ptr" "= \\(access foo\\.little_array\\) 0x\[0-9a-zA-Z\]+"
+    gdb_test "print arr_ptr" "= \\(access (foo\\.)?little_array\\) 0x\[0-9a-zA-Z\]+"
 
     gdb_test "print arr_ptr(2)" "= 22"
 
index 9c25522917187913c63a101434db62c8fdade292..a7a42bac3a6dbd2b01b399f7be45ba80fad65ff8 100644 (file)
@@ -30,4 +30,5 @@ if {![runto "dyn.adb:$bp_location"]} {
     return -1
 }
 
-gdb_test "whatis d" "type = dyn.dyn_range"
+# Accept "dyn." prefix for older versions of GNAT.
+gdb_test "whatis d" "type = (dyn.)?dyn_range"
index 82642cf0dcf612b9b8c6dcc97f6e51ccc77684e0..b1dfd11582a8f7c60a08667dd9524e75b9312374 100644 (file)
@@ -35,18 +35,19 @@ if {![runto "local.adb:$bp_location"]} {
 # name of the enum, either "e1" or "e2".
 proc print_three {which_enum value} {
     # We don't know which in order gdb will print the constants, so
-    # adapt to either.
+    # adapt to either.  Accept "local." prefix for older versions of
+    # GNAT.
     set menu1 [multi_line \
                   "Multiple matches for three" \
                   "\\\[0\\\] cancel" \
-                  "\\\[1\\\] local\\.e2'\\(three\\) \\(enumeral\\)" \
-                  "\\\[2\\\] local\\.e1'\\(three\\) \\(enumeral\\)" \
+                  "\\\[1\\\] (local\\.)?e2'\\(three\\) \\(enumeral\\)" \
+                  "\\\[2\\\] (local\\.)?e1'\\(three\\) \\(enumeral\\)" \
                   "> $"]
     set menu2 [multi_line \
                   "Multiple matches for three" \
                   "\\\[0\\\] cancel" \
-                  "\\\[1\\\] local\\.e1'\\(three\\) \\(enumeral\\)" \
-                  "\\\[2\\\] local\\.e2'\\(three\\) \\(enumeral\\)" \
+                  "\\\[1\\\] (local\\.)?e1'\\(three\\) \\(enumeral\\)" \
+                  "\\\[2\\\] (local\\.)?e2'\\(three\\) \\(enumeral\\)" \
                   "> $"]
 
     set index -1
index 8fd116b545c00e00b069034f63a66e736ebbce09..59a7ad67f8ae44e5a8e3d91f05f84b640bf80cdc 100644 (file)
@@ -44,8 +44,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
        "\\^done,name=\"var1\",numchild=\"2\",.*" \
        "Create var1 varobj"
 
+    # Accept "bar." prefix for older versions of GNAT.
     mi_gdb_test "-var-list-children 1 var1" \
-       "\\^done,numchild=\"2\",children=\\\[child={name=\"var1.1\",exp=\"1\",numchild=\"1\",value=\"$hex\",type=\"bar.string_access\",thread-id=\"$decimal\"},child={name=\"var1.2\",exp=\"2\",numchild=\"1\",value=\"$hex\",type=\"bar.string_access\",thread-id=\"$decimal\"}\\\],has_more=\"0\"" \
+       "\\^done,numchild=\"2\",children=\\\[child={name=\"var1.1\",exp=\"1\",numchild=\"1\",value=\"$hex\",type=\"(bar.)?string_access\",thread-id=\"$decimal\"},child={name=\"var1.2\",exp=\"2\",numchild=\"1\",value=\"$hex\",type=\"(bar.)?string_access\",thread-id=\"$decimal\"}\\\],has_more=\"0\"" \
        "list var1's children"
 
     mi_gdb_test "-var-evaluate-expression var1" \
index 15419bb6629dfbd938baf64988514b22520d6311..1448ce37e10d6e8739b46399206009baedbc891d 100644 (file)
@@ -52,11 +52,18 @@ mi_continue_to_line \
     "mi_access.adb:$bp_location" \
     "stop at stop 2"
 
+# A helper to quote some expected output, then arrange for the package
+# component to be optional.
+proc optional_quote {out} {
+    set out [string_to_regexp $out]
+    return [regsub -all "pck\\\\." $out "(pck\\.)?"]
+}
+
 # If the  VAROBJ_UPDATE_RESULT.TYPE is true, the new_type and new_num_children
 # strings and values will be printed.  This currently happens on PowerPC but
 # not X86-64.
 set re_default [string_to_regexp {^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="false",has_more="0"}]}]
-set re_varobj_update_result_type [string_to_regexp {^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="true",new_type="pck.string_access",new_num_children="1",has_more="0"}]}]
+set re_varobj_update_result_type [optional_quote {^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="true",new_type="pck.string_access",new_num_children="1",has_more="0"}]}]
 mi_gdb_test "-var-update A_String_Access" \
     "($re_default|$re_varobj_update_result_type)" \
     "update at stop 2"
@@ -71,5 +78,5 @@ mi_continue_to_line \
     "stop at stop 3"
 
 mi_gdb_test "-var-update A_String_Access" \
-    [string_to_regexp {^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="true",new_type="pck.string_access",new_num_children="0",has_more="0"}]}] \
+    [optional_quote {^done,changelist=[{name="A_String_Access",in_scope="true",type_changed="true",new_type="pck.string_access",new_num_children="0",has_more="0"}]}] \
     "update at stop 3"
index 434366fab60d09c6705e00269ee862233d9f361c..664fc4225c51e1c169b063c877c733c41c196471 100644 (file)
@@ -34,4 +34,5 @@ gdb_test "print f(0)" " = false"
 
 gdb_test "print null" " = null"
 gdb_test "print/d null" " = 0"
-gdb_test "print U_Ptr" " = \\\(access foo\\.u_0\\\) 0x0"
+# Accept "foo." prefix for older versions of GNAT.
+gdb_test "print U_Ptr" " = \\\(access (foo\\.)?u_0\\\) 0x0"
index 85bc59db882720f93ea848f84d4cdf37bfa3b804..14a4b69e300b8b4d66bc51adc3b7d4c118453e90 100644 (file)
@@ -40,8 +40,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
     gdb_test "ptype &var" \
        "type = access array \\(4 \\.\\. 8\\) of boolean <packed: 1-bit elements>"
 
+    # Accept "pa." prefix for older versions of GNAT.
     gdb_test "print &var" \
-       "= \\(access pa.packed_array\\) 0x.*"
+       "= \\(access (pa.)?packed_array\\) 0x.*"
 
     # Print the value of U_Var, an unconstrainted packed array.
 
index f96beac6dc0ffd230dc5f066b968f239b113a8ed..295eb78a554256779f11e58ae4db8a7d75779e87 100644 (file)
@@ -38,10 +38,11 @@ gdb_test "python print(int(gdb.parse_and_eval('si')))" \
 gdb_test "python print(int(gdb.parse_and_eval('ir')))" \
          "974"
 
+# Accept "foo." prefix for older versions of GNAT.
 gdb_test "python print(gdb.parse_and_eval('si').type)" \
-    "foo\\.small_integer" "print type"
+    "(foo\\.)?small_integer" "print type"
 gdb_test "python print(gdb.parse_and_eval('si').type.name)" \
-    "foo\\.small_integer" "print type name"
+    "(foo\\.)?small_integer" "print type name"
 
 gdb_test "python print(gdb.selected_inferior().main_name)" \
     "_ada_foo" \
index 641ebb6f3cb100a9e785b98d39498d43709ffd00..5c5c794bc12824877bef205c5977b493b7d4a767 100644 (file)
@@ -30,9 +30,10 @@ if {![runto "bar_o203_012.adb:$bp_location"]} {
   return
 }
 
-gdb_test "whatis r.ia" " = bar_o203_012.int_access"
+# Accept "bar_o203_012." prefix for older versions of GNAT.
+gdb_test "whatis r.ia" " = (bar_o203_012.)?int_access"
 
 gdb_test "ptype r" \
-    " = record\r\n *ia: bar_o203_012\\.int_access;\r\nend record"
+    " = record\r\n *ia: (bar_o203_012\\.)?int_access;\r\nend record"
 
 gdb_test "ptype r.ia" " = access <$decimal-byte integer>"
index 2bcc027cec4384e191e6e1a8b6a0e8383d54a570..1512f23ce4077ea486cdece1cc7cfad1828cfa85 100644 (file)
@@ -37,8 +37,9 @@ foreach_gnat_encoding scenario flags {all minimal} {
        "= \\(n => 3, ptr => 0x0, data => \\(3, 5, 8\\)\\)" \
        "print My_Object with null Ptr"
 
+    # Accept "foo." prefix for older versions of GNAT.
     gdb_test "print my_object.ptr" \
-       "= \\(foo.table_access\\) 0x0" \
+       "= \\((foo.)?table_access\\) 0x0" \
        "print My_Object.Ptr when null"
 
     # Same for My_P_Object...
@@ -48,7 +49,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
        "print My_P_Object with null Ptr"
 
     gdb_test "print my_p_object.ptr" \
-       "\\(foo.p_table_access\\) 0x0" \
+       "\\((foo.)?p_table_access\\) 0x0" \
        "print My_P_Object.Ptr when null"
 
     # Continue until the Ptr component of both objects get allocated.
@@ -68,7 +69,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
        "print my_object after setting Ptr"
 
     gdb_test "print my_object.ptr" \
-       "\\(foo.table_access\\) $hex" \
+       "\\((foo.)?table_access\\) $hex" \
        "print my_object.ptr when no longer null"
 
     gdb_test "print my_object.ptr.all" \
@@ -81,7 +82,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
        "print my_p_object after setting Ptr"
 
     gdb_test "print my_p_object.ptr" \
-       "= \\(foo.p_table_access\\) $hex" \
+       "= \\((foo.)?p_table_access\\) $hex" \
        "print My_P_Object.Ptr when no longer null"
 
     gdb_test "print my_p_object.ptr.all" \
index f193459b3358306521eb0365ce0ee13542c597df..47446c910ce29a428b21ea54598509d1a40d2e93 100644 (file)
@@ -52,7 +52,7 @@ foreach_gnat_encoding scenario flags {all minimal} {
        "= \\(system\\.address\\) $hex" \
        "print address"
 
-    set test "print {foo.octal_buffer}($)"
+    set test "print {octal_buffer}($)"
     gdb_test_multiple "$test" $test {
        -re "= \\(size => 8, buffer => \\(1, 2, 3, 4, 5, 6, 7, 0\\), length => 8\\)\[\r\n\]+$gdb_prompt $" {
            pass $test
index 007d6ef130e55191fd13ea399e2951d2e1c0fd49..1ebbf977cebe29245e2f923aa994ffa59c274943 100644 (file)
@@ -30,12 +30,13 @@ if {![runto "foo.adb:$bp_location"]} {
   return
 } 
 
+# Accept "foo." prefix for older versions of GNAT.
 gdb_test "whatis full" \
-         "type = foo\\.full_table"
+         "type = (foo\\.)?full_table"
 
 gdb_test "print full" \
          " = \\(144, 233, 377, 610, 987\\)"
 
 gdb_test "whatis $" \
-         "type = foo\\.full_table"
+         "type = (foo\\.)?full_table"