From: "Maciej W. Rozycki" <macro@mips.com>
To: gdb-patches@sourceware.org
Cc: David Ung <davidu@mips.com>, "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: infcmd.c: Output user registers correctly
Date: Wed, 24 Oct 2007 16:22:00 -0000 [thread overview]
Message-ID: <Pine.LNX.4.61.0710241643290.1987@perivale.mips.com> (raw)
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,
next reply other threads:[~2007-10-24 16:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-10-24 16:22 Maciej W. Rozycki [this message]
2007-10-24 16:47 ` Daniel Jacobowitz
2007-10-24 18:12 ` Maciej W. Rozycki
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.0710241643290.1987@perivale.mips.com \
--to=macro@mips.com \
--cc=davidu@mips.com \
--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