]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
gdb: Replace \r\n with multi_line to make tests more readable
authorDaniel Knezevic <daniel.knezevic@htecgroup.com>
Tue, 25 Nov 2025 10:48:50 +0000 (11:48 +0100)
committerDaniel Knezevic <daniel.knezevic@htecgroup.com>
Fri, 9 Jan 2026 12:44:09 +0000 (13:44 +0100)
Approved-By: Tom Tromey <tom@tromey.com>
gdb/testsuite/gdb.base/ctf-ptype.exp
gdb/testsuite/gdb.base/ptype.exp
gdb/testsuite/gdb.xml/tdesc-regs.exp

index 96a34b66bef13cab256caf2bf372acca810ba44c..d17ce3bbc915bc703e06b397ae58b6b9868bba27 100644 (file)
@@ -59,7 +59,16 @@ gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" {
 # Here and elsewhere, we accept
 # "long", "long int", or "int" for long variables (whatis.exp already
 # has an XFAIL for "int" (Sun cc bug), so no need to fail it here).
-gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\]    (unsigned |)char v_char_member;.*\[\r\n\]    (short|short int) v_short_member;.*\[\r\n\]    int v_int_member;.*\[\r\n\]    (long|long int|int) v_long_member;.*\[\r\n\]    float v_float_member;.*\[\r\n\]    double v_double_member;.*\[\r\n\]\}.*" "ptype structure"
+gdb_test "ptype struct t_struct" \
+    [multi_line \
+       "type = struct t_struct {" \
+       "    (unsigned |)char v_char_member;" \
+       "    (short|short int) v_short_member;" \
+       "    int v_int_member;" \
+       "    (long|long int|int) v_long_member;" \
+       "    float v_float_member;" \
+       "    double v_double_member;" \
+       "}"] "ptype structure"
 
 
 # Test the equivalence between '.' and '->' for struct member references.
@@ -77,12 +86,27 @@ if {[gdb_test "ptype v_t_struct_p->v_float_member"  "type = float"] < 0} {
     return -1
 }
 
-gdb_test "ptype struct link" "type = struct link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.3.;\[\r\n\]+\}.*" "ptype linked list structure"
+gdb_test "ptype struct link" \
+    [multi_line \
+       "type = struct link {" \
+       "    struct link \\*next;" \
+       "    struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);" \
+       "    struct t_struct stuff.3.;" \
+       "}"] "ptype linked list structure"
 
 #
 # test ptype command with unions
 #
-gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\]    (unsigned |)char v_char_member;.*\[\r\n\]    (short|short int) v_short_member;.*\[\r\n\]    int v_int_member;.*\[\r\n\]    (long|long int|int) v_long_member;.*\[\r\n\]    float v_float_member;.*\[\r\n\]    double v_double_member;.*\[\r\n\]\}.*" "ptype union"
+gdb_test "ptype union t_union" \
+    [multi_line \
+       "type = union t_union {" \
+       "    (unsigned |)char v_char_member;" \
+       "    (short|short int) v_short_member;" \
+       "    int v_int_member;" \
+       "    (long|long int|int) v_long_member;" \
+       "    float v_float_member;" \
+       "    double v_double_member;" \
+       "}"] "ptype union"
 
 #
 # test ptype command with enums
@@ -179,33 +203,69 @@ gdb_test "ptype v_int" "type = int.*" "ptype int"
 #
 # test ptype command with nested structure and union
 #
-gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\]+\
-.*int outer_int;.*\[\r\n\]+\
-.*(struct|) inner_struct inner_struct_instance;.*\[\r\n\]+\
-.*(union|) inner_union inner_union_instance;.*\[\r\n\]+\
-.*(long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure"
-
-gdb_test "ptype struct inner_struct" "type = struct inner_struct \{.*\[\r\n\]    int inner_int;.*\[\r\n\]    (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure"
-
-gdb_test "ptype union inner_union" "type = union inner_union \{.*\[\r\n\]    int inner_union_int;.*\[\r\n\]    (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union"
-
-gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\]    int outer_int;.*\[\r\n\]    (struct |)inner_struct inner_struct_instance;.*\[\r\n\]    (union |)inner_union inner_union_instance;.*\[\r\n\]    (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure"
+gdb_test "ptype struct outer_struct" \
+    [multi_line \
+       "type = struct outer_struct {" \
+       "    int outer_int;" \
+       "    (struct|) inner_struct inner_struct_instance;" \
+       "    (union|) inner_union inner_union_instance;" \
+       "    (long|long int|int) outer_long;" \
+       "}"] "ptype outer structure"
+
+gdb_test "ptype struct inner_struct" \
+    [multi_line \
+       "type = struct inner_struct {" \
+       "    int inner_int;" \
+       "    (long|long int|int) inner_long;" \
+       "}"] "ptype inner structure"
+
+gdb_test "ptype union inner_union" \
+    [multi_line \
+       "type = union inner_union {" \
+       "    int inner_union_int;" \
+       "    (long|long int|int) inner_union_long;" \
+       "}"] "ptype inner union"
+
+gdb_test "ptype nested_su" \
+    [multi_line \
+       "type = struct outer_struct {" \
+       "    int outer_int;" \
+       "    (struct |)inner_struct inner_struct_instance;" \
+       "    (union |)inner_union inner_union_instance;" \
+       "    (long|long int|int) outer_long;" \
+       "}"] "ptype nested structure"
 
 gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int"
 
-gdb_test "ptype nested_su.inner_struct_instance" "type = struct inner_struct \{.*\[\r\n\]    int inner_int;.*\[\r\n\]    (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure #2"
+gdb_test "ptype nested_su.inner_struct_instance" \
+    [multi_line \
+       "type = struct inner_struct {" \
+       "    int inner_int;" \
+       "    (long|long int|int) inner_long;" \
+       "}"] "ptype nested structure #2"
 
 gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int"
 
-gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[\r\n\]    int inner_union_int;.*\[\r\n\]    (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union"
+gdb_test "ptype nested_su.inner_union_instance" \
+    [multi_line \
+       "type = union inner_union {" \
+       "    int inner_union_int;" \
+       "    (long|long int|int) inner_union_long;" \
+       "}"] "ptype nested union"
 
 # Print the type description of variable the_highest, and verify that
 # the type description for the fields whose type is anonymous are
 # correctly printed (at nesting level 1 and 2).
 
 gdb_test "ptype the_highest" \
-        "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*" \
-        "ptype the_highest"
+    [multi_line \
+       "type = struct highest {" \
+       "    int a;" \
+       "    struct {" \
+       "        int b;" \
+       "        struct {...} anonymous_level_2;" \
+       "    } anonymous_level_1;" \
+       "}"] "ptype the_highest"
 
 # Print the type description for one of the fields of variable the_highest.
 # The purpose is to verify that the type of a field that was printed above
@@ -213,8 +273,13 @@ gdb_test "ptype the_highest" \
 # nesting level is now one level less).
 
 gdb_test "ptype the_highest.anonymous_level_1" \
-        "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \
-        "ptype the_highest.anonymous_level_1"
+    [multi_line \
+       "type = struct {" \
+       "    int b;" \
+       "    struct {" \
+       "        int c;" \
+       "    \} anonymous_level_2;" \
+       "}"] "ptype the_highest.anonymous_level_1"
 
 # Print the type of the identifier ID, and check the response:
 # - Expect to see PROTOTYPED as the type.  PROTOTYPED is not a regular
index 6e6e8f9a326b344929098384bce339acd97fdb54..8545c716f272b34c656ca5eac681b53ed43a577c 100644 (file)
@@ -51,7 +51,16 @@ gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" {
 # Here and elsewhere, we accept
 # "long", "long int", or "int" for long variables (whatis.exp already
 # has an XFAIL for "int" (Sun cc bug), so no need to fail it here).
-gdb_test "ptype struct t_struct" "type = struct t_struct \{.*\[\r\n\]    (unsigned |)char v_char_member;.*\[\r\n\]    (short|short int) v_short_member;.*\[\r\n\]    int v_int_member;.*\[\r\n\]    (long|long int|int) v_long_member;.*\[\r\n\]    float v_float_member;.*\[\r\n\]    double v_double_member;.*\[\r\n\]\}.*" "ptype structure"
+gdb_test "ptype struct t_struct" \
+    [multi_line \
+       "type = struct t_struct {" \
+       "    (unsigned |)char v_char_member;" \
+       "    (short|short int) v_short_member;" \
+       "    int v_int_member;" \
+       "    (long|long int|int) v_long_member;" \
+       "    float v_float_member;" \
+       "    double v_double_member;" \
+       "}"] "ptype structure"
 
 
 # Test the equivalence between '.' and '->' for struct member references.
@@ -73,16 +82,37 @@ if {[gdb_test "ptype v_t_struct_p->v_float_member" "type = float"] < 0} {
 # IBM's xlc puts out bogus stabs--the stuff field is type 42,
 # which isn't defined.
 
-gdb_test "ptype struct link" "type = struct link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list structure"
+gdb_test "ptype struct link" \
+    [multi_line \
+       "type = struct link {" \
+       "    struct link \\*next;" \
+       "    struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);" \
+       "    struct t_struct stuff.1..2..3.;" \
+       "}"] "ptype linked list structure"
 
 #
 # test ptype command with unions
 #
-gdb_test "ptype union t_union" "type = union t_union \{.*\[\r\n\]    (unsigned |)char v_char_member;.*\[\r\n\]    (short|short int) v_short_member;.*\[\r\n\]    int v_int_member;.*\[\r\n\]    (long|long int|int) v_long_member;.*\[\r\n\]    float v_float_member;.*\[\r\n\]    double v_double_member;.*\[\r\n\]\}.*" "ptype union"
+gdb_test "ptype union t_union" \
+    [multi_line \
+       "type = union t_union {" \
+       "    (unsigned |)char v_char_member;" \
+       "    (short|short int) v_short_member;" \
+       "    int v_int_member;" \
+       "    (long|long int|int) v_long_member;" \
+       "    float v_float_member;" \
+       "    double v_double_member;" \
+       "}"] "ptype union"
 
 # IBM's xlc puts out bogus stabs--the stuff field is type 42,
 # which isn't defined.
-gdb_test "ptype union tu_link" "type = union tu_link \{\[\r\n\]+\[ \t\]+struct link \\*next;\[\r\n\]+\[ \t\]+struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);\[\r\n\]+\[ \t\]+struct t_struct stuff.1..2..3.;\[\r\n\]+\}.*" "ptype linked list union"
+gdb_test "ptype union tu_link" \
+    [multi_line \
+       "type = union tu_link {" \
+       "    struct link \\*next;" \
+       "    struct link \\*\\(\\*linkfunc\\)\\((struct link \\*, int|void|)\\);" \
+       "    struct t_struct stuff.1..2..3.;" \
+       "}"] "ptype linked list union"
 
 #
 # test ptype command with enums
@@ -472,32 +502,69 @@ gdb_test "ptype pv_char_array" "type = (|unsigned )char \\(\\*\\)\\\[0?\\\]"
 #
 # test ptype command with nested structure and union
 #
-gdb_test "ptype struct outer_struct" "type = struct outer_struct \{.*\[\r\n\]+\
-.*int outer_int;.*\[\r\n\]+\
-.*(struct|) inner_struct inner_struct_instance;.*\[\r\n\]+\
-.*(union|) inner_union inner_union_instance;.*\[\r\n\]+\
-.*(long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype outer structure"
-
-gdb_test "ptype struct inner_struct" "type = struct inner_struct \{.*\[\r\n\]    int inner_int;.*\[\r\n\]    (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype inner structure"
-
-gdb_test "ptype union inner_union" "type = union inner_union \{.*\[\r\n\]    int inner_union_int;.*\[\r\n\]    (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype inner union"
-
-gdb_test "ptype nested_su" "type = struct outer_struct \{.*\[\r\n\]    int outer_int;.*\[\r\n\]    (struct |)inner_struct inner_struct_instance;.*\[\r\n\]    (union |)inner_union inner_union_instance;.*\[\r\n\]    (long|long int|int) outer_long;.*\[\r\n\]\}.*" "ptype nested structure"
+gdb_test "ptype struct outer_struct" \
+    [multi_line \
+       "type = struct outer_struct {" \
+       "    int outer_int;" \
+       "    (struct|) inner_struct inner_struct_instance;" \
+       "    (union|) inner_union inner_union_instance;" \
+       "    (long|long int|int) outer_long;" \
+       "}"] "ptype outer structure"
+
+gdb_test "ptype struct inner_struct" \
+    [multi_line \
+       "type = struct inner_struct {" \
+       "    int inner_int;" \
+       "    (long|long int|int) inner_long;" \
+       "}"] "ptype inner structure"
+
+gdb_test "ptype union inner_union" \
+    [multi_line \
+       "type = union inner_union {" \
+       "    int inner_union_int;" \
+       "    (long|long int|int) inner_union_long;" \
+       "}"] "ptype inner union"
+
+gdb_test "ptype nested_su" \
+    [multi_line \
+       "type = struct outer_struct {" \
+       "    int outer_int;" \
+       "    (struct |)inner_struct inner_struct_instance;" \
+       "    (union |)inner_union inner_union_instance;" \
+       "    (long|long int|int) outer_long;" \
+       "}"] "ptype nested structure"
 
 gdb_test "ptype nested_su.outer_int" "type = int.*" "ptype outer int"
 
-gdb_test "ptype nested_su.inner_struct_instance" "type = struct inner_struct \{.*\[\r\n\]    int inner_int;.*\[\r\n\]    (long|long int|int) inner_long;.*\[\r\n\]\}.*" "ptype nested structure #2"
+gdb_test "ptype nested_su.inner_struct_instance" \
+    [multi_line \
+       "type = struct inner_struct {" \
+       "    int inner_int;" \
+       "    (long|long int|int) inner_long;" \
+       "}"] "ptype nested structure #2"
 
 gdb_test "ptype nested_su.inner_struct_instance.inner_int" "type = int.*" "ptype inner int"
 
-gdb_test "ptype nested_su.inner_union_instance" "type = union inner_union \{.*\[\r\n\]    int inner_union_int;.*\[\r\n\]    (long|long int|int) inner_union_long;.*\[\r\n\]\}.*" "ptype nested union"
+gdb_test "ptype nested_su.inner_union_instance" \
+    [multi_line \
+       "type = union inner_union {" \
+       "    int inner_union_int;" \
+       "    (long|long int|int) inner_union_long;" \
+       "}"] "ptype nested union"
 
 # Print the type description of variable the_highest, and verify that
 # the type description for the fields whose type is anonymous are
 # correctly printed (at nesting level 1 and 2).
 
 gdb_test "ptype the_highest" \
-        "type = struct highest \{.*\[\r\n\] *int a;.*\[\r\n\] *struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{\.\.\.\} anonymous_level_2;.*\[\r\n\] *\} anonymous_level_1;.*\[\r\n\]}.*"
+    [multi_line \
+       "type = struct highest {" \
+       "    int a;" \
+       "    struct {" \
+       "        int b;" \
+       "        struct \{\.\.\.\} anonymous_level_2;" \
+       "    \} anonymous_level_1;" \
+       "}"]
 
 # Print the type description for one of the fields of variable the_highest.
 # The purpose is to verify that the type of a field that was printed above
@@ -505,8 +572,13 @@ gdb_test "ptype the_highest" \
 # nesting level is now one level less).
 
 gdb_test "ptype the_highest.anonymous_level_1" \
-        "type = struct \{.*\[\r\n\] *int b;.*\[\r\n\] *struct \{.*\[\r\n\] *int c;.*\[\r\n\] *\} anonymous_level_2;.*\[\r\n\]}.*" \
-        "ptype the_highest.anonymous_level_1"
+    [multi_line \
+       "type = struct {" \
+       "    int b;" \
+       "    struct {" \
+       "        int c;" \
+       "    \} anonymous_level_2;" \
+       "}"] "ptype the_highest.anonymous_level_1"
 
 get_debug_format
 
index c0d7de3cb9aadadac62f2f97889397348102d03b..25028fbd6994f92ee6ab5d75495f6d8b54ffb16a 100644 (file)
@@ -179,17 +179,41 @@ gdb_test "ptype \$extrareg" "type = (int32_t|int|long|long long)"
 gdb_test "ptype \$uintreg" "type = uint32_t"
 gdb_test "ptype \$vecreg" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
 gdb_test "ptype \$unionreg" \
-    "type = union vecint {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
+    [multi_line \
+       "type = union vecint {" \
+       "    v4int8 v4;" \
+       "    v2int16 v2;" \
+       "}"]
 gdb_test "ptype \$unionreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
 gdb_test "ptype \$structreg" \
-    "type = struct struct1 {\r\n *v4int8 v4;\r\n *v2int16 v2;\r\n}"
+    [multi_line \
+       "type = struct struct1 {" \
+       "    v4int8 v4;" \
+       "    v2int16 v2;" \
+       "}"]
 gdb_test "ptype \$structreg.v4" "type = int8_t __attribute__ \\(\\(vector_size\\(4\\)\\)\\)"
 gdb_test "ptype \$bitfields" \
-    "type = struct struct2 {\r\n *uint64_t f1 : 35;\r\n *uint64_t f2 : 1;\r\n}"
+    [multi_line \
+       "type = struct struct2 {" \
+       "    uint64_t f1 : 35;" \
+       "    uint64_t f2 : 1;" \
+       "}"]
 gdb_test "ptype \$flags" \
-    "type = flag flags {\r\n *bool X @0;\r\n *uint32_t Y @2;\r\n}"
+    [multi_line \
+       "type = flag flags {" \
+       "    bool X @0;" \
+       "    uint32_t Y @2;" \
+       "}"]
 gdb_test "ptype \$mixed_flags" \
-    "type = flag mixed_flags {\r\n *bool A @0;\r\n *uint32_t B @1-3;\r\n *bool C @4;\r\n *uint32_t D @5;\r\n *uint32_t @6-7;\r\n *enum Z_values {yes = 1, no = 0, maybe = 2, so} Z @8-9;\r\n}"
+    [multi_line \
+       "type = flag mixed_flags {" \
+       "    bool A @0;" \
+       "    uint32_t B @1-3;" \
+       "    bool C @4;" \
+       "    uint32_t D @5;" \
+       "    uint32_t @6-7;" \
+       "    enum Z_values {yes = 1, no = 0, maybe = 2, so} Z @8-9;" \
+       "}"]
 # Reggroups should have at least general and the extra foo group
 gdb_test "maintenance print reggroups" \
     "Group\[ \t\]+Type\[ \t\]+\r\n.*general\[ \t\]+user\[ \t\]+\r\n.*foo\[ \t\]+user\[ \t\]+"