1993-07-31 02:57:41 +08:00
|
|
|
/* This file defines the interface between the simulator and gdb.
|
1994-05-19 04:42:06 +08:00
|
|
|
Copyright (C) 1993, 1994 Free Software Foundation, Inc.
|
1993-07-31 02:57:41 +08:00
|
|
|
|
|
|
|
This file is part of GDB.
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
1995-08-02 11:41:12 +08:00
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
|
|
|
#if !defined (REMOTE_SIM_H)
|
|
|
|
#define REMOTE_SIM_H 1
|
|
|
|
|
1995-10-14 05:15:18 +08:00
|
|
|
#include "callback.h"
|
1993-10-27 00:34:01 +08:00
|
|
|
/* This file is used when building stand-alone simulators, so isolate this
|
|
|
|
file from gdb. */
|
|
|
|
|
|
|
|
/* Pick up CORE_ADDR_TYPE if defined (from gdb), otherwise use same value as
|
|
|
|
gdb does (unsigned int - from defs.h). */
|
|
|
|
|
|
|
|
#ifndef CORE_ADDR_TYPE
|
|
|
|
typedef unsigned int SIM_ADDR;
|
|
|
|
#else
|
|
|
|
typedef CORE_ADDR_TYPE SIM_ADDR;
|
|
|
|
#endif
|
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
/* Callbacks.
|
|
|
|
The simulator may use the following callbacks (gdb routines) which the
|
|
|
|
standalone program must provide.
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void printf_filtered (char *msg, ...);
|
|
|
|
void error /-* noreturn *-/ (char *msg, ...);
|
|
|
|
void *xmalloc (long size);
|
1995-09-20 23:37:50 +08:00
|
|
|
int sim_callback_write_stdout (char *, int len);
|
1995-10-14 05:15:18 +08:00
|
|
|
|
|
|
|
The new way of doing I/O is to use the pointer provided by GDB
|
|
|
|
via the sim_set_callbacks call, look in callbacks.c to see what
|
|
|
|
can be done.
|
1994-05-19 04:42:06 +08:00
|
|
|
*/
|
1993-07-31 02:57:41 +08:00
|
|
|
|
|
|
|
/* Main simulator entry points ...
|
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
All functions that can get an error must call the gdb routine `error',
|
|
|
|
they can only return upon success. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
|
|
|
/* Initialize the simulator. This function is called when the simulator
|
|
|
|
is selected from the command line. ARGS is passed from the command line
|
|
|
|
and can be used to select whatever run time options the simulator provides.
|
1994-05-19 04:42:06 +08:00
|
|
|
ARGS is the raw character string and must be parsed by the simulator,
|
|
|
|
which is trivial to do with the buildargv function in libiberty.
|
|
|
|
It is ok to do nothing. */
|
1993-09-18 01:27:43 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_open PARAMS ((char *args));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
/* Terminate usage of the simulator. This may involve freeing target memory
|
|
|
|
and closing any open files and mmap'd areas. You cannot assume sim_kill
|
|
|
|
has already been called.
|
|
|
|
QUITTING is non-zero if we cannot hang on errors. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_close PARAMS ((int quitting));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
/* Load program PROG into the simulator.
|
|
|
|
Return non-zero if you wish the caller to handle it
|
|
|
|
(it is done this way because most simulators can use gr_load_image,
|
|
|
|
but defining it as a callback seems awkward). */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
int sim_load PARAMS ((char *prog, int from_tty));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
/* Prepare to run the simulated program.
|
|
|
|
START_ADDRESS is, yes, you guessed it, the start address of the program.
|
|
|
|
ARGV and ENV are NULL terminated lists of pointers.
|
|
|
|
Gdb will set the start address via sim_store_register as well, but
|
|
|
|
standalone versions of existing simulators are not set up to cleanly call
|
|
|
|
sim_store_register, so the START_ADDRESS argument is there as a
|
|
|
|
workaround. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_create_inferior PARAMS ((SIM_ADDR start_address,
|
|
|
|
char **argv, char **env));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
|
|
|
/* Kill the running program.
|
|
|
|
This may involve closing any open files and deleting any mmap'd areas. */
|
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_kill PARAMS ((void));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1993-10-24 05:56:47 +08:00
|
|
|
/* Read LENGTH bytes of the simulated program's memory and store in BUF.
|
|
|
|
Result is number of bytes read, or zero if error. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1993-10-27 00:34:01 +08:00
|
|
|
int sim_read PARAMS ((SIM_ADDR mem, unsigned char *buf, int length));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1993-10-24 05:56:47 +08:00
|
|
|
/* Store LENGTH bytes from BUF in the simulated program's memory.
|
|
|
|
Result is number of bytes write, or zero if error. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1993-10-27 00:34:01 +08:00
|
|
|
int sim_write PARAMS ((SIM_ADDR mem, unsigned char *buf, int length));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
/* Fetch register REGNO and store the raw value in BUF. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_fetch_register PARAMS ((int regno, unsigned char *buf));
|
|
|
|
|
|
|
|
/* Store register REGNO from BUF (in raw format). */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_store_register PARAMS ((int regno, unsigned char *buf));
|
|
|
|
|
|
|
|
/* Print some interesting information about the simulator.
|
|
|
|
VERBOSE is non-zero for the wordy version. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_info PARAMS ((int verbose));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1993-10-24 05:56:47 +08:00
|
|
|
/* Fetch why the program stopped.
|
|
|
|
SIGRC will contain either the argument to exit() or the signal number. */
|
1993-07-31 02:57:41 +08:00
|
|
|
|
1993-10-24 05:56:47 +08:00
|
|
|
enum sim_stop { sim_exited, sim_stopped, sim_signalled };
|
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_stop_reason PARAMS ((enum sim_stop *reason, int *sigrc));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
|
|
|
/* Run (or resume) the program. */
|
|
|
|
|
1994-05-19 04:42:06 +08:00
|
|
|
void sim_resume PARAMS ((int step, int siggnal));
|
1993-07-31 02:57:41 +08:00
|
|
|
|
* config/h8300/h8300.mt: Renamed from h8300hms.mt.
* config/h8500/h8500.mt: Renamed from h8500hms.mt.
* config/z8k/z8k.mt: Renamed from z8ksim.mt.
* configure, configure.in: Update to reflect renamings.
* remote-sim.c (sim): New command, passes commands to simulator.
(simulator_command): New function.
(gdbsim_ops): Clean up.
* remote-sim.h (sim_do_command): Declare.
* sh-tdep.c (memory_size): Remove command.
* Makefile.in (SIM, SIM_OBS): New variables.
(CLIBS, CDEPS): Add value of SIM.
(DEPFILES): Add value of SIM_OBS
* config/arm/arm.mt, config/h8300/h8300.mt, config/h8500/h8500.mt,
config/sh/sh.mt, config/sparc/sp64sim.mt, config/w65/w65.mt,
config/z8k/z8k.mt: Remove simulator files from TDEPFILES,
define in SIM_OBS and SIM.
config/sparc/sp64sim.mt (SIMFILES): Remove.
* remote-z8k.c: Remove, was superseded by remote-sim.c
* Makefile.in, mpw-make.in: Remove references to remote-z8k.c.
1995-07-01 08:22:57 +08:00
|
|
|
/* Passthru for other commands that the simulator might support. */
|
|
|
|
|
|
|
|
void sim_do_command PARAMS ((char *cmd));
|
|
|
|
|
1995-09-20 23:32:41 +08:00
|
|
|
|
|
|
|
/* Callbacks for the simulator to use. */
|
|
|
|
|
1995-09-20 23:37:50 +08:00
|
|
|
int sim_callback_write_stdout PARAMS ((char *, int));
|
1995-09-20 23:32:41 +08:00
|
|
|
|
1995-10-14 05:15:18 +08:00
|
|
|
/* Provide simulator with a standard host_callback_struct. */
|
|
|
|
|
|
|
|
void sim_set_callbacks PARAMS ((struct host_callback_struct *));
|
|
|
|
|
|
|
|
|
1993-07-31 02:57:41 +08:00
|
|
|
#endif /* !defined (REMOTE_SIM_H) */
|