[2/3] Use ui-out table in "maint print reggroups"
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Build passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
fail
|
Test failed
|
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
fail
|
Test failed
|
Commit Message
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.
---
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(-)
Comments
Hi Tom,
while I can't approve, this patch looks good to me with the nit fixed below.
> -----Original Message-----
> From: Tom Tromey <tom@tromey.com>
> Sent: Saturday, October 12, 2024 1:25 AM
> To: gdb-patches@sourceware.org
> Subject: [PATCH 2/3] Use ui-out table in "maint print reggroups"
>
> 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.
> ---
> 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..c651575257e3cd9757ddca
> 20e8f1e47371bd3118 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)
> {
I think we can omit the "struct" for both parameters here.
Reviewed-by: Christina Schimpe <christina.schimpe@intel.com>
Thanks,
Christina
Intel Deutschland GmbH
Registered Address: Am Campeon 10, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de
Managing Directors: Sean Fennelly, Jeffrey Schneiderman, Tiffany Doon Silva
Chairperson of the Supervisory Board: Nicole Lau
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928
@@ -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);
}
}
@@ -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
}
@@ -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
}
@@ -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 } {
@@ -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"