Use ui-out tables in "maint print user-regs"

This changes "maint print user-regs" to use ui-out tables rather than
printfs.

Approved-By: Andrew Burgess <aburgess@redhat.com>
This commit is contained in:
Tom Tromey 2024-10-03 16:51:38 -06:00
parent 57f5c841c3
commit a750186ec5
2 changed files with 13 additions and 3 deletions

View File

@ -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
}

View File

@ -222,9 +222,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");
ui_out_emit_table emitter (current_uiout, 2, -1, "UserRegs");
current_uiout->table_header (11, ui_left, "name", "Name");
current_uiout->table_header (3, ui_left, "regnum", "Nr");
current_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 (current_uiout, nullptr);
current_uiout->field_string ("name", reg->name);
current_uiout->field_signed ("regnum", regnum);
current_uiout->text ("\n");
}
}
void _initialize_user_regs ();