From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qWXTN8rsJmnWFTIAWB0awg (envelope-from ) for ; Wed, 26 Nov 2025 07:04:26 -0500 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=htecgroup.com header.i=@htecgroup.com header.a=rsa-sha256 header.s=selector1 header.b=QaZZoEmo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id DA1271E08D; Wed, 26 Nov 2025 07:04:26 -0500 (EST) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from server2.sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 5D4311E08D for ; Wed, 26 Nov 2025 07:04:25 -0500 (EST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 236303857BA0 for ; Wed, 26 Nov 2025 12:04:25 +0000 (GMT) Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11021128.outbound.protection.outlook.com [52.101.70.128]) by sourceware.org (Postfix) with ESMTPS id DEE87385840D for ; Wed, 26 Nov 2025 12:03:17 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DEE87385840D Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=htecgroup.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=htecgroup.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DEE87385840D Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=52.101.70.128 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1764158598; cv=pass; b=bAbOxZNvKB9BAIcP8ibWC5TTThGkc/DBjGf8LMr4PPY2RX/wd9Ybnbh2VIWmJ3EKTS78860E9/dOIKdvKylUefCUffYsZhxN1BO/wLMwDw+Z4hJBSlSrcNR+fpd/gUl+icyKWGKxXE/xDQrgotHhQbiy0ki0MY34CP4Z2rhjz2k= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1764158598; c=relaxed/simple; bh=3Nop4go2Ld3TsICqiBdxXw25YJSDVZ7cNfzj4JQR/+s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=nrHU1s01+o8Obt5RMPCq+djEAiP5G41K21mq11d/Dn6zPymrumCRRMlWu7C2R4OlFbm1Biinj+GBBKS7LCJ817uPh9llRlJbYGaLpcDTVyl3U7Ia3WvBBjYXejiLgiGMdpnlp/n6p/W5bclQiWCbSsIuPKqPFWBmu7e83T+u46A= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ErojodqA5CCukp9c+hn3OgYTSjOjy8mjkvBxVJYq2h1h1SKckU7bpGPueI9ZbyLMYsxGbPgi4ByZcoeRFRnzwJd34Sy947mFTK3hn4xt4cFysU8zawuKMEuPcAEnXjLHBd3Gt4kBxVFUnT9cAy5jv4tR10J+iLj3Wsa419fxE8P7JFnqHDocFbvjykt0eWImnDpdo0+XZ+ZDO6Bc8saVK1xiOL6BqTu7UyQr0CHiJwUnTJ0iWhm+AAe4TlH4LhfHTD/5EVQI8O2//7LtdiMlpJ0VvZWU6rZzEayzyP4yEYi/5CrRo1uPbeawBDvze2la50UGxpeoFaK5FSiS7ZG9dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=sBWhbMrAK01oeZEUxHxwsfsvohQbT+owWvnkeEkDr1g=; b=AAjm0Ig/H929swPcg8GIqNEj0APycWAKkpgGJgESu+3jpW9KsXT3VqIUfBznUUWhJKyHOWKQVpfez7cA6p73DBGN3pIU+JCeyADx7E52Uwuv3WZK79YBYoUeHtxQ7YcfEVG+V4edCNLvZzkYOTW6h3zWdNiDHuke1fDqCk6nGVxFXW5fVi/Y7Bd1Y49F3QKa4qu98HFYXAHuIX3/5nt6+1ZMqJSq+CVhI17V9Ua9SyYbN/45wYaTZYnpBChMxug4Tbgf1a/cRbzIzMzMtSl2yKBIMVbeU8mswiFTJ/0lI/J+tOC3GnXfu+GFLgOhbhrBChWJ16rIlPSeyn8ZNRqZ7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=htecgroup.com; dmarc=pass action=none header.from=htecgroup.com; dkim=pass header.d=htecgroup.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=htecgroup.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=sBWhbMrAK01oeZEUxHxwsfsvohQbT+owWvnkeEkDr1g=; b=QaZZoEmoficMy06+hgFVxTUUoIZi1tq9czAJG7M6MKGR1Zz5bdH6NSJM6Yl5RzrHdvUS83xnXgwS5FFKeTYHhx/AIE9Z8t7MwiMnZ/grMp/hWDJl545SACfB3UjYVXGPp98zlZmGq1vQ3mGm2dAuXRvGD2+r7pBfk1Ay5wgPXYQBd7I9AkcFOalO1pIKd4tSfFnb2KRGPVdUrLBrIMmhC84gqhGpk0oacIn+TGs1/eHTzpMxUoOEUyn2/9ipr3RroZ0nGN9K6EaG6JX5fK0mPBEuko/nTfiIT3JaQR74ZEvbr+EZS0eSG34LE2MmvgultsRH6wMk43WOFUDQFQ+UxQ== Received: from DBBPR09MB3477.eurprd09.prod.outlook.com (2603:10a6:10:d7::21) by DBBPR09MB4537.eurprd09.prod.outlook.com (2603:10a6:10:1f5::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9366.12; Wed, 26 Nov 2025 12:03:02 +0000 Received: from DBBPR09MB3477.eurprd09.prod.outlook.com ([fe80::a339:e3f8:fe9b:112e]) by DBBPR09MB3477.eurprd09.prod.outlook.com ([fe80::a339:e3f8:fe9b:112e%7]) with mapi id 15.20.9343.016; Wed, 26 Nov 2025 12:03:02 +0000 From: Daniel Knezevic To: "gdb-patches@sourceware.org" CC: Tom Tromey , Pedro Alves , Simon Marchi , Daniel Knezevic Subject: [PATCH 3/3] gdb: Make printing enum types prettier. Thread-Topic: [PATCH 3/3] gdb: Make printing enum types prettier. Thread-Index: AQHcXsydPzS/IUDUskqNI/mRgLjfZg== Date: Wed, 26 Nov 2025 12:03:02 +0000 Message-ID: <20251126120210.919813-4-daniel.knezevic@htecgroup.com> References: <20251126120210.919813-1-daniel.knezevic@htecgroup.com> In-Reply-To: <20251126120210.919813-1-daniel.knezevic@htecgroup.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=htecgroup.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: DBBPR09MB3477:EE_|DBBPR09MB4537:EE_ x-ms-office365-filtering-correlation-id: 42e86f54-7e39-46ac-8b11-08de2ce3c028 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; ARA:13230040|366016|1800799024|376014|38070700021; x-microsoft-antispam-message-info: =?iso-8859-1?Q?yDE1cyXPxwHubdk2m2sf0TaVmUDrBxi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/7LoB662f6yie3YDN6Rpx/9S0kf9DABT6UTOAtkRZYnvR5FV?= =?iso-8859-1?Q?G2/JfagQShXOSeWt8kj679BDTtxJYAzD2h1gRHn6D/mNmct3ZfXiteEaOs?= =?iso-8859-1?Q?vNdgoxE1SFCypDtRj4CLols5dIkDNeZ/fHYvwhhp3a6rkLpoR74w1DJH/M?= =?iso-8859-1?Q?pGh54t38T74URa3HjPGOC6/Tv/J8v2URZlZRjN+JmynY0EBkwFmUwUv8rs?= =?iso-8859-1?Q?9PlUsKUT19jZ76a8fqgQVW5nHQNtIPPDtIgdiH/aipS3x2N9OhiVCjhK8S?= =?iso-8859-1?Q?ZxK8ZmZS4wT6aUZ2e4YvoL3riWdjwsFAzZXGewGwcXV1xviv0FY5f/4J7x?= =?iso-8859-1?Q?Y7P2FbQMa9xpzWsNNNnTNu4LAkuYAejlr/QkwWf3il6pPB72wYWycxZvQc?= =?iso-8859-1?Q?fn7u6lWeKe2XZcB/1luKLLLv3uGNiBYhBJ270RmfCy02OkmloWa3A99NBB?= =?iso-8859-1?Q?UqcQw8oN7OFMt2qob+2kVUfge6lQCxyn677oACzGSMp/5Bsg2pMgcMrvgj?= =?iso-8859-1?Q?3R6Bv7/b/8nbZ2RW3V6WHt4mcBb40DmXSUSAUicwAmwIn7JplTtskKj5cI?= =?iso-8859-1?Q?Xhqx8s1iZlEHh5Mz//Ndj8RMgdHPoFTq2lYGfNVJjVisbVGpcXI9dIj+MA?= =?iso-8859-1?Q?jDx67OEx6QjIkoMWh4Ibmrl2dkmu?= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DBBPR09MB3477.eurprd09.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(38070700021); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?ikCjGBLv1c9RzRsfNEeRm09/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?Q?RHuVavNrCl9qN+32rJIi8n2sQGucAVgPEm3ST+wdw4cAErItrZbi070ZER?= =?iso-8859-1?Q?6WYcq4gB3K5yfvg2fa/L3dGXzmZ7gBF6d+Tepo89Cjzhvljo5WaPlJAHNN?= =?iso-8859-1?Q?0qc5TkPJ8DZIna/0PpX4jw4qtgCaqB6BZTzqhZD/6IgUeovsqvAlSwqCve?= =?iso-8859-1?Q?iS4APpUWF/N5xHnSj4e/kL0S2TCXTot6F/m0fRM4azKOJQ04YAyKl6zhKG?= =?iso-8859-1?Q?mEfjuBScB35zUX8/x+aabxWCKeugpVcVtFHRBgHMFriEXE3HABSJur6mHB?= =?iso-8859-1?Q?PsTWBNJ8kzYuNSZLAfA72zG/KdeSVbXd4XIpSj+Cb+RwQR4eujD9MOyZ1k?= =?iso-8859-1?Q?D7nkVH0owiQ/Wqx84Es00bXYXMEA7uucuqGE2up2I03rW3CcEpp8oq7pEq?= =?iso-8859-1?Q?RHc5texsUcECTJdhDPMDAb3P4VBT11GayUfJmgwlwH+3ByOhyuo1oq3JUK?= =?iso-8859-1?Q?huQ8eZ4IJnY1nC/O621Z5TOmLqtOAcmedkqSyDf7zij97nOS1xn4qC/2lm?= =?iso-8859-1?Q?DFlfzLhEVC4je00MmVPlHqbfHM4NIGzTo9E2KL2DgJj7uS22QwptxIEiKE?= =?iso-8859-1?Q?pVaE3AeP9kpjQdhXHtEHwetH71/NdTcJwZnERGBdV6q8IvM25RpWH908fM?= =?iso-8859-1?Q?7ySi0zy9qQr1INjWQbll+T5suOqzJcg5NCFRw1+IyjaAO0p0opfXYvd9YL?= =?iso-8859-1?Q?lMthM75yVnVCh7BV3slrZnBtZvsA/BorQOoAtoDL3Oqh1dbVL015qKNHVc?= =?iso-8859-1?Q?KctraeaXCCBNpm4n8QE=3D?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: htecgroup.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DBBPR09MB3477.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 42e86f54-7e39-46ac-8b11-08de2ce3c028 X-MS-Exchange-CrossTenant-originalarrivaltime: 26 Nov 2025 12:03:02.5796 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 9f85665b-7efd-4776-9dfe-b6bfda2565ee X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: MoJRlVgLe6Xo1Jcx3aVcCLq0ul7xqfq1Zs2ful0kz8wFNI4y+B4WZg8GoBU+kBO9ld1qH9bFtmNzfuCghMuORLJL8Th+GjaKbQD8aaEGDVY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR09MB4537 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org Update printing of enum types to follow the same formatting conventions as for structs resulting in more readable output. Now that horizontal space is less of an issue enum values are always printed. Empty enums are now printed with an added "" message. Example of printing an enum with default values: enum class TestEnum {A, B, C, D}; (gdb) ptype TestEnum type =3D enum class TestEnum : int { TestEnum::A =3D 0, TestEnum::B =3D 1, TestEnum::C =3D 2, TestEnum::D =3D 3 } Example of printing an empty enum: enum class TestEnum {}; (gdb) ptype TestEnum type =3D enum class TestEnum : int { } Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=3D19294 --- gdb/c-typeprint.c | 28 +++---- gdb/testsuite/gdb.base/call-sc.exp | 11 ++- gdb/testsuite/gdb.base/ctf-ptype.exp | 76 ++++++++++++++++--- gdb/testsuite/gdb.base/ptype.exp | 76 ++++++++++++++++--- .../gdb.base/whatis-ptype-typedefs.exp | 8 +- gdb/testsuite/gdb.cp/classes.exp | 27 ++++++- gdb/testsuite/gdb.cp/empty-enum.exp | 24 +++++- gdb/testsuite/gdb.cp/enum-class.exp | 6 +- gdb/testsuite/gdb.cp/nested-types.exp | 6 +- gdb/testsuite/gdb.dwarf2/enum-type.exp | 14 +++- gdb/testsuite/gdb.xml/tdesc-regs.exp | 7 +- gdb/testsuite/lib/cp-support.exp | 39 +++++++--- 12 files changed, 258 insertions(+), 64 deletions(-) diff --git a/gdb/c-typeprint.c b/gdb/c-typeprint.c index 9e39c3d9b77..4dba9222066 100644 --- a/gdb/c-typeprint.c +++ b/gdb/c-typeprint.c @@ -1329,8 +1329,6 @@ c_type_print_base_enum (struct type *type, struct ui_= file *stream, } else if (show > 0 || type->name () =3D=3D NULL) { - LONGEST lastval =3D 0; - /* We can't handle this case perfectly, as DWARF does not tell us whether or not the underlying type was specified in the source (and other debug formats don't provide this @@ -1347,25 +1345,27 @@ c_type_print_base_enum (struct type *type, struct u= i_file *stream, gdb_printf (stream, ": %s ", underlying->name ()); } =20 - gdb_printf (stream, "{"); + gdb_printf (stream, "{\n"); int len =3D type->num_fields (); - for (int i =3D 0; i < len; i++) + if (len =3D=3D 0) { - QUIT; - if (i) - gdb_printf (stream, ", "); - stream->wrap_here (4); - fputs_styled (type->field (i).name (), - variable_name_style.style (), stream); - if (lastval !=3D type->field (i).loc_enumval ()) + fprintf_styled (stream, metadata_style.style (), + "%*s", level + 4, ""); + } + else + { + for (int i =3D 0; i < len; i++) { + QUIT; + if (i !=3D 0) + gdb_printf (stream, ",\n"); + fprintf_styled (stream, variable_name_style.style (), + "%*s%s", level + 4, "", type->field (i).name ()); gdb_printf (stream, " =3D %s", plongest (type->field (i).loc_enumval ())); - lastval =3D type->field (i).loc_enumval (); } - lastval++; } - gdb_printf (stream, "}"); + gdb_printf (stream, "\n%*s}", level, ""); } } =20 diff --git a/gdb/testsuite/gdb.base/call-sc.exp b/gdb/testsuite/gdb.base/ca= ll-sc.exp index 5f7cfe00c03..6f46ff2a67c 100644 --- a/gdb/testsuite/gdb.base/call-sc.exp +++ b/gdb/testsuite/gdb.base/call-sc.exp @@ -73,8 +73,17 @@ proc start_scalars_test { type } { set foo_t "$expect_out(1,string)" pass "$test (${foo_t})" } + -re "type =3D enum .*\\{\r\n.*\r\n\\}\r\n$gdb_prompt $" { + set foo_t "$expect_out(1,string)" + pass "$test (${foo_t})" + } + } + gdb_test_multiple "ptype/r foo" "ptype foo; ${testfile}" { + -re "type =3D .*$gdb_prompt $" { + set foo_t "$expect_out(1,string)" + pass "$test (${foo_t})" + } } - gdb_test "ptype/r foo" "type =3D ${foo_t}" "ptype foo; ${testfile} $ex= pect_out(1,string)" } =20 =20 diff --git a/gdb/testsuite/gdb.base/ctf-ptype.exp b/gdb/testsuite/gdb.base/= ctf-ptype.exp index 30f333744de..2515ad5422c 100644 --- a/gdb/testsuite/gdb.base/ctf-ptype.exp +++ b/gdb/testsuite/gdb.base/ctf-ptype.exp @@ -42,13 +42,27 @@ gdb_load $binfile # with stabs compilers which fail to use a nameless stab (such as # pre-2.4.5 versions of gcc and most non-gcc compilers). =20 + +set re1 [multi_line \ + "type =3D enum primary1_tag {" \ + " red1 =3D 0," \ + " green1 =3D 1," \ + " blue1 =3D 2" \ + "}.*$gdb_prompt $"] +set re2 [multi_line \ + "type =3D enum {" \ + " red1 =3D 0," \ + " green1 =3D 1," \ + " blue1 =3D 2" \ + "}.*$gdb_prompt $"] + gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" { - -re "type =3D enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $= " { + -re $re1 { # The workaround is in effect. As this is a compiler, not GDB, # bug, we'll make it a PASS but perhaps it should be an XFAIL. pass "ptype unnamed enumeration member (worked around)" } - -re "type =3D enum \{red1, green1, blue1\}.*$gdb_prompt $" { + -re $re2 { pass "ptype unnamed enumeration member" } } @@ -112,15 +126,32 @@ gdb_test "ptype union t_union" \ # test ptype command with enums # =20 -gdb_test "ptype primary" "type =3D enum .red, green, blue.*" "ptype unname= d enumeration" +gdb_test "ptype primary" \ + [multi_line \ + "type =3D enum {" \ + " red =3D 0," \ + " green =3D 1," \ + " blue =3D 2" \ + "}"] "ptype unnamed enumeration" =20 -gdb_test "ptype enum colors" "type =3D enum colors \{yellow, purple, pink\= }.*" "ptype named enumeration" +gdb_test "ptype enum colors" \ + [multi_line \ + "type =3D enum colors {" \ + " yellow =3D 0," \ + " purple =3D 1," \ + " pink =3D 2" \ + "}"] "ptype named enumeration" =20 =20 # # test ptype command with enums as typedef # -gdb_test "ptype boolean" "type =3D enum (boolean |)\{FALSE, TRUE\}.*" "pty= pe unnamed typedef'd enumeration" +gdb_test "ptype boolean" \ + [multi_line \ + "type =3D enum (boolean |){" \ + " FALSE =3D 0," \ + " TRUE =3D 1" \ + "}"] "ptype unnamed typedef'd enumeration" =20 gdb_test "list -q main" ".*" =20 @@ -133,19 +164,44 @@ gdb_test "ptype t_union3" "type =3D union (t_union3 |= )\{.* *double v_double_member;.* *int v_int_member;.*\}" "printing typedef'd union" =20 -gdb_test "ptype enum bvals" "type =3D enum bvals \{my_false, my_true\}.*" = "ptype named typedef'd enumf'd enum" +gdb_test "ptype enum bvals" \ + [multi_line \ + "type =3D enum bvals {" \ + " my_false =3D 0," \ + " my_true =3D 1" \ + "}"] "ptype named typedef'd enumf'd enum" =20 # # test ptype command with out-of-order enum values # -gdb_test "ptype enum misordered" "type =3D enum misordered \{two =3D 2, on= e =3D 1, zero =3D 0, three =3D 3\}.*" "ptype misordered enumeration" +gdb_test "ptype enum misordered" \ + [multi_line \ + "type =3D enum misordered {" \ + " two =3D 2," \ + " one =3D 1," \ + " zero =3D 0," \ + " three =3D 3" \ + "}"] "ptype misordered enumeration" =20 # # test ptype command with a named enum's value # -gdb_test "ptype three" "type =3D enum misordered \{two =3D 2, one =3D 1, z= ero =3D 0, three =3D 3\}.*" "ptype named enumeration member" - -gdb_test "ptype red" "type =3D enum \{red, green, blue\}.*" "ptype unnamed= enumeration member #2" +gdb_test "ptype three" \ + [multi_line \ + "type =3D enum misordered {" \ + " two =3D 2," \ + " one =3D 1," \ + " zero =3D 0," \ + " three =3D 3" \ + "}"] "ptype named enumeration member" + +gdb_test "ptype red" \ + [multi_line \ + "type =3D enum {" \ + " red =3D 0," \ + " green =3D 1," \ + " blue =3D 2" \ + "}"] "ptype unnamed enumeration member #2" =20 # # test ptype command with arrays diff --git a/gdb/testsuite/gdb.base/ptype.exp b/gdb/testsuite/gdb.base/ptyp= e.exp index 3335950e93e..be2d5dedc63 100644 --- a/gdb/testsuite/gdb.base/ptype.exp +++ b/gdb/testsuite/gdb.base/ptype.exp @@ -34,13 +34,27 @@ set gcc_compiled [is_c_compiler_gcc] # with stabs compilers which fail to use a nameless stab (such as # pre-2.4.5 versions of gcc and most non-gcc compilers). =20 + +set re1 [multi_line \ + "type =3D enum primary1_tag {" \ + " red1 =3D 0," \ + " green1 =3D 1," \ + " blue1 =3D 2" \ + "}.*$gdb_prompt $"] +set re2 [multi_line \ + "type =3D enum {" \ + " red1 =3D 0," \ + " green1 =3D 1," \ + " blue1 =3D 2" \ + "}.*$gdb_prompt $"] + gdb_test_multiple "ptype red1" "ptype unnamed enumeration member" { - -re "type =3D enum primary1_tag \{red1, green1, blue1\}.*$gdb_prompt $= " { + -re $re1 { # The workaround is in effect. As this is a compiler, not GDB, # bug, we'll make it a PASS but perhaps it should be an XFAIL. pass "ptype unnamed enumeration member (worked around)" } - -re "type =3D enum \{red1, green1, blue1\}.*$gdb_prompt $" { + -re $re2 { pass "ptype unnamed enumeration member" } } @@ -118,15 +132,32 @@ gdb_test "ptype union tu_link" \ # test ptype command with enums # =20 -gdb_test "ptype primary" "type =3D enum .red, green, blue.*" "ptype unname= d enumeration" +gdb_test "ptype primary" \ + [multi_line \ + "type =3D enum {" \ + " red =3D 0," \ + " green =3D 1," \ + " blue =3D 2" \ + "}"] "ptype unnamed enumeration" =20 -gdb_test "ptype enum colors" "type =3D enum colors \{yellow, purple, pink\= }.*" "ptype named enumeration" +gdb_test "ptype enum colors" \ + [multi_line \ + "type =3D enum colors {" \ + " yellow =3D 0," \ + " purple =3D 1," \ + " pink =3D 2" \ + "}"] "ptype named enumeration" =20 =20 # # test ptype command with enums as typedef # -gdb_test "ptype boolean" "type =3D enum (boolean |)\{FALSE, TRUE\}.*" "pty= pe unnamed typedef'd enumeration" +gdb_test "ptype boolean" \ + [multi_line \ + "type =3D enum (boolean |){" \ + " FALSE =3D 0," \ + " TRUE =3D 1" \ + "}"] "ptype unnamed typedef'd enumeration" =20 # And check that whatis shows the name, not "enum {...}". # This probably fails for all DWARF 1 cases, so assume so for now. -fnf @@ -157,19 +188,44 @@ gdb_test "ptype t_union3" "type =3D union (t_union3 |= )\{.* *double v_double_member;.* *int v_int_member;.*\}" "printing typedef'd union" =20 -gdb_test "ptype enum bvals" "type =3D enum bvals \{my_false, my_true\}.*" = "ptype named typedef'd enumf'd enum" +gdb_test "ptype enum bvals" \ + [multi_line \ + "type =3D enum bvals {" \ + " my_false =3D 0," \ + " my_true =3D 1" \ + "}"] "ptype named typedef'd enumf'd enum" =20 # # test ptype command with out-of-order enum values # -gdb_test "ptype enum misordered" "type =3D enum misordered \{two =3D 2, on= e =3D 1, zero =3D 0, three =3D 3\}.*" "ptype misordered enumeration" +gdb_test "ptype enum misordered" \ + [multi_line \ + "type =3D enum misordered {" \ + " two =3D 2," \ + " one =3D 1," \ + " zero =3D 0," \ + " three =3D 3" \ + "}"] "ptype misordered enumeration" =20 # # test ptype command with a named enum's value # -gdb_test "ptype three" "type =3D enum misordered \{two =3D 2, one =3D 1, z= ero =3D 0, three =3D 3\}.*" "ptype named enumeration member" - -gdb_test "ptype red" "type =3D enum \{red, green, blue\}.*" "ptype unnamed= enumeration member #2" +gdb_test "ptype three" \ + [multi_line \ + "type =3D enum misordered {" \ + " two =3D 2," \ + " one =3D 1," \ + " zero =3D 0," \ + " three =3D 3" \ + "}"] "ptype named enumeration member" + +gdb_test "ptype red" \ + [multi_line \ + "type =3D enum {" \ + " red =3D 0," \ + " green =3D 1," \ + " blue =3D 2" \ + "}"] "ptype unnamed enumeration member #2" =20 # # test ptype command with basic C types diff --git a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp b/gdb/testsui= te/gdb.base/whatis-ptype-typedefs.exp index 744c6ee999e..8eec4470618 100644 --- a/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp +++ b/gdb/testsuite/gdb.base/whatis-ptype-typedefs.exp @@ -103,10 +103,10 @@ set table { {"v_long_double_typedef" "long_double_typedef" "long double"} {"v_long_double_typedef2" "long_double_typedef2" "long double"} =20 - {"colors_typedef" "(enum )?colors" "enum colors( : unsigned int)= ? {red, green, blue}"} - {"colors_typedef2" "colors_typedef" "enum colors( : unsigned int)= ? {red, green, blue}"} - {"v_colors_typedef" "colors_typedef" "enum colors( : unsigned int)= ? {red, green, blue}"} - {"v_colors_typedef2" "colors_typedef2" "enum colors( : unsigned int)= ? {red, green, blue}"} + {"colors_typedef" "(enum )?colors" "enum colors( : unsigned int)= ? {.*red =3D 0,.* green =3D 1,.* blue =3D 2.*}"} + {"colors_typedef2" "colors_typedef" "enum colors( : unsigned int)= ? {.*red =3D 0,.* green =3D 1,.* blue =3D 2.*}"} + {"v_colors_typedef" "colors_typedef" "enum colors( : unsigned int)= ? {.*red =3D 0,.* green =3D 1,.* blue =3D 2.*}"} + {"v_colors_typedef2" "colors_typedef2" "enum colors( : unsigned int)= ? {.*red =3D 0,.* green =3D 1,.* blue =3D 2.*}"} =20 {"func_ftype" "void \\(void\\)" "void \\(void\\)"} {"func_ftype2" "func_ftype" "void \\(void\\)"} diff --git a/gdb/testsuite/gdb.cp/classes.exp b/gdb/testsuite/gdb.cp/classe= s.exp index 64689c701e2..13195a08e4f 100644 --- a/gdb/testsuite/gdb.cp/classes.exp +++ b/gdb/testsuite/gdb.cp/classes.exp @@ -510,16 +510,37 @@ proc test_enums {} { =20 # ptype on the enum member =20 + set re1 [multi_line \ + "type =3D enum ClassWithEnum::PrivEnum (: unsigned (int|short|char) )?{" = \ + " ?(ClassWithEnum::)?red =3D 0," \ + " (ClassWithEnum::)?green =3D 1," \ + " (ClassWithEnum::)?blue =3D 2," \ + " (ClassWithEnum::)?yellow =3D 42" \ + "?}$nl$gdb_prompt $"] + set re2 [multi_line \ + "type =3D enum PrivEnum {" \ + " ?(ClassWithEnum::)?red =3D 0," \ + " (ClassWithEnum::)?green =3D 1," \ + " (ClassWithEnum::)?blue =3D 2," \ + " (ClassWithEnum::)?yellow =3D 42" \ + "?}$nl$gdb_prompt $"] + set re3 [multi_line \ + "type =3D enum {" \ + " ?red =3D 0," \ + " green =3D 1," \ + " blue =3D 2," \ + " yellow =3D 42" \ + "?}$nl$gdb_prompt $"] gdb_test_multiple "ptype obj_with_enum.priv_enum" "ptype obj_with_enum= .priv_enum" { - -re "type =3D enum ClassWithEnum::PrivEnum (: unsigned (int|short|char) )= ?\{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?green, (ClassWithEnum::)?blue= , (ClassWithEnum::)?yellow =3D 42 ?\}$nl$gdb_prompt $" { + -re $re1 { pass "ptype obj_with_enum.priv_enum" } - -re "type =3D enum PrivEnum \{ ?(ClassWithEnum::)?red, (ClassWithEnum::)?= green, (ClassWithEnum::)?blue, (ClassWithEnum::)?yellow =3D 42 ?\}$nl$gdb_p= rompt $" { + -re $re2 { # gcc 2.95.3 -gdwarf-2 # gcc 3.3.2 -gdwarf-2 pass "ptype obj_with_enum.priv_enum" } - -re "type =3D enum \{ ?red, green, blue, yellow =3D 42 ?\}$nl$gdb_prompt = $" { + -re $re3 { # This case case is a little dubious, but it's not clear what # ought to be required of a ptype on a private enum... # -sts 19990324 diff --git a/gdb/testsuite/gdb.cp/empty-enum.exp b/gdb/testsuite/gdb.cp/emp= ty-enum.exp index 487d5619e44..0781e486706 100644 --- a/gdb/testsuite/gdb.cp/empty-enum.exp +++ b/gdb/testsuite/gdb.cp/empty-enum.exp @@ -53,11 +53,19 @@ gdb_test "print arg2" " =3D 4" # Xfail for missing DW_AT_type in DW_TAG_enumeration_type, gcc PR debug/16= 063. set have_xfail [expr {[test_compiler_info gcc-*] && [gcc_major_version] < = 5}] =20 +set enum1 [multi_line "" \ + "type =3D enum enum1 : unsigned int {" \ + " " \ + "}"] +set enum1_no_type [multi_line "" \ + "type =3D enum enum1 {" \ + " " \ + "}"] gdb_test_multiple "ptype arg1" "" { - -re -wrap "type =3D enum enum1 : unsigned int \\{\\}" { + -re -wrap $enum1 { pass $gdb_test_name } - -re -wrap "type =3D enum enum1 \\{\\}" { + -re -wrap $enum1_no_type { if { $have_xfail } { setup_xfail *-*-* gcc/16063 } @@ -65,11 +73,19 @@ gdb_test_multiple "ptype arg1" "" { } } =20 +set enum2 [multi_line "" \ + "type =3D enum class enum2 : unsigned char {" \ + " " \ + "}"] +set enum2_no_type [multi_line "" \ + "type =3D enum class enum2 {" \ + " " \ + "}"] gdb_test_multiple "ptype arg2" "" { - -re -wrap "type =3D enum class enum2 : unsigned char \\{\\}" { + -re -wrap $enum2 { pass $gdb_test_name } - -re -wrap "type =3D enum class enum2 \\{\\}" { + -re -wrap $enum2_no_type { if { $have_xfail } { setup_xfail *-*-* gcc/16063 } diff --git a/gdb/testsuite/gdb.cp/enum-class.exp b/gdb/testsuite/gdb.cp/enu= m-class.exp index dead0c51511..fbfda8937f0 100644 --- a/gdb/testsuite/gdb.cp/enum-class.exp +++ b/gdb/testsuite/gdb.cp/enum-class.exp @@ -29,7 +29,11 @@ if {![runto_main]} { } =20 gdb_test "ptype E1" \ - "type =3D enum class E1 (: int )?{E1::HI =3D 7, E1::THERE}" + [multi_line \ + "type =3D enum class E1 (: int )?{" \ + " E1::HI =3D 7," \ + " E1::THERE =3D 8" \ + "}"] =20 gdb_test "print E1::HI" " =3D E1::HI" gdb_test "print (int) E1::HI" " =3D 7" diff --git a/gdb/testsuite/gdb.cp/nested-types.exp b/gdb/testsuite/gdb.cp/n= ested-types.exp index 28ce8e0c094..0a4939e5062 100644 --- a/gdb/testsuite/gdb.cp/nested-types.exp +++ b/gdb/testsuite/gdb.cp/nested-types.exp @@ -154,9 +154,9 @@ proc make_enum {result_var id parent_list indent_lvl lo= g} { upvar $result_var result =20 set s "[qual_name E$id $parent_list]" - set a "[qual_name A$id $parent_list]" - set b "[qual_name B$id $parent_list]" - set c "[qual_name C$id $parent_list]" + set a "[qual_name A$id $parent_list] =3D 0" + set b "[qual_name B$id $parent_list] =3D 1" + set c "[qual_name C$id $parent_list] =3D 2" lappend result [list "type" "public" "enum" $s [list $a $b $c]] =20 if {$log} { diff --git a/gdb/testsuite/gdb.dwarf2/enum-type.exp b/gdb/testsuite/gdb.dwa= rf2/enum-type.exp index f077c0acb2a..6f751406f9b 100644 --- a/gdb/testsuite/gdb.dwarf2/enum-type.exp +++ b/gdb/testsuite/gdb.dwarf2/enum-type.exp @@ -109,11 +109,17 @@ if { [prepare_for_testing "failed to prepare" ${testf= ile} \ =20 gdb_test "print sizeof(enum E)" " =3D 4" =20 -gdb_test "ptype enum EU" "type =3D enum EU {TWO =3D 2}" \ - "ptype EU in enum C" +gdb_test "ptype enum EU" \ + [multi_line \ + "type =3D enum EU {" \ + " TWO =3D 2" \ + "}"] "ptype EU in enum C" gdb_test_no_output "set lang c++" -gdb_test "ptype enum EU" "type =3D enum EU : unsigned int {TWO =3D 2}" \ - "ptype EU in C++" +gdb_test "ptype enum EU" \ + [multi_line \ + "type =3D enum EU : unsigned int {" \ + " TWO =3D 2" \ + "}"] "ptype EU in C++" =20 gdb_test "p ns::val1" \ " =3D ns::val1" diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/t= desc-regs.exp index 63f5ebc90d8..2dcff9ab468 100644 --- a/gdb/testsuite/gdb.xml/tdesc-regs.exp +++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp @@ -212,7 +212,12 @@ gdb_test "ptype \$mixed_flags" \ " bool C @4;" \ " uint32_t D @5;" \ " uint32_t @6-7;" \ - " enum Z_values {yes =3D 1, no =3D 0, maybe =3D 2, so} Z @8-9;" \ + " enum Z_values {" \ + " yes =3D 1," \ + " no =3D 0," \ + " maybe =3D 2," \ + " so =3D 3" \ + " } Z @8-9;" \ "}"] # Reggroups should have at least general and the extra foo group gdb_test "maintenance print reggroups" \ diff --git a/gdb/testsuite/lib/cp-support.exp b/gdb/testsuite/lib/cp-suppor= t.exp index ded4cf8aeb6..5795836ce04 100644 --- a/gdb/testsuite/lib/cp-support.exp +++ b/gdb/testsuite/lib/cp-support.exp @@ -582,23 +582,44 @@ proc cp_test_ptype_class { in_exp in_testname in_key = in_tag in_class_table =20 switch $nested_key { enum { - set expected_result \ - "enum $nested_name (: (unsigned )?int )?\{" - foreach c $nested_children { - append expected_result "$c, " - } - set expected_result \ - [string trimright $expected_result { ,}] - append expected_result "\};" + set expected_result "enum $nested_name : unsigned int \{" cp_ptype_class_verbose \ "Expecting enum result: $expected_result" - if {![regexp -- $expected_result $actual_line]} { + if {![string equal $expected_result $actual_line]} { set txt "$in_testname // wrong nested type enum" append txt " definition: $actual_line" fail $txt queue delete $line_queue return false } + # This will be followed by lines for each value of the + # enum. + cp_ptype_class_verbose "matched enum value" + foreach m $nested_children { + set actual_line \ + [cp_support_internal::next_line $line_queue] + cp_ptype_class_verbose "Expecting enum value: $m" + # Remove the trailing comma from the actual line to + # simplify comparison. + set trimmed_actual_line \ + [string trimright $actual_line " ,"] + if {![string equal $m $trimmed_actual_line]} { + set txt "$in_testname // unexpected enum value: " + append txt $m + fail $txt + queue delete $line_queue + return false + } + cp_ptype_class_verbose "matched enum value \"$m\"" + } + + # Nested enum values always end with a trailing curly brace. + set actual_line [cp_support_internal::next_line $line_queue] + if {![string equal $actual_line "\};"]} { + fail "$in_testname // missing closing curly brace" + queue delete $line_queue + return false + } cp_ptype_class_verbose "passed enum $nested_name" } =20 --=20 2.43.0