This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[PATCH]: Fixes for pseudo regs support
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [PATCH]: Fixes for pseudo regs support
- From: Stephane Carrez <Stephane dot Carrez at worldnet dot fr>
- Date: Fri, 25 Aug 2000 01:49:59 +0200
Hi!
Andrew Cagney wrote:
> Could I encourage you to persue this alternative. It isn't that I
> have something against extra multi-arch entries (ok I do but not in this
> case :-) but rather that the problem you're describing (registers living
> in memory space) is far more common than you might think. Off hand, I
> can think of at least three targets that have an identical problem. In
> those cases people ended up shoving hacks into either/and SIM and the
> target stub :-(.
Ok.
After a close look of the problem, it's not that big or complex.
I assume that:
- Machine dependent parts need not be changed: they must know how
to handle pseudo registers (well, only the sh does that).
- The remote, monitor, sim stubs need not be changed because they
only deal with real hard registers. They are not aware at all
of the existence of pseudo registers.
Now, what remains is in fact the following places:
- The stabs reader performs checks about the validity of the register
number. A pseudo register can be referenced in stabs.
- The frame_info structure must save the pseudo registers.
The pseudo register (which lies in memory) can be saved by GCC
at entry point of a function.
- When listing registers or the frame we must report the pseudo registers
as well.
There is nothing to do in regcache.c
I've checked that on 68hc11 gdb (in multi-arch mode).
Stephane
2000-08-25 Stephane Carrez <Stephane.Carrez@worldnet.fr>
* stabsread.c (define_symbol): A parameter ('R'), a local ('r'),
or a reference ('a') can be in a pseudo register.
* infcmd.c (do_registers_info): Must take into account the pseudo
registers to print their value.
(registers_info): Likewise.
* stack.c (frame_info): Likewise.
* frame.h (SIZEOF_FRAME_SAVED_REGS): Save the pseudo registers.
diff -Nrup --exclude-from=gdb-exclude.lst /src/gnu/cygnus/gdb/gdb/frame.h gdb/gdb/frame.h
--- /src/gnu/cygnus/gdb/gdb/frame.h Thu Jun 1 00:40:21 2000
+++ gdb/gdb/frame.h Fri Aug 25 00:52:19 2000
@@ -80,7 +80,7 @@ struct frame_info
address where the sp was saved. */
/* Allocated by frame_saved_regs_zalloc () which is called /
initialized by FRAME_INIT_SAVED_REGS(). */
- CORE_ADDR *saved_regs; /*NUM_REGS */
+ CORE_ADDR *saved_regs; /*NUM_REGS + NUM_PSEUDO_REGS */
#ifdef EXTRA_FRAME_INFO
/* XXXX - deprecated */
@@ -116,7 +116,8 @@ enum print_what
/* Allocate additional space for appendices to a struct frame_info. */
#ifndef SIZEOF_FRAME_SAVED_REGS
-#define SIZEOF_FRAME_SAVED_REGS (sizeof (CORE_ADDR) * (NUM_REGS))
+#define SIZEOF_FRAME_SAVED_REGS \
+ (sizeof (CORE_ADDR) * (NUM_REGS+NUM_PSEUDO_REGS))
#endif
extern void *frame_obstack_alloc (unsigned long size);
extern void frame_saved_regs_zalloc (struct frame_info *);
diff -Nrup --exclude-from=gdb-exclude.lst /src/gnu/cygnus/gdb/gdb/infcmd.c gdb/gdb/infcmd.c
--- /src/gnu/cygnus/gdb/gdb/infcmd.c Tue Aug 1 22:50:44 2000
+++ gdb/gdb/infcmd.c Fri Aug 25 00:37:39 2000
@@ -1445,7 +1445,7 @@ void
do_registers_info (int regnum, int fpregs)
{
register int i;
- int numregs = ARCH_NUM_REGS;
+ int numregs = ARCH_NUM_REGS + NUM_PSEUDO_REGS;
for (i = 0; i < numregs; i++)
{
@@ -1569,7 +1569,7 @@ registers_info (char *addr_exp, int fpre
end = addr_exp;
while (*end != '\0' && *end != ' ' && *end != '\t')
++end;
- numregs = ARCH_NUM_REGS;
+ numregs = ARCH_NUM_REGS + NUM_PSEUDO_REGS;
regnum = target_map_name_to_register (addr_exp, end - addr_exp);
if (regnum >= 0)
diff -Nrup --exclude-from=gdb-exclude.lst /src/gnu/cygnus/gdb/gdb/stabsread.c gdb/gdb/stabsread.c
--- /src/gnu/cygnus/gdb/gdb/stabsread.c Tue Aug 1 22:55:20 2000
+++ gdb/gdb/stabsread.c Fri Aug 25 00:45:09 2000
@@ -1804,9 +1804,10 @@ define_symbol (CORE_ADDR valu, char *str
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGPARM;
SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
- if (SYMBOL_VALUE (sym) >= NUM_REGS)
+ if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
{
- complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
+ complain (®_value_complaint, SYMBOL_VALUE (sym),
+ NUM_REGS + NUM_PSEUDO_REGS,
SYMBOL_SOURCE_NAME (sym));
SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
}
@@ -1819,9 +1820,10 @@ define_symbol (CORE_ADDR valu, char *str
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGISTER;
SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
- if (SYMBOL_VALUE (sym) >= NUM_REGS)
+ if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
{
- complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
+ complain (®_value_complaint, SYMBOL_VALUE (sym),
+ NUM_REGS + NUM_PSEUDO_REGS,
SYMBOL_SOURCE_NAME (sym));
SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
}
@@ -2047,9 +2049,10 @@ define_symbol (CORE_ADDR valu, char *str
SYMBOL_TYPE (sym) = read_type (&p, objfile);
SYMBOL_CLASS (sym) = LOC_REGPARM_ADDR;
SYMBOL_VALUE (sym) = STAB_REG_TO_REGNUM (valu);
- if (SYMBOL_VALUE (sym) >= NUM_REGS)
+ if (SYMBOL_VALUE (sym) >= NUM_REGS + NUM_PSEUDO_REGS)
{
- complain (®_value_complaint, SYMBOL_VALUE (sym), NUM_REGS,
+ complain (®_value_complaint, SYMBOL_VALUE (sym),
+ NUM_REGS + NUM_PSEUDO_REGS,
SYMBOL_SOURCE_NAME (sym));
SYMBOL_VALUE (sym) = SP_REGNUM; /* Known safe, though useless */
}
diff -Nrup --exclude-from=gdb-exclude.lst /src/gnu/cygnus/gdb/gdb/stack.c gdb/gdb/stack.c
--- /src/gnu/cygnus/gdb/gdb/stack.c Tue Aug 1 22:55:24 2000
+++ gdb/gdb/stack.c Fri Aug 25 00:58:43 2000
@@ -1003,7 +1003,7 @@ frame_info (char *addr_exp, int from_tty
print_address_numeric (fi->saved_regs[SP_REGNUM], 1, gdb_stdout);
printf_filtered ("\n");
count = 0;
- numregs = ARCH_NUM_REGS;
+ numregs = ARCH_NUM_REGS + NUM_PSEUDO_REGS;
for (i = 0; i < numregs; i++)
if (fi->saved_regs[i] && i != SP_REGNUM)
{