From patchwork Wed Dec 10 17:22:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Arnez X-Patchwork-Id: 4145 Received: (qmail 5275 invoked by alias); 10 Dec 2014 17:22:46 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 5264 invoked by uid 89); 10 Dec 2014 17:22:46 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: e06smtp14.uk.ibm.com Received: from e06smtp14.uk.ibm.com (HELO e06smtp14.uk.ibm.com) (195.75.94.110) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES256-SHA encrypted) ESMTPS; Wed, 10 Dec 2014 17:22:45 +0000 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Dec 2014 17:22:41 -0000 Received: from d06dlp03.portsmouth.uk.ibm.com (9.149.20.15) by e06smtp14.uk.ibm.com (192.168.101.144) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 10 Dec 2014 17:22:40 -0000 Received: from b06cxnps4074.portsmouth.uk.ibm.com (d06relay11.portsmouth.uk.ibm.com [9.149.109.196]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id BEF1A1B0804B for ; Wed, 10 Dec 2014 17:23:00 +0000 (GMT) Received: from d06av06.portsmouth.uk.ibm.com (d06av06.portsmouth.uk.ibm.com [9.149.37.217]) by b06cxnps4074.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id sBAHMdQO29622354 for ; Wed, 10 Dec 2014 17:22:39 GMT Received: from d06av06.portsmouth.uk.ibm.com (localhost [127.0.0.1]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id sBACJQNx005509 for ; Wed, 10 Dec 2014 07:19:26 -0500 Received: from br87z6lw.boeblingen.de.ibm.com (dyn-9-152-212-196.boeblingen.de.ibm.com [9.152.212.196]) by d06av06.portsmouth.uk.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id sBACJQP5005483 for ; Wed, 10 Dec 2014 07:19:26 -0500 From: Andreas Arnez To: gdb-patches@sourceware.org Subject: [PATCH v3 1/2] Add new GDB command "maint print user-registers" Date: Wed, 10 Dec 2014 18:22:38 +0100 Message-Id: <1418232159-15289-2-git-send-email-arnez@linux.vnet.ibm.com> In-Reply-To: <1418232159-15289-1-git-send-email-arnez@linux.vnet.ibm.com> References: <1418232159-15289-1-git-send-email-arnez@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 14121017-0017-0000-0000-000002291098 X-IsSubscribed: yes 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 "target.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 | 30 ++++++++++++++++++++++++++++++ 3 files changed, 45 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..c321605 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 ``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..84ecf3a 100644 --- a/gdb/user-regs.c +++ b/gdb/user-regs.c @@ -23,6 +23,8 @@ #include "user-regs.h" #include "gdbtypes.h" #include "frame.h" +#include "target.h" +#include "cli/cli-cmds.h" /* A table of user registers. @@ -215,10 +217,38 @@ 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; + struct gdb_user_regs *regs; + struct user_reg *reg; + int nr; + + if (!target_has_registers) + error (_("The program has no registers now.")); + + gdbarch = get_frame_arch (get_selected_frame (NULL)); + regs = gdbarch_data (gdbarch, user_regs_data); + nr = 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) + { + fprintf_unfiltered (gdb_stdout, "%3d %s\n", nr, reg->name); + nr++; + } +} + 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); }