This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
infcmd.c: Output user registers correctly
- From: "Maciej W. Rozycki" <macro at mips dot com>
- To: gdb-patches at sourceware dot org
- Cc: David Ung <davidu at mips dot com>, "Maciej W. Rozycki" <macro at linux-mips dot org>
- Date: Wed, 24 Oct 2007 16:59:47 +0100 (BST)
- Subject: infcmd.c: Output user registers correctly
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,