2004-08-04 Andrew Cagney <cagney@gnu.org>
Jim Blandy <jimb@redhat.com> * sim_callbacks.h (simulator): Declare. * Makefile.in (gdb-sim.o): New rule. (MAIN_SRC, GDB_OBJ): Add gdb-sim.o, gdb-sim.c. (DEFS_H): Delete. (GDB_SIM_PPC_H): Define. * gdb-sim.c: New file. * sim_calls.c: Do not include "defs.h". (simulator): Drop static. (sim_store_register, sim_fetch_register): Delete.
This commit is contained in:
parent
0a8490ad3a
commit
91cd10427a
5 changed files with 1318 additions and 75 deletions
|
@ -1,3 +1,16 @@
|
|||
2004-08-04 Andrew Cagney <cagney@gnu.org>
|
||||
Jim Blandy <jimb@redhat.com>
|
||||
|
||||
* sim_callbacks.h (simulator): Declare.
|
||||
* Makefile.in (gdb-sim.o): New rule.
|
||||
(MAIN_SRC, GDB_OBJ): Add gdb-sim.o, gdb-sim.c.
|
||||
(DEFS_H): Delete.
|
||||
(GDB_SIM_PPC_H): Define.
|
||||
* gdb-sim.c: New file.
|
||||
* sim_calls.c: Do not include "defs.h".
|
||||
(simulator): Drop static.
|
||||
(sim_store_register, sim_fetch_register): Delete.
|
||||
|
||||
2004-08-04 Andrew Cagney <cagney@gnu.org>
|
||||
|
||||
* Back out accidently committed change.
|
||||
|
|
|
@ -172,9 +172,9 @@ all: run $(TARGETLIB) $(GDB_OBJ)
|
|||
# Headers outside sim/ppc.
|
||||
ANSIDECL_H = $(srcroot)/include/ansidecl.h
|
||||
BFD_H = ../../bfd/bfd.h
|
||||
DEFS_H = $(srcroot)/gdb/defs.h
|
||||
GDB_CALLBACK_H = $(srcroot)/include/gdb/callback.h
|
||||
GDB_REMOTE_SIM_H = $(srcroot)/include/gdb/remote-sim.h
|
||||
GDB_SIM_PPC_H = $(srcroot)/include/gdb/sim-ppc.h
|
||||
COMMON_SIM_BASE_H = $(srcroot)/sim/common/sim-base.h
|
||||
COMMON_SIM_BASICS_H = $(srcroot)/sim/common/sim-basics.h
|
||||
COMMON_SIM_FPU_H = $(srcroot)/sim/common/sim-fpu.h
|
||||
|
@ -498,6 +498,7 @@ LIB_SRC = \
|
|||
|
||||
MAIN_SRC = \
|
||||
main.c \
|
||||
gdb-sim.c \
|
||||
sim_calls.c
|
||||
|
||||
|
||||
|
@ -539,7 +540,7 @@ LIB_OBJ = \
|
|||
options.o
|
||||
|
||||
|
||||
GDB_OBJ = sim_calls.o @sim_callback@
|
||||
GDB_OBJ = gdb-sim.o sim_calls.o @sim_callback@
|
||||
|
||||
HW_SRC = @sim_hw_src@
|
||||
HW_OBJ = @sim_hw_obj@
|
||||
|
@ -599,6 +600,8 @@ events.o: events.c $(BASICS_H) $(EVENTS_H)
|
|||
|
||||
sim_calls.o: sim_calls.c $(PSIM_H) $(OPTIONS_H) $(DEFS_H) $(BFD_H) $(GDB_CALLBACK_H) $(GDB_REMOTE_SIM_H)
|
||||
|
||||
gdb-sim.o: gdb-sim.c $(PSIM_H) $(OPTIONS_H) $(REGISTERS_H) $(GDB_REMOTE_SIM_H) $(GDB_SIM_PPC_H) $(SIM_CALLBACK_H)
|
||||
|
||||
spreg.o: spreg.c $(BASICS_H) $(SPREG_H)
|
||||
|
||||
main.o: main.c $(PSIM_H) $(OPTIONS_H) $(DEVICE_H) $(EVENTS_H) $(BFD_H) $(GDB_CALLBACK_H) $(GDB_REMOTE_SIM_H)
|
||||
|
|
1295
sim/ppc/gdb-sim.c
Normal file
1295
sim/ppc/gdb-sim.c
Normal file
File diff suppressed because it is too large
Load diff
|
@ -103,6 +103,10 @@ void sim_io_flush_stdoutput
|
|||
(void);
|
||||
|
||||
|
||||
/* Simulator instance. */
|
||||
extern psim *simulator;
|
||||
|
||||
|
||||
/* Memory management with an allocator that clears memory before use. */
|
||||
|
||||
void *zalloc
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#include "defs.h"
|
||||
#include "bfd.h"
|
||||
#include "gdb/callback.h"
|
||||
#include "gdb/remote-sim.h"
|
||||
|
@ -55,33 +54,10 @@ static int poll_quit_count = POLL_QUIT_INTERVAL;
|
|||
|
||||
/* Structures used by the simulator, for gdb just have static structures */
|
||||
|
||||
static psim *simulator;
|
||||
psim *simulator;
|
||||
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,
|
||||
|
@ -176,54 +152,6 @@ sim_write (SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length)
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sim_fetch_register (SIM_DESC sd, int regno, unsigned char *buf, int length)
|
||||
{
|
||||
const char *regname;
|
||||
|
||||
if (simulator == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* 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;
|
||||
|
||||
TRACE(trace_gdb, ("sim_fetch_register(regno=%d(%s), buf=0x%lx)\n",
|
||||
regno, regname, (long)buf));
|
||||
return psim_read_register(simulator, MAX_NR_PROCESSORS,
|
||||
buf, regname, raw_transfer);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
sim_store_register (SIM_DESC sd, int regno, unsigned char *buf, int length)
|
||||
{
|
||||
const char *regname;
|
||||
|
||||
if (simulator == NULL)
|
||||
return 0;
|
||||
|
||||
/* See comments in sim_fetch_register, above. */
|
||||
regname = gdbarch_register_name (current_gdbarch, regno);
|
||||
if (! regname || regname[0] == '\0')
|
||||
return -1;
|
||||
|
||||
TRACE(trace_gdb, ("sim_store_register(regno=%d(%s), buf=0x%lx)\n",
|
||||
regno, regname, (long)buf));
|
||||
return psim_write_register(simulator, MAX_NR_PROCESSORS,
|
||||
buf, regname, raw_transfer);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
sim_info (SIM_DESC sd, int verbose)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue