From patchwork Fri Oct 11 23:24:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 98768 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2EAA1385AC25 for ; Fri, 11 Oct 2024 23:25:15 +0000 (GMT) X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from omta36.uswest2.a.cloudfilter.net (omta36.uswest2.a.cloudfilter.net [35.89.44.35]) by sourceware.org (Postfix) with ESMTPS id 46B963858433 for ; Fri, 11 Oct 2024 23:24:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 46B963858433 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 46B963858433 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=35.89.44.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728689079; cv=none; b=Tbq7LMm9dD/JpZORqAQGStiSNFyn7guMDZHHJeM7MKvha/fSZFKWsY0F+rSbLcB3wquj716c0jNw6cza+sLPHvQRkZ2s0Gyu2v2czhgeplwssbpRh5qRFXMT6aEn1lbY6gxHnq/vVAvpwrYTM/NxPBE36D+TRp3sKE2dgiFV1z0= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1728689079; c=relaxed/simple; bh=msVRnOfTxJAMqfHIMMJ4hlCr/EoU3Tka134mbEIsiY4=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=QI6I4NcXC7oeqepSir5kHqW1jkwje3oU4iDgaC3zWjTVV6z3SWjy1Y/g8qp9BViNPAb5edconuelV1oN+6gMul0XD10GKMZcEvgYUAFNJmf9liYZUyCgIvROAPoKRZW4tnpaGqV8Sof40OBO6Iz1FfQRtJ5EC/Upv4yndRVpdJQ= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from eig-obgw-5010a.ext.cloudfilter.net ([10.0.29.199]) by cmsmtp with ESMTPS id z7GCsf06qqvuozOzss3mn2; Fri, 11 Oct 2024 23:24:36 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id zOzqskNmpxS8LzOzrswc1X; Fri, 11 Oct 2024 23:24:35 +0000 X-Authority-Analysis: v=2.4 cv=Wa4KaVhX c=1 sm=1 tr=0 ts=6709b3b3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=DAUX931o1VcA:10 a=ItBw4LHWJt0A:10 a=S9odsrSVWhxOl4p7IAkA:9 a=QEXdDO2ut3YA:10 a=6Ogn3jAGHLSNbaov7Orx:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=To:In-Reply-To:References:Message-Id:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:Date:From:Sender:Reply-To:Cc:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ck636J2xheT+bwMyWRS3l2NLsGpP/pHF9ZF3y9Zwiao=; b=ijA0aZw+UqhwmsTWIy6/7Jif2z LJj3A6S4Ez3Io9Z3NhYm8RlKwRiuxP3yuNQMxm/fa8nRC9KiZPEVshzd7QhzPr+iS4ClboeyxTL7x JVnpuUKPCychvmWgWnS0QF7XK; Received: from 97-118-40-216.hlrn.qwest.net ([97.118.40.216]:39238 helo=prentzel.local) by box5379.bluehost.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96.2) (envelope-from ) id 1szOzq-001F4p-1h for gdb-patches@sourceware.org; Fri, 11 Oct 2024 17:24:34 -0600 From: Tom Tromey Date: Fri, 11 Oct 2024 17:24:31 -0600 Subject: [PATCH 2/3] Use ui-out table in "maint print reggroups" MIME-Version: 1.0 Message-Id: <20241011-even-more-ui-out-v1-2-e1f92f01bacb@tromey.com> References: <20241011-even-more-ui-out-v1-0-e1f92f01bacb@tromey.com> In-Reply-To: <20241011-even-more-ui-out-v1-0-e1f92f01bacb@tromey.com> To: gdb-patches@sourceware.org X-Mailer: b4 0.14.2 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 97.118.40.216 X-Source-L: No X-Exim-ID: 1szOzq-001F4p-1h X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 97-118-40-216.hlrn.qwest.net (prentzel.local) [97.118.40.216]:39238 X-Source-Auth: tom+tromey.com X-Email-Count: 3 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfLFreDv44/ny6ZWQm6n1jnD5kpKqZumMxx/qn436lA4r0TQw+HylURN4uNeTshmG/EhcGSedsfCL0vSFTn5srbQp8GBRDMig7vO+Hlf5t8czs0WcGAfa 1F4I2MqZZVPnbE36ngTZ/tl5k7hnvynIzmu2pnCuWKkYLozto+T34itZ6fNbTJv6HSEXRPtRVn2Tdx4lUPBil8DT+n4/9WWrQbE= X-Spam-Status: No, score=-3020.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_LOTSOFHASH, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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~patchwork=sourceware.org@sourceware.org This changes the "maint print reggroups" command to use a ui-out table rather than printf. It also fixes a typo I noticed in a related test case name; and lets us finally remove the leading \s from the regexp in completion.exp. Reviewed-by: Christina Schimpe --- gdb/reggroups.c | 22 +++++++++++++--------- gdb/testsuite/gdb.base/completion.exp | 2 +- gdb/testsuite/gdb.base/reggroups.exp | 4 ++-- gdb/testsuite/gdb.python/py-arch-reg-groups.exp | 6 +++--- gdb/testsuite/gdb.xml/tdesc-regs.exp | 2 +- 5 files changed, 20 insertions(+), 16 deletions(-) diff --git a/gdb/reggroups.c b/gdb/reggroups.c index b2ac62c62b14d4d404b7107a90fdeb1954a7cadd..c651575257e3cd9757ddca20e8f1e47371bd3118 100644 --- a/gdb/reggroups.c +++ b/gdb/reggroups.c @@ -186,16 +186,19 @@ reggroup_find (struct gdbarch *gdbarch, const char *name) /* Dump out a table of register groups for the current architecture. */ static void -reggroups_dump (struct gdbarch *gdbarch, struct ui_file *file) +reggroups_dump (struct gdbarch *gdbarch, struct ui_out *out) { - static constexpr const char *fmt = " %-10s %-10s\n"; - - gdb_printf (file, fmt, "Group", "Type"); + ui_out_emit_table table (out, 2, -1, "RegGroups"); + out->table_header (10, ui_left, "group", "Group"); + out->table_header (10, ui_left, "type", "Type"); + out->table_body (); for (const struct reggroup *group : gdbarch_reggroups (gdbarch)) { + ui_out_emit_tuple tuple_emitter (out, nullptr); + /* Group name. */ - const char *name = group->name (); + out->field_string ("group", group->name ()); /* Group type. */ const char *type; @@ -214,8 +217,8 @@ reggroups_dump (struct gdbarch *gdbarch, struct ui_file *file) /* Note: If you change this, be sure to also update the documentation. */ - - gdb_printf (file, fmt, name, type); + out->field_string ("type", type); + out->text ("\n"); } } @@ -227,14 +230,15 @@ maintenance_print_reggroups (const char *args, int from_tty) struct gdbarch *gdbarch = get_current_arch (); if (args == NULL) - reggroups_dump (gdbarch, gdb_stdout); + reggroups_dump (gdbarch, current_uiout); else { stdio_file file; if (!file.open (args, "w")) perror_with_name (_("maintenance print reggroups")); - reggroups_dump (gdbarch, &file); + ui_out_redirect_pop redirect (current_uiout, &file); + reggroups_dump (gdbarch, current_uiout); } } diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 57b4d1c1045a2fad8d947fd804f3698a32960b52..aea18de9e3f87b43fd2e6ce111e1f1d0728e6cf5 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -145,7 +145,7 @@ append regs_output "\n" append regs_output [capture_command_output "mt print user-registers" \ ".*Name.*Nr\[^\n]*\n"] set all_regs {} -foreach {- reg} [regexp -all -inline -line {^\s*(\w+)} $regs_output] { +foreach {- reg} [regexp -all -inline -line {^(\w+)} $regs_output] { lappend all_regs $reg } diff --git a/gdb/testsuite/gdb.base/reggroups.exp b/gdb/testsuite/gdb.base/reggroups.exp index 56c00e588311fe2faedd440c1e614a7d6dafe7de..638601b4936fc905389ece05bbf6564b9aff4fe4 100644 --- a/gdb/testsuite/gdb.base/reggroups.exp +++ b/gdb/testsuite/gdb.base/reggroups.exp @@ -39,10 +39,10 @@ proc fetch_reggroups {test} { -re "maint print reggroups\r\n" { exp_continue } - -re "^ Group\[ \t\]+Type\[ \t\]+\r\n" { + -re "^Group\[ \t\]+Type\[ \t\]+\r\n" { exp_continue } - -re "^ (\[_0-9a-zA-Z-\]+)\[ \t\]+(user|internal)\[ \t\]+\r\n" { + -re "^(\[_0-9a-zA-Z-\]+)\[ \t\]+(user|internal)\[ \t\]+\r\n" { lappend reggroups $expect_out(1,string) exp_continue } diff --git a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp index 4ff3e9cd8c2a40f43ac723102f4b6408bee18e43..e3646f56eb64d3004ed4ccdc07c59cdd1c7f3b9b 100644 --- a/gdb/testsuite/gdb.python/py-arch-reg-groups.exp +++ b/gdb/testsuite/gdb.python/py-arch-reg-groups.exp @@ -32,10 +32,10 @@ if ![runto_main] { set groups {} set test "maint print reggroups" gdb_test_multiple $test $test { - -re ".*Group\[ \t\]+Type\[ \t\]+\r\n" { + -re "Group\[ \t\]+Type\[ \t\]+\r\n" { exp_continue } - -re "^ (\[^ \t\]+)\[ \t\]+\[^\r\n\]+\r\n" { + -re "^(\[^ \t\]+)\[ \t\]+\[^\r\n\]+\r\n" { lappend groups $expect_out(1,string) exp_continue } @@ -74,7 +74,7 @@ gdb_test_multiple "python print (\"\\n\".join (groups))" \ gdb_assert {[llength $py_groups] > 0} \ "Found at least one register group from python" gdb_assert {[llength $py_groups] == [llength $groups]} \ - "Same numnber of registers groups found" + "Same number of registers groups found" set found_non_match 0 for { set i 0 } { $i < [llength $groups] } { incr i } { diff --git a/gdb/testsuite/gdb.xml/tdesc-regs.exp b/gdb/testsuite/gdb.xml/tdesc-regs.exp index 344e387004a73c27e39e813a3aea39a1a93e4f07..1ba4cd90837fe7b378656a2be32063f65106eaba 100644 --- a/gdb/testsuite/gdb.xml/tdesc-regs.exp +++ b/gdb/testsuite/gdb.xml/tdesc-regs.exp @@ -195,7 +195,7 @@ 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}" # 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\]+" + "Group\[ \t\]+Type\[ \t\]+\r\n.*general\[ \t\]+user\[ \t\]+\r\n.*foo\[ \t\]+user\[ \t\]+" with_test_prefix "core-only.xml" { load_description "core-only.xml" "" "test-regs.xml"