This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[RFA] sim/ppc/sim_calls.c: fix broken REGISTER_NAME call
- To: gdb-patches at sourceware dot cygnus dot com
- Subject: [RFA] sim/ppc/sim_calls.c: fix broken REGISTER_NAME call
- From: Michael Elizabeth Chastain <chastain at cygnus dot com>
- Date: Wed, 6 Dec 2000 09:47:49 -0800
- Cc: jimb at cygnus dot com
I received this patch from Jim Blandy last week.
In the powerpc-unknown-eabi toolchain (and perhaps in others), gdb has
a ppc simulator linked in. The linked-in simulator needs to convert
register numbers to names in some places, and calls REGISTER_NAME
to accomplish this.
Now that the ppc is multi-arched, REGISTER_NAME does not work in the
simulator (specifically, the sim code does not see gdb's "config.h"
file, so it does not get the right value of GDB_MULTI_ARCH). This patch
changes the ppc simulator to call gdbarch_register_name directly.
Before applying this patch, I get a lot of these:
gdb-internal-error: legacy_register_name: called.
Applying this patch fixes these errors, and does not appear to introduce
any other problems.
OK to apply?
Michael Elizabeth Chastain
<chastain@redhat.com>
"love without fear"
---
2000-11-15 Jim Blandy <jimb@redhat.com>
* sim_calls.c: Doc fix.
(sim_fetch_register, sim_store_register): Call
gdbarch_register_name directly, instead of going through
REGISTER_NAME macro.
Index: sim/ppc/sim_calls.c
===================================================================
RCS file: /cvs/cvsfiles/devo/sim/ppc/sim_calls.c,v
retrieving revision 1.45
retrieving revision 1.45.98.1
diff -c -r1.45 -r1.45.98.1
*** sim/ppc/sim_calls.c 2000/03/02 09:24:26 1.45
--- sim/ppc/sim_calls.c 2000/11/15 18:41:28 1.45.98.1
***************
*** 59,81 ****
static device *root_device;
static host_callback *callbacks;
! /* We use GDB's reg_names array to map GDB register numbers onto
! names, which we can then look up in the register table.
! We used to just use the REGISTER_NAMES macro, from GDB's
! target-dependent header files. That was kind of nice, because it
! meant that libsim.a had only a compile-time dependency on GDB;
! using reg_names directly means that there are now link-time and
! run-time dependencies too.
!
! However, the GDB PPC back-end now modifies the reg_names array when
! the user runs the `set processor' command, which affects the
! meanings of the register numbers. So the sim needs to see the
! register names GDB is actually using.
- Perhaps the host_callback structure could contain a pointer to the
- register name table; that would be cleaner. */
-
SIM_DESC
sim_open (SIM_OPEN_KIND kind,
host_callback *callback,
--- 59,87 ----
static device *root_device;
static host_callback *callbacks;
! /* We use GDB's gdbarch_register_name function to map GDB register
! numbers onto names, which we can then look up in the register
! table. Since the `set architecture' command can select a new
! processor variant at run-time, the meanings of the register numbers
! can change, so we need to make sure the sim uses the same
! name/number mapping that GDB uses.
!
! (We don't use the REGISTER_NAME macro, which is a wrapper for
! gdbarch_register_name. We #include GDB's "defs.h", which tries to
! #include GDB's "config.h", but gets ours instead, and REGISTER_NAME
! ends up not getting defined. Simpler to just use
! gdbarch_register_name directly.)
!
! We used to just use the REGISTER_NAMES macro from GDB's
! target-dependent header files, which expanded into an initializer
! for an array of strings. That was kind of nice, because it meant
! that libsim.a had only a compile-time dependency on GDB; using
! gdbarch_register_name directly means that there are now link-time
! and run-time dependencies too.
! Perhaps the host_callback structure could provide a function for
! retrieving register names; that would be cleaner. */
SIM_DESC
sim_open (SIM_OPEN_KIND kind,
host_callback *callback,
***************
*** 181,193 ****
}
/* GDB will sometimes ask for the contents of a register named "";
! we ignore such requests, and leave garbage in *BUF. In
! REG_NAMES, the empty string means "the register with this
! number is not present in the currently selected architecture
! variant." That's following the kludge we're using for the MIPS
! processors. But there are loops that just walk through the
! entire list of names and try to get everything. */
! regname = REGISTER_NAME (regno);
if (! regname || regname[0] == '\0')
return -1;
--- 187,199 ----
}
/* GDB will sometimes ask for the contents of a register named "";
! we ignore such requests, and leave garbage in *BUF. In GDB
! terms, the empty string means "the register with this number is
! not present in the currently selected architecture variant."
! That's following the kludge we're using for the MIPS processors.
! But there are loops that just walk through the entire list of
! names and try to get everything. */
! regname = gdbarch_register_name (current_gdbarch, regno);
if (! regname || regname[0] == '\0')
return -1;
***************
*** 208,214 ****
return 0;
/* See comments in sim_fetch_register, above. */
! regname = REGISTER_NAME (regno);
if (! regname || regname[0] == '\0')
return -1;
--- 214,220 ----
return 0;
/* See comments in sim_fetch_register, above. */
! regname = gdbarch_register_name (current_gdbarch, regno);
if (! regname || regname[0] == '\0')
return -1;