From 25dda427ec9e074e0a258eb93c7cc811f0a85a9c Mon Sep 17 00:00:00 2001 From: Andreas Arnez Date: Tue, 16 Dec 2014 16:06:42 +0100 Subject: [PATCH] Fix indentation of "maint print user-registers" This fixes a failure of the test case "complete 'info registers '" in completion.exp on architectures where the user registers have numbers above 99. In that case the output of "maint print user-registers" was no longer indented, and the regexp in the test case failed to add them to the list of expected completion results. The fix also swaps the columns "Name" and "Nr", such that the indentation is always the same, and to be consistent with the output of "maint print registers". gdb/ChangeLog: * user-regs.c (maintenance_print_user_registers): Swap "Nr" and "Name" columns. Assure that the output is always indented. gdb/testsuite/ChangeLog: * gdb.base/completion.exp: Adjust to format changes of "maint print user-registers". --- gdb/ChangeLog | 5 +++++ gdb/testsuite/ChangeLog | 5 +++++ gdb/testsuite/gdb.base/completion.exp | 9 +++------ gdb/user-regs.c | 4 ++-- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 2fadb8cf394..7c2e6f35d6f 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,8 @@ +2014-12-16 Andreas Arnez + + * user-regs.c (maintenance_print_user_registers): Swap "Nr" and + "Name" columns. Assure that the output is always indented. + 2014-12-16 Joel Brobecker * nat/linux-ptrace.h (PTRACE_O_EXITKILL): Define if not diff --git a/gdb/testsuite/ChangeLog b/gdb/testsuite/ChangeLog index ece258f4164..4be1f71e099 100644 --- a/gdb/testsuite/ChangeLog +++ b/gdb/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2014-12-16 Andreas Arnez + + * gdb.base/completion.exp: Adjust to format changes of "maint + print user-registers". + 2014-12-16 Catalin Udma PR server/17457 diff --git a/gdb/testsuite/gdb.base/completion.exp b/gdb/testsuite/gdb.base/completion.exp index 08e1a52d98d..9c79a29bf3e 100644 --- a/gdb/testsuite/gdb.base/completion.exp +++ b/gdb/testsuite/gdb.base/completion.exp @@ -145,17 +145,14 @@ set regs_output [capture_command_output "mt print registers" \ append regs_output "\n" append regs_output [capture_command_output "mt print reggroups" \ ".*Group.*Type\[^\n]*\n"] +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] { lappend all_regs $reg } -set regs_output [capture_command_output "mt print user-registers" \ - ".*Nr.*Name\[^\n]*\n"] -foreach {- reg} [regexp -all -inline -line {^\s+\d+\s+(\w+)} $regs_output] { - lappend all_regs $reg -} - set all_regs [join [lsort -unique $all_regs]] # ... and then compare them to the completion of "info registers". diff --git a/gdb/user-regs.c b/gdb/user-regs.c index adaa959a41c..6cdea16d853 100644 --- a/gdb/user-regs.c +++ b/gdb/user-regs.c @@ -229,9 +229,9 @@ maintenance_print_user_registers (char *args, int from_tty) regs = gdbarch_data (gdbarch, user_regs_data); regnum = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch); - fprintf_unfiltered (gdb_stdout, " Nr Name\n"); + fprintf_unfiltered (gdb_stdout, " %-11s %3s\n", "Name", "Nr"); for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum) - fprintf_unfiltered (gdb_stdout, "%3d %s\n", regnum, reg->name); + fprintf_unfiltered (gdb_stdout, " %-11s %3d\n", reg->name, regnum); } extern initialize_file_ftype _initialize_user_regs; /* -Wmissing-prototypes */ -- 2.30.2