From 28954a6eb339de75de8dea3373d4d56e9f85d197 Mon Sep 17 00:00:00 2001 From: Mark Alexander Date: Sat, 9 Aug 1997 04:49:48 +0000 Subject: [PATCH] start-sanitize-tic80 * config/tic80/tic80.mt: (GDBSERVER-DEPFILES, GDBSERVER_LIBS): Define for gdbserver. (SIM): Remove -lm to prevent make errors. * configure.tgt: add gdbserver to configdirs for tic80. end-sanitize-tic80 * gdbserver/utils.c (error): Change prototype to match defs.h. * gdbserver/low-sim.c: Change simulator calls to use new interface. * remote.c (remote_write_bytes): Include '$' at start of packet and checksum at end of packet in overhead calculation. --- gdb/ChangeLog | 13 +++++++++++ gdb/config/tic80/tic80.mt | 6 ++--- gdb/configure.tgt | 6 +++-- gdb/gdbserver/low-sim.c | 59 ++++++++++++++++++++++++++++++++--------------- 4 files changed, 60 insertions(+), 24 deletions(-) diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e3d29ae..bf42689 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,16 @@ +Fri Aug 8 21:35:44 1997 Mark Alexander + +start-sanitize-tic80 + * config/tic80/tic80.mt: + (GDBSERVER-DEPFILES, GDBSERVER_LIBS): Define for gdbserver. + (SIM): Remove -lm to prevent make errors. + * configure.tgt: add gdbserver to configdirs for tic80. +end-sanitize-tic80 + * gdbserver/utils.c (error): Change prototype to match defs.h. + * gdbserver/low-sim.c: Change simulator calls to use new interface. + * remote.c (remote_write_bytes): Include '$' at start of packet + and checksum at end of packet in overhead calculation. + Fri Aug 8 15:59:24 1997 Ian Lance Taylor * ser-ocd.c: If _WIN32, include . diff --git a/gdb/config/tic80/tic80.mt b/gdb/config/tic80/tic80.mt index 84b6eb2..10be27e 100644 --- a/gdb/config/tic80/tic80.mt +++ b/gdb/config/tic80/tic80.mt @@ -1,7 +1,7 @@ # Target: TI TMS320C80 (MVP) processor TDEPFILES= tic80-tdep.o TM_FILE= tm-tic80.h - -# Disable using the simulator until it is ready. SIM_OBS = remote-sim.o -SIM = ../sim/tic80/libsim.a -lm +SIM = ../sim/tic80/libsim.a +GDBSERVER_DEPFILES= low-sim.o +GDBSERVER_LIBS = ../../sim/tic80/libsim.a ../../bfd/libbfd.a ../../libiberty/libiberty.a -lm diff --git a/gdb/configure.tgt b/gdb/configure.tgt index 9acc920..ae56df7 100644 --- a/gdb/configure.tgt +++ b/gdb/configure.tgt @@ -162,7 +162,8 @@ mips64*vr4300*-*-elf*) gdb_target=vr4300 ;; mips64*vr4100*el-*-elf*) gdb_target=vr4300el ;; mips64*vr4100*-*-elf*) gdb_target=vr4300 ;; mips64*vr5000*el-*-elf*) gdb_target=vr5000el ;; -mips64*vr5000*-*-elf*) gdb_target=vr5000 ;; +mips64*vr5000*-*-elf*) gdb_target=vr5000 + configdirs="${configdirs} gdbserver" ;; # start-sanitize-r5900 mips64*vr5900*el-*-elf*) gdb_target=vr5000el ;; mips64*vr5900*-*-elf*) gdb_target=vr5000 ;; @@ -254,7 +255,8 @@ sparc64-*-*) gdb_target=sp64 ;; tahoe-*-*) gdb_target=tahoe ;; # start-sanitize-tic80 -tic80-*-*) gdb_target=tic80 ;; +tic80-*-*) gdb_target=tic80 + configdirs="${configdirs} gdbserver" ;; # end-sanitize-tic80 vax-*-*) gdb_target=vax ;; diff --git a/gdb/gdbserver/low-sim.c b/gdb/gdbserver/low-sim.c index 3f4c69a..08d600a 100644 --- a/gdb/gdbserver/low-sim.c +++ b/gdb/gdbserver/low-sim.c @@ -23,12 +23,16 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "callback.h" /* GDB simulator callback interface */ #include "remote-sim.h" /* GDB simulator interface */ -extern host_callback default_callback; /* in callback.c */ +extern host_callback default_callback; /* in sim/common/callback.c */ char registers[REGISTER_BYTES]; int target_byte_order; /* used by simulator */ +/* We record the result of sim_open so we can pass it + back to the other sim_foo routines. */ +static SIM_DESC gdbsim_desc = 0; + /* This version of "load" should be usable for any simulator that does not support loading itself. */ @@ -77,12 +81,16 @@ generic_load (loadfile_bfd) } int -create_inferior (program, allargs) +create_inferior (program, argv) char *program; - char **allargs; + char **argv; { bfd *abfd; int pid = 0; +#ifdef TARGET_BYTE_ORDER_SELECTABLE + char **new_argv; + int nargs; +#endif abfd = bfd_openr (program, 0); if (!abfd) @@ -99,20 +107,33 @@ create_inferior (program, allargs) exit (1); } - /* This must be set before sim_open is called, because gdb assumes that - the simulator endianness is known immediately after the sim_open call. */ - target_byte_order = bfd_big_endian (abfd) ? 4321 : 1234; +#ifdef TARGET_BYTE_ORDER_SELECTABLE + /* Add "-E big" or "-E little" to the argument list depending on the + endianness of the program to be loaded. */ + for (nargs = 0; argv[nargs] != NULL; nargs++) /* count the args */ + ; + new_argv = alloca (sizeof (char *) * (nargs + 3)); /* allocate new args */ + for (nargs = 0; argv[nargs] != NULL; nargs++) /* copy old to new */ + new_argv[nargs] = argv[nargs]; + new_args[nargs] = "-E"; + new_args[nargs + 1] = bfd_big_endian (abfd) ? "big" : "little"; + new_args[nargs + 2] = NULL; + argv = new_args; +#endif - sim_set_callbacks (&default_callback); + /* Create an instance of the simulator. */ default_callback.init (&default_callback); + gdbsim_desc = sim_open (SIM_OPEN_STANDALONE, &default_callback, argv); + if (gdbsim_desc == 0) + exit (1); - /* Should concatenate args here. FIXME!! */ - sim_open (allargs[0]); - - /* Load program. */ - if (sim_load (allargs[0], 0) != 0) + /* Load the program into the simulator. */ + if (sim_load (gdbsim_desc, program, NULL, 0) == SIM_RC_FAIL) generic_load (abfd); + /* Create an inferior process in the simulator. This initializes SP. */ + sim_create_inferior (gdbsim_desc, argv, /* env */ NULL); + return pid; } @@ -121,7 +142,7 @@ create_inferior (program, allargs) void kill_inferior () { - sim_close (0); + sim_close (gdbsim_desc, 0); default_callback.shutdown (&default_callback); } @@ -131,7 +152,7 @@ static void fetch_register (regno) int regno; { - sim_fetch_register (regno, ®isters[REGISTER_BYTE (regno)]); + sim_fetch_register (gdbsim_desc, regno, ®isters[REGISTER_BYTE (regno)]); } /* Fetch all registers, or just one, from the child process. */ @@ -161,7 +182,7 @@ store_inferior_registers (regno) store_inferior_registers (regno); } else - sim_store_register (regno, ®isters[REGISTER_BYTE (regno)]); + sim_store_register (gdbsim_desc, regno, ®isters[REGISTER_BYTE (regno)]); } /* Return nonzero if the given thread is still alive. */ @@ -181,7 +202,7 @@ mywait (status) int sigrc; enum sim_stop reason; - sim_stop_reason (&reason, &sigrc); + sim_stop_reason (gdbsim_desc, &reason, &sigrc); switch (reason) { case sim_exited: @@ -215,7 +236,7 @@ myresume (step, signo) { /* Should be using target_signal_to_host() or signal numbers in target.h to convert GDB signal number to target signal number. */ - sim_resume (step, signo); + sim_resume (gdbsim_desc, step, signo); } /* Copy LEN bytes from inferior's memory starting at MEMADDR @@ -227,7 +248,7 @@ read_inferior_memory (memaddr, myaddr, len) char *myaddr; int len; { - sim_read (memaddr, myaddr, len); + sim_read (gdbsim_desc, memaddr, myaddr, len); } /* Copy LEN bytes of data from debugger memory at MYADDR @@ -241,7 +262,7 @@ write_inferior_memory (memaddr, myaddr, len) char *myaddr; int len; { - sim_write (memaddr, myaddr, len); /* should check for error. FIXME!! */ + sim_write (gdbsim_desc, memaddr, myaddr, len); /* should check for error. FIXME!! */ return 0; } -- 2.7.4