* infcmd.c: Output user registers correctly
@ 2007-10-24 16:22 Maciej W. Rozycki
2007-10-24 16:47 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Maciej W. Rozycki @ 2007-10-24 16:22 UTC (permalink / raw)
To: gdb-patches; +Cc: David Ung, Maciej W. Rozycki
Hello,
We have a problem, seen at least for the MIPS target, with user
registers. If one is requested with "info registers", an assertion
failure happens. For example (with GNU sim):
(gdb) info registers
zero at v0 v1 a0 a1 a2 a3
R0 00000000 00000000 ffffffff ffffffff 00000000 807fffe0 807fffe8 00000000
t0 t1 t2 t3 t4 t5 t6 t7
R8 800287a4 80000000 aaaa5555 00000000 ff0055aa 00000000 00000000 00000000
s0 s1 s2 s3 s4 s5 s6 s7
R16 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
t8 t9 k0 k1 gp sp s8 ra
R24 00000000 00000000 00000000 00000000 80030e80 807fffa0 807fffa0 80020164
sr lo hi bad cause pc
20000000 00000000 00000000 00000000 00000000 80020284
fsr fir
00000000 00000000
(gdb) info registers $ta0
/n/bank/raid/macro/src7-mdi/combined/gdb/regcache.c:164: internal-error: register_type: Assertion `regnum >= 0 && regnum < descr->nr_cooked_registers' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) n
/n/bank/raid/macro/src7-mdi/combined/gdb/regcache.c:164: internal-error: register_type: Assertion `regnum >= 0 && regnum < descr->nr_cooked_registers' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Create a core file of GDB? (y or n) n
(gdb)
The "ta0" register is an alias for the "t4" register. With the fix below
I get:
(gdb) info registers $ta0
ta0: 0xff0055aa
(gdb)
Tested using the mipsisa32-sde-elf target, with the mips-sim-sde32/-EB
and mips-sim-sde32/-EL boards with no regressions.
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?
Maciej
12659.diff
Index: binutils-quilt/src/gdb/infcmd.c
===================================================================
--- binutils-quilt.orig/src/gdb/infcmd.c 2007-10-24 14:20:01.000000000 +0100
+++ binutils-quilt/src/gdb/infcmd.c 2007-10-24 16:16:09.000000000 +0100
@@ -1705,21 +1705,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/value.h
===================================================================
--- binutils-quilt.orig/src/gdb/value.h 2007-10-24 14:20:01.000000000 +0100
+++ binutils-quilt/src/gdb/value.h 2007-10-24 16:16:54.000000000 +0100
@@ -299,6 +299,8 @@
extern struct value *value_of_register (int regnum, struct frame_info *frame);
+extern struct value *value_of_user_reg (int regnum, struct frame_info *frame);
+
extern int symbol_read_needs_frame (struct symbol *);
extern struct value *read_var_value (struct symbol *var,
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: infcmd.c: Output user registers correctly
2007-10-24 16:22 infcmd.c: Output user registers correctly Maciej W. Rozycki
@ 2007-10-24 16:47 ` Daniel Jacobowitz
2007-10-24 18:12 ` Maciej W. Rozycki
0 siblings, 1 reply; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-10-24 16:47 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: gdb-patches, David Ung, Maciej W. Rozycki
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.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: infcmd.c: Output user registers correctly
2007-10-24 16:47 ` Daniel Jacobowitz
@ 2007-10-24 18:12 ` Maciej W. Rozycki
2007-10-24 18:42 ` Daniel Jacobowitz
0 siblings, 1 reply; 4+ messages in thread
From: Maciej W. Rozycki @ 2007-10-24 18:12 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: gdb-patches, David Ung, Maciej W. Rozycki
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) \
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: infcmd.c: Output user registers correctly
2007-10-24 18:12 ` Maciej W. Rozycki
@ 2007-10-24 18:42 ` Daniel Jacobowitz
0 siblings, 0 replies; 4+ messages in thread
From: Daniel Jacobowitz @ 2007-10-24 18:42 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: gdb-patches, David Ung, Maciej W. Rozycki
On Wed, Oct 24, 2007 at 07:07:39PM +0100, Maciej W. Rozycki wrote:
> 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?
I had been wondering about that... yes, this is OK.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-10-24 18:21 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-24 16:22 infcmd.c: Output user registers correctly Maciej W. Rozycki
2007-10-24 16:47 ` Daniel Jacobowitz
2007-10-24 18:12 ` Maciej W. Rozycki
2007-10-24 18:42 ` Daniel Jacobowitz
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox