diff options
author | Tom Tromey <tom@tromey.com> | 2024-10-03 16:51:38 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-10-08 17:07:37 -0600 |
commit | a750186ec5f67e356a64f73334af0073c83fc533 (patch) | |
tree | 77f05853a57986117970038c9dcc6e28391a449c | |
parent | 57f5c841c33c49583338048d06a4dfd5cefd7e40 (diff) | |
download | binutils-a750186ec5f67e356a64f73334af0073c83fc533.zip binutils-a750186ec5f67e356a64f73334af0073c83fc533.tar.gz binutils-a750186ec5f67e356a64f73334af0073c83fc533.tar.bz2 |
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>
-rw-r--r-- | gdb/testsuite/gdb.base/completion.exp | 2 | ||||
-rw-r--r-- | gdb/user-regs.c | 14 |
2 files changed, 13 insertions, 3 deletions
diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 4a0a373..57b4d1c 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 } diff --git a/gdb/user-regs.c b/gdb/user-regs.c index ac04f63..2ace46e 100644 --- a/gdb/user-regs.c +++ b/gdb/user-regs.c @@ -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 (); |