Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Maciej W. Rozycki" <macro@mips.com>
To: Daniel Jacobowitz <drow@false.org>
Cc: gdb-patches@sourceware.org, David Ung <davidu@mips.com>,
	     "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: infcmd.c: Output user registers correctly
Date: Wed, 24 Oct 2007 18:12:00 -0000	[thread overview]
Message-ID: <Pine.LNX.4.61.0710241843560.1987@perivale.mips.com> (raw)
In-Reply-To: <20071024164221.GA4025@caradoc.them.org>

On Wed, 24 Oct 2007, Daniel Jacobowitz wrote:

> On Wed, Oct 24, 2007 at 04:59:47PM +0100, Maciej W. Rozycki wrote:
> > 2007-10-24  David Ung  <davidu@mips.com>
> >             Maciej W. Rozycki  <macro@mips.com>
> > 
> > 	* infcmd.c (registers_info): Check for a user register before
> > 	calling target's gdbarch_print_registers_info().  If found to be
> > 	so, extract the implicit value of user register and call
> > 	print_scalar_formatted().
> > 	* value.h (value_of_user_reg): Add prototype.
> > 
> >  OK to apply?
> 
> OK, thanks.  This also fixes PR exp/1926.  There may be another one
> too, but that's the only one I can find at present.

 I have just checked and value_of_user_reg() is already declared in 
user-regs.h.  I am inclined to commit this change instead so as to avoid 
having prototypes in two different places.  OK?

2007-10-24  David Ung  <davidu@mips.com>
            Maciej W. Rozycki  <macro@mips.com>

	PR exp/1926
	* infcmd.c (registers_info): Check for a user register before
	calling target's gdbarch_print_registers_info().  If found to be
	so, extract the implicit value of user register and call
	print_scalar_formatted().
	* Makefile.in: (infcmd.o): Add $(user_regs_h).

  Maciej

Index: binutils-quilt/src/gdb/infcmd.c
===================================================================
--- binutils-quilt.orig/src/gdb/infcmd.c	2007-10-24 16:50:07.000000000 +0100
+++ binutils-quilt/src/gdb/infcmd.c	2007-10-24 18:51:16.000000000 +0100
@@ -47,6 +47,7 @@
 #include "gdb_assert.h"
 #include "observer.h"
 #include "target-descriptions.h"
+#include "user-regs.h"
 
 /* Functions exported for general use, in inferior.h: */
 
@@ -1705,21 +1706,35 @@
       while ((*addr_exp) != '\0' && !isspace ((*addr_exp)))
 	addr_exp++;
       end = addr_exp;
-      
+
       /* Figure out what we've found and display it.  */
 
       /* A register name?  */
       {
-	int regnum = frame_map_name_to_regnum (frame,
-					       start, end - start);
+	int regnum = frame_map_name_to_regnum (frame, start, end - start);
 	if (regnum >= 0)
 	  {
-	    gdbarch_print_registers_info (gdbarch, gdb_stdout,
-					  frame, regnum, fpregs);
+	    /* User registers lie completely outside of the range of
+	       normal registers.  Catch them early so that the target
+	       never sees them.  */
+	    if (regnum >= gdbarch_num_regs (gdbarch)
+			  + gdbarch_num_pseudo_regs (gdbarch))
+	      {
+		struct value *val = value_of_user_reg (regnum, frame);
+
+		printf_filtered ("%s: ", start);
+		print_scalar_formatted (value_contents (val),
+					check_typedef (value_type (val)),
+					'x', 0, gdb_stdout);
+		printf_filtered ("\n");
+	      }
+	    else
+	      gdbarch_print_registers_info (gdbarch, gdb_stdout,
+					    frame, regnum, fpregs);
 	    continue;
 	  }
       }
-	
+
       /* A register number?  (how portable is this one?).  */
       {
 	char *endptr;
Index: binutils-quilt/src/gdb/Makefile.in
===================================================================
--- binutils-quilt.orig/src/gdb/Makefile.in	2007-10-24 17:01:15.000000000 +0100
+++ binutils-quilt/src/gdb/Makefile.in	2007-10-24 18:50:03.000000000 +0100
@@ -2204,7 +2204,8 @@
 	$(symfile_h) $(gdbcore_h) $(target_h) $(language_h) $(symfile_h) \
 	$(objfiles_h) $(completer_h) $(ui_out_h) $(event_top_h) \
 	$(parser_defs_h) $(regcache_h) $(reggroups_h) $(block_h) \
-	$(solib_h) $(gdb_assert_h) $(observer_h) $(target_descriptions_h)
+	$(solib_h) $(gdb_assert_h) $(observer_h) $(target_descriptions_h) \
+	$(user_regs_h)
 inf-loop.o: inf-loop.c $(defs_h) $(inferior_h) $(target_h) $(event_loop_h) \
 	$(event_top_h) $(inf_loop_h) $(remote_h) $(exceptions_h)
 inflow.o: inflow.c $(defs_h) $(frame_h) $(inferior_h) $(command_h) \


  reply	other threads:[~2007-10-24 18:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-24 16:22 Maciej W. Rozycki
2007-10-24 16:47 ` Daniel Jacobowitz
2007-10-24 18:12   ` Maciej W. Rozycki [this message]
2007-10-24 18:42     ` Daniel Jacobowitz

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=Pine.LNX.4.61.0710241843560.1987@perivale.mips.com \
    --to=macro@mips.com \
    --cc=davidu@mips.com \
    --cc=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    --cc=macro@linux-mips.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