]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[gdb/testsuite] Handle address class annotation for s390x in some test-cases
authorTom de Vries <tdevries@suse.de>
Wed, 24 Jul 2024 12:56:56 +0000 (14:56 +0200)
committerTom de Vries <tdevries@suse.de>
Wed, 24 Jul 2024 12:56:56 +0000 (14:56 +0200)
On s390x-linux, I ran into:
...
(gdb) ptype crash^M
type = class crash {^M
^M
  public:^M
    crash(int (class {...}::*)(class {...} * const @mode32));^M
}^M
(gdb) FAIL: gdb.dwarf2/dw2-anon-mptr.exp: ptype crash
...

The problem is that the test-case doesn't expect the address class annotation
@mode32.

The test-case uses a .S file, with the address size hard-coded to 4 bytes, and
that's something that is annotated with @mode32 on s390x (which uses 8 byte
addresses).

Fix this by allowing the annotation in the regexp.

Likewise in two other test-cases.

Tested on s390-linux and x86_64-linux.

gdb/testsuite/gdb.dwarf2/dw2-anon-mptr.exp
gdb/testsuite/gdb.dwarf2/dw2-opt-structptr.exp
gdb/testsuite/gdb.dwarf2/member-ptr-forwardref.exp

index 5935ba628b6f033a13de36a8d8bd38106b491277..fa98e413ad8130e3183cbab3f962c0b80300794b 100644 (file)
@@ -36,5 +36,19 @@ gdb_test "show cp-abi" {The currently selected C\+\+ ABI is "gnu-v3".*}
 
 gdb_load $binfile
 
+set re_address_class "@\[^\r\n\]+"
+
+set re_class_ptr_const \
+    [string cat \
+        [string_to_regexp "class {...} * const"] "( $re_address_class)?"]
+
 gdb_test "ptype crash" \
-    "type = class crash {\[\r\n \t\]*public:\[\r\n \t\]*crash\\(int \\(class {\\.\\.\\.}::\\*\\)\\(class {\\.\\.\\.} \\* const\\)\\);\[\r\n \t\]*}"
+    [multi_line \
+        "type = class crash {" \
+        "" \
+        "  public:" \
+        [string cat \
+             [string_to_regexp "    crash(int (class {...}::*)("] \
+             $re_class_ptr_const \
+             [string_to_regexp "));"]] \
+        "}"]
index cebed1d292bb86a107a2242bd79c9ded9c452246..d73f4a892ba1b91d252ff24a50cd4dab1b45d16a 100644 (file)
@@ -126,6 +126,8 @@ proc build_test_program {} {
     }
 }
 
+set re_address_class "@\[^\r\n\]+"
+
 # Test access to an optimized-out pointer-to-struct using the
 # console interpreter.
 
@@ -210,13 +212,18 @@ proc do_mi_test {} {
        
        # Test that -var-create for 'ptr' is successful.
        mi_create_varobj "var1" "ptr" "create varobj for ptr"
+
+       set struct_foo_ptr \
+           [string cat \
+                [string_to_regexp "struct foo *"] "( $::re_address_class)?"]
        
        # Test that -var-list-children of 'ptr' is successful.
-       mi_list_varobj_children "var1" { \
-           {var1.a a 0 integer} \
-           {var1.x x 128 foo__array_type} \
-           {var1.y y 3 "struct foo \\*"} \
-       } "get children of var1 (ptr)"
+       mi_list_varobj_children "var1" \
+           [list \
+                {var1.a a 0 integer} \
+                {var1.x x 128 foo__array_type} \
+                [list "var1.y" "y" "3" $struct_foo_ptr]] \
+           "get children of var1 (ptr)"
 
        # Test that dereferencing 'ptr' will throw an error.
        mi_gdb_test "-var-create var2 * &((ptr)->a)" \
index c97c887d5a120dd8ccd515f35e40a9fa5cd6384f..21ad111c9ac082906964c7798a9b9b095ccf49fa 100644 (file)
@@ -34,5 +34,19 @@ gdb_test "show cp-abi" {The currently selected C\+\+ ABI is "gnu-v3".*}
 
 gdb_load ${binfile}
 
+set re_address_class "@\[^\r\n\]+"
+
+set re_C_ptr \
+    [string cat \
+        [string_to_regexp "C *"] "( const)?( $re_address_class)?"]
+
 gdb_test_no_output "set language c++"
-gdb_test "ptype c" "type = struct C {\[\r\n \t\]*private:\[\r\n \t\]*int \\(C::\\*fp\\)\\(C \\*( const)?\\);\[\r\n \t\]*}"
+gdb_test "ptype c" \
+    [multi_line \
+        "type = struct C {" \
+        "  private:" \
+        [string cat \
+             [string_to_regexp "    int (C::*fp)("] \
+             $re_C_ptr \
+             [string_to_regexp ");"]] \
+        "}"]