Add new GDB command "maint print user-registers"
authorAndreas Arnez <arnez@linux.vnet.ibm.com>
Fri, 12 Dec 2014 16:11:22 +0000 (17:11 +0100)
committerAndreas Krebbel <krebbel@linux.vnet.ibm.com>
Fri, 12 Dec 2014 16:11:22 +0000 (17:11 +0100)
This adds a command for listing the "user" registers.  So far GDB
offered no means of determining the set of user registers and omitted
them from all other register listings.

gdb/ChangeLog:

* user-regs.c: Include "arch-utils.h", "command.h", and
"cli/cli-cmds.h".
(maintenance_print_user_registers): New.
(_initialize_user_regs): Register new "maint print user-registers"
subcommand.
* NEWS: Mention new GDB command "maint print user-registers".

gdb/doc/ChangeLog:

* gdb.texinfo: Document "maint print user-registers".

gdb/ChangeLog
gdb/NEWS
gdb/doc/ChangeLog
gdb/doc/gdb.texinfo
gdb/user-regs.c

index 1dc180a6f927bc0c264b211f2e2f561690141719..f757618dac841881f6d97784ea5ca041608bae3b 100644 (file)
@@ -1,3 +1,12 @@
+2014-12-12  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
+       * user-regs.c: Include "arch-utils.h", "command.h", and
+       "cli/cli-cmds.h".
+       (maintenance_print_user_registers): New.
+       (_initialize_user_regs): Register new "maint print user-registers"
+       subcommand.
+       * NEWS: Mention new GDB command "maint print user-registers".
+
 2014-12-12  Maciej W. Rozycki  <macro@codesourcery.com>
             Maciej W. Rozycki  <macro@mips.com>
             Pedro Alves  <pedro@codesourcery.com>
index 6a2cb9b548f7b86562f19c29d4cfaa5941b66f64..a47dfbf645ab932c2c5ea49cf5ab233fb0460c28 100644 (file)
--- a/gdb/NEWS
+++ b/gdb/NEWS
@@ -45,6 +45,9 @@ add-auto-load-scripts-directory directory
   Add entries to the list of directories from which to load auto-loaded
   scripts.
 
+maint print user-registers
+  List all currently available "user" registers.
+
 * On resume, GDB now always passes the signal the program had stopped
   for to the thread the signal was sent to, even if the user changed
   threads before resuming.  Previously GDB would often (but not
index 14b2e53c29f93ed98003bb774f6435f794ce75fa..b8152df282d6ba165fb81060e5941366937a5ea0 100644 (file)
@@ -1,3 +1,7 @@
+2014-12-12  Andreas Arnez  <arnez@linux.vnet.ibm.com>
+
+       * gdb.texinfo: Document "maint print user-registers".
+
 2014-12-08  Doug Evans  <dje@google.com>
 
        * python.texi (Objfiles In Python): Document Objfile.owner.
index 670c36998eaf7d71483caa2b0d9eacec7827b6a0..4986a687b3f50ab513c9c84ffc35630750fbcc6c 100644 (file)
@@ -10256,6 +10256,7 @@ the selected stack frame.  The @var{regname} may be any register name valid on
 the machine you are using, with or without the initial @samp{$}.
 @end table
 
+@anchor{standard registers}
 @cindex stack pointer register
 @cindex program counter register
 @cindex process status register
@@ -33435,6 +33436,17 @@ If @var{regexp} is specified, only print object files whose names
 match @var{regexp}.  For each object file, this command prints its name,
 address in memory, and all of its psymtabs and symtabs.
 
+@kindex maint print user-registers
+@cindex user registers
+@item maint print user-registers
+List all currently available @dfn{user registers}.  User registers
+typically provide alternate names for actual hardware registers.  They
+include the four ``standard'' registers @code{$fp}, @code{$pc},
+@code{$sp}, and @code{$ps}.  @xref{standard registers}.  User
+registers can be used in expressions in the same way as the canonical
+register names, but only the latter are listed by the @code{info
+registers} and @code{maint print registers} commands.
+
 @kindex maint print section-scripts
 @cindex info for known .debug_gdb_scripts-loaded scripts
 @item maint print section-scripts [@var{regexp}]
index 35d64eccb16c29a47dd36e14adcf20d78cd0ea56..adaa959a41c4671cafcd75e550e754975911cac8 100644 (file)
@@ -23,6 +23,9 @@
 #include "user-regs.h"
 #include "gdbtypes.h"
 #include "frame.h"
+#include "arch-utils.h"
+#include "command.h"
+#include "cli/cli-cmds.h"
 
 /* A table of user registers.
 
@@ -215,10 +218,31 @@ value_of_user_reg (int regnum, struct frame_info *frame)
   return reg->read (frame, reg->baton);
 }
 
+static void
+maintenance_print_user_registers (char *args, int from_tty)
+{
+  struct gdbarch *gdbarch = get_current_arch ();
+  struct gdb_user_regs *regs;
+  struct user_reg *reg;
+  int regnum;
+
+  regs = gdbarch_data (gdbarch, user_regs_data);
+  regnum = gdbarch_num_regs (gdbarch) + gdbarch_num_pseudo_regs (gdbarch);
+
+  fprintf_unfiltered (gdb_stdout, " Nr  Name\n");
+  for (reg = regs->first; reg != NULL; reg = reg->next, ++regnum)
+    fprintf_unfiltered (gdb_stdout, "%3d  %s\n", regnum, reg->name);
+}
+
 extern initialize_file_ftype _initialize_user_regs; /* -Wmissing-prototypes */
 
 void
 _initialize_user_regs (void)
 {
   user_regs_data = gdbarch_data_register_post_init (user_regs_init);
+
+  add_cmd ("user-registers", class_maintenance,
+          maintenance_print_user_registers,
+          _("List the names of the current user registers.\n"),
+          &maintenanceprintlist);
 }
This page took 0.054523 seconds and 4 git commands to generate.