[1/3] Use ui-out in maintenance_print_user_registers
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 |
fail
|
Testing failed
|
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_gdb_check--master-arm |
fail
|
Testing failed
|
Commit Message
This changes maintenance_print_user_registers to use a ui-out table.
---
gdb/user-regs.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
Comments
Hi Tom,
On Wed, 9 Aug 2023 at 18:41, Tom Tromey <tom@tromey.com> wrote:
> This changes maintenance_print_user_registers to use a ui-out table.
> ---
> gdb/user-regs.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/gdb/user-regs.c b/gdb/user-regs.c
> index 25c57d4886c..503a41162c6 100644
> --- a/gdb/user-regs.c
> +++ b/gdb/user-regs.c
> @@ -223,9 +223,19 @@ maintenance_print_user_registers (const char *args,
> int from_tty)
> struct gdb_user_regs *regs = get_user_regs (gdbarch);
> regnum = gdbarch_num_cooked_regs (gdbarch);
>
> - gdb_printf (" %-11s %3s\n", "Name", "Nr");
> + struct ui_out *uiout = current_uiout;
> + ui_out_emit_table table_emitter (uiout, 2, -1, "user-registers");
> + uiout->table_header (11, ui_left, "name", "Name");
> + uiout->table_header (3, ui_right, "number", "Nr");
> +
> + uiout->table_body ();
> for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum)
> - gdb_printf (" %-11s %3d\n", reg->name, regnum);
> + {
> + ui_out_emit_tuple tuple_emitter (uiout, nullptr);
> + uiout->field_string ("name", reg->name);
> + uiout->field_signed ("number", regnum);
> + uiout->text ("\n");
> + }
> }
>
> void _initialize_user_regs ();
>
> --
> 2.41.0
>
>
Our pre-commit CI has noticed that this causes a regression on aarch64 in
gdb.base/completion.exp:
FAIL: gdb.base/completion.exp: complete 'info registers '
I digged a bit, and it seems related to the fact that there's a slight
spacing difference.
Before your patch mt print user-registers prints:
fp 260
(with a leading space)
after your patch, it prints:
fp 260
(with a trailing space)
Accepting no space before the register name in completion.exp is enough to
make the test pass again, but I guess you probably want to fix the actual
output instead?
diff --git a/gdb/testsuite/gdb.base/completion.exp
b/gdb/testsuite/gdb.base/completion.exp
index 4686e6f8f34..07a91c90f73 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 {^\s*(\w+)} $regs_output] {
lappend all_regs $reg
}
Thanks,
Christophe
@@ -223,9 +223,19 @@ maintenance_print_user_registers (const char *args, int from_tty)
struct gdb_user_regs *regs = get_user_regs (gdbarch);
regnum = gdbarch_num_cooked_regs (gdbarch);
- gdb_printf (" %-11s %3s\n", "Name", "Nr");
+ struct ui_out *uiout = current_uiout;
+ ui_out_emit_table table_emitter (uiout, 2, -1, "user-registers");
+ uiout->table_header (11, ui_left, "name", "Name");
+ uiout->table_header (3, ui_right, "number", "Nr");
+
+ uiout->table_body ();
for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum)
- gdb_printf (" %-11s %3d\n", reg->name, regnum);
+ {
+ ui_out_emit_tuple tuple_emitter (uiout, nullptr);
+ uiout->field_string ("name", reg->name);
+ uiout->field_signed ("number", regnum);
+ uiout->text ("\n");
+ }
}
void _initialize_user_regs ();