Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Knezevic <daniel.knezevic@htecgroup.com>
To: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>, Pedro Alves <pedro@palves.net>,
	Simon Marchi <simark@simark.ca>,
	Daniel Knezevic <daniel.knezevic@htecgroup.com>
Subject: [PATCH 2/3] gdb: Replace \r\n with multi_line to make tests more readable
Date: Wed, 26 Nov 2025 12:03:00 +0000	[thread overview]
Message-ID: <20251126120210.919813-3-daniel.knezevic@htecgroup.com> (raw)
In-Reply-To: <20251126120210.919813-1-daniel.knezevic@htecgroup.com>

---
 gdb/testsuite/gdb.base/ctf-ptype.exp | 105 ++++++++++++++++++++-----
 gdb/testsuite/gdb.base/ptype.exp     | 112 ++++++++++++++++++++++-----
 gdb/testsuite/gdb.xml/tdesc-regs.exp |  34 ++++++--
 3 files changed, 206 insertions(+), 45 deletions(-)

diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/ctf-ptype.exp
index 8baefdc005e..30f333744de 100644
--- a/gdb/testsuite/gdb.base/ctf-ptype.exp
+++ b/gdb/testsuite/gdb.base/ctf-ptype.exp
@@ -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 descrption 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
diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptype.exp
index cf28aea2f51..3335950e93e 100644
--- a/gdb/testsuite/gdb.base/ptype.exp
+++ b/gdb/testsuite/gdb.base/ptype.exp
@@ -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 descrption 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
 
diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp
index fa9b5b71310..63f5ebc90d8 100644
--- a/gdb/testsuite/gdb.xml/tdesc-regs.exp
+++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp
@@ -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\]+"
-- 
2.43.0

  parent reply	other threads:[~2025-11-26 12:04 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26 12:02 [PATCH 0/3 v4] gdb: Make printing enum types prettier Daniel Knezevic
2025-11-26 12:02 ` [PATCH 1/3] gdb: Move logic for printing enums to a helper function Daniel Knezevic
2025-11-26 12:03 ` Daniel Knezevic [this message]
2025-11-26 12:43   ` [PATCH 2/3] gdb: Replace \r\n with multi_line to make tests more readable Andreas Schwab
2025-11-26 12:03 ` [PATCH 3/3] gdb: Make printing enum types prettier Daniel Knezevic
2025-12-01 20:23 ` [PATCH 0/3 v4] " Tom Tromey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251126120210.919813-3-daniel.knezevic@htecgroup.com \
    --to=daniel.knezevic@htecgroup.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pedro@palves.net \
    --cc=simark@simark.ca \
    --cc=tom@tromey.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox