From: Andreas Arnez <arnez@linux.vnet.ibm.com>
To: gdb-patches@sourceware.org
Subject: [PATCH v4 1/2] Add new GDB command "maint print user-registers"
Date: Thu, 11 Dec 2014 11:49:00 -0000 [thread overview]
Message-ID: <1418298589-23120-2-git-send-email-arnez@linux.vnet.ibm.com> (raw)
In-Reply-To: <1418298589-23120-1-git-send-email-arnez@linux.vnet.ibm.com>
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/NEWS | 3 +++
gdb/doc/gdb.texinfo | 12 ++++++++++++
gdb/user-regs.c | 24 ++++++++++++++++++++++++
3 files changed, 39 insertions(+)
diff --git a/gdb/NEWS b/gdb/NEWS
index 6a2cb9b..a47dfbf 100644
--- 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
diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo
index 670c369..4986a68 100644
--- a/gdb/doc/gdb.texinfo
+++ b/gdb/doc/gdb.texinfo
@@ -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}]
diff --git a/gdb/user-regs.c b/gdb/user-regs.c
index 35d64ec..adaa959 100644
--- a/gdb/user-regs.c
+++ b/gdb/user-regs.c
@@ -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);
}
--
1.8.4.2
next prev parent reply other threads:[~2014-12-11 11:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-11 11:49 [PATCH v4 0/2] Provide useful completer for "info registers" Andreas Arnez
2014-12-11 11:49 ` [PATCH v4 2/2] Provide " Andreas Arnez
2014-12-12 13:20 ` Pedro Alves
2014-12-12 15:20 ` Andreas Arnez
2014-12-12 15:30 ` Pedro Alves
2014-12-12 17:45 ` Doug Evans
2014-12-12 19:04 ` Andreas Arnez
2014-12-15 12:41 ` Pedro Alves
2014-12-11 11:49 ` Andreas Arnez [this message]
2014-12-12 13:19 ` [PATCH v4 1/2] Add new GDB command "maint print user-registers" Pedro Alves
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1418298589-23120-2-git-send-email-arnez@linux.vnet.ibm.com \
--to=arnez@linux.vnet.ibm.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox