1997-03-17 15:19:23 +01:00
|
|
|
|
/* This file defines the interface between the simulator and gdb.
|
|
|
|
|
Copyright (C) 1993, 1994, 1996, 1997 Free Software Foundation, Inc.
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
|
|
|
|
|
|
|
|
|
|
#if !defined (REMOTE_SIM_H)
|
|
|
|
|
#define REMOTE_SIM_H 1
|
|
|
|
|
|
1997-11-07 18:49:34 +01:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
extern "C" {
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-03-17 15:19:23 +01: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
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
|
1997-03-17 15:19:23 +01:00
|
|
|
|
/* Semi-opaque type used as result of sim_open and passed back to all
|
|
|
|
|
other routines. "desc" is short for "descriptor".
|
|
|
|
|
It is up to each simulator to define `sim_state'. */
|
|
|
|
|
|
|
|
|
|
typedef struct sim_state *SIM_DESC;
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
|
1997-04-03 01:24:25 +02:00
|
|
|
|
/* Values for `kind' arg to sim_open. */
|
1997-05-22 06:59:25 +02:00
|
|
|
|
|
1997-04-03 01:24:25 +02:00
|
|
|
|
typedef enum {
|
|
|
|
|
SIM_OPEN_STANDALONE, /* simulator used standalone (run.c) */
|
|
|
|
|
SIM_OPEN_DEBUG /* simulator used by debugger (gdb) */
|
|
|
|
|
} SIM_OPEN_KIND;
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
|
1997-04-03 01:24:25 +02:00
|
|
|
|
/* Return codes from various functions. */
|
1997-05-22 06:59:25 +02:00
|
|
|
|
|
1997-04-03 01:24:25 +02:00
|
|
|
|
typedef enum {
|
|
|
|
|
SIM_RC_FAIL = 0,
|
1997-09-25 03:05:31 +02:00
|
|
|
|
SIM_RC_OK = 1,
|
|
|
|
|
SIM_RC_UNKNOWN_BREAKPOINT = 2,
|
|
|
|
|
SIM_RC_INSUFFICIENT_RESOURCES = 3,
|
|
|
|
|
SIM_RC_DUPLICATE_BREAKPOINT = 4
|
1997-04-03 01:24:25 +02:00
|
|
|
|
} SIM_RC;
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
|
1997-04-17 11:19:45 +02:00
|
|
|
|
/* The bfd struct, as an opaque type. */
|
1997-05-22 06:59:25 +02:00
|
|
|
|
|
1997-04-17 11:19:45 +02:00
|
|
|
|
struct _bfd;
|
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-03-17 15:19:23 +01:00
|
|
|
|
/* Main simulator entry points. */
|
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-08-26 01:14:25 +02:00
|
|
|
|
/* Create a fully initialized simulator instance.
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
(This function is called when the simulator is selected from the
|
|
|
|
|
gdb command line.)
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-08-27 06:44:41 +02:00
|
|
|
|
KIND specifies how the simulator shall be used. Currently there
|
|
|
|
|
are only two kinds: stand-alone and debug.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
CALLBACK specifies a standard host callback (defined in callback.h).
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1997-08-26 01:14:25 +02:00
|
|
|
|
ABFD, when non NULL, designates a target program. The program is
|
|
|
|
|
not loaded.
|
|
|
|
|
|
|
|
|
|
ARGV is a standard ARGV pointer such as that passed from the
|
|
|
|
|
command line. The syntax of the argument list is is assumed to be
|
|
|
|
|
``SIM-PROG { SIM-OPTION } [ TARGET-PROGRAM { TARGET-OPTION } ]''.
|
1997-08-27 06:44:41 +02:00
|
|
|
|
The trailing TARGET-PROGRAM and args are only valid for a
|
|
|
|
|
stand-alone simulator.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
|
|
|
|
On success, the result is a non NULL descriptor that shall be
|
|
|
|
|
passed to the other sim_foo functions. While the simulator
|
|
|
|
|
configuration can be parameterized by (in decreasing precedence)
|
|
|
|
|
ARGV's SIM-OPTION, ARGV's TARGET-PROGRAM and the ABFD argument, the
|
|
|
|
|
successful creation of the simulator shall not dependent on the
|
|
|
|
|
presence of any of these arguments/options.
|
|
|
|
|
|
1997-08-27 06:44:41 +02:00
|
|
|
|
Hardware simulator: The created simulator shall be sufficiently
|
|
|
|
|
initialized to handle, with out restrictions any client requests
|
|
|
|
|
(including memory reads/writes, register fetch/stores and a
|
|
|
|
|
resume).
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-08-27 06:44:41 +02:00
|
|
|
|
Process simulator: that process is not created until a call to
|
|
|
|
|
sim_create_inferior. FIXME: What should the state of the simulator
|
|
|
|
|
be? */
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
|
|
|
|
SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, struct host_callback_struct *callback, struct _bfd *abfd, char **argv));
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
/* Destory a simulator instance.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
|
|
|
|
QUITTING is non-zero if we cannot hang on errors.
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
This may involve freeing target memory and closing any open files
|
|
|
|
|
and mmap'd areas. You cannot assume sim_kill has already been
|
1997-08-26 01:14:25 +02:00
|
|
|
|
called. */
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
|
|
|
|
void sim_close PARAMS ((SIM_DESC sd, int quitting));
|
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-08-26 01:14:25 +02:00
|
|
|
|
/* Load program PROG into the simulators memory.
|
|
|
|
|
|
1997-04-17 11:19:45 +02:00
|
|
|
|
If ABFD is non-NULL, the bfd for the file has already been opened.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
The result is a return code indicating success.
|
|
|
|
|
|
1997-10-22 07:26:27 +02:00
|
|
|
|
Hardware simulator: Normally, each program section is written into
|
|
|
|
|
memory according to that sections LMA using physical (direct)
|
|
|
|
|
addressing. The exception being systems, such as PPC/CHRP, which
|
|
|
|
|
support more complicated program loaders. A call to this function
|
|
|
|
|
should not effect the state of the processor registers. Multiple
|
|
|
|
|
calls to this function are permitted and have an accumulative
|
|
|
|
|
effect.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-08-27 06:44:41 +02:00
|
|
|
|
Process simulator: Calls to this function may be ignored.
|
|
|
|
|
|
1997-10-22 07:26:27 +02:00
|
|
|
|
FIXME: Most hardware simulators load the image at the VMA using
|
|
|
|
|
virtual addressing.
|
|
|
|
|
|
|
|
|
|
FIXME: For some hardware targets, before a loaded program can be
|
|
|
|
|
executed, it requires the manipulation of VM registers and tables.
|
1997-08-27 06:44:41 +02:00
|
|
|
|
Such manipulation should probably (?) occure in
|
|
|
|
|
sim_create_inferior. */
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1997-04-17 11:19:45 +02:00
|
|
|
|
SIM_RC sim_load PARAMS ((SIM_DESC sd, char *prog, struct _bfd *abfd, int from_tty));
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-03-17 15:19:23 +01:00
|
|
|
|
/* Prepare to run the simulated program.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-08-27 06:44:41 +02:00
|
|
|
|
ABFD, if not NULL, provides initial processor state information.
|
|
|
|
|
ARGV and ENV, if non NULL, are NULL terminated lists of pointers.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-08-27 06:44:41 +02:00
|
|
|
|
Hardware simulator: This function shall initialize the processor
|
|
|
|
|
registers to a known value. The program counter and possibly stack
|
|
|
|
|
pointer shall be set using information obtained from ABFD (or
|
|
|
|
|
hardware reset defaults). ARGV and ENV, dependant on the target
|
|
|
|
|
ABI, may be written to memory.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-08-27 06:44:41 +02:00
|
|
|
|
Process simulator: After a call to this function, a new process
|
|
|
|
|
instance shall exist. The TEXT, DATA, BSS and stack regions shall
|
|
|
|
|
all be initialized, ARGV and ENV shall be written to process
|
|
|
|
|
address space (according to the applicable ABI) and the program
|
|
|
|
|
counter and stack pointer set accordingly. */
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1997-08-27 06:44:41 +02:00
|
|
|
|
SIM_RC sim_create_inferior PARAMS ((SIM_DESC sd, struct _bfd *abfd, char **argv, char **env));
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-10-14 11:33:18 +02:00
|
|
|
|
/* Fetch LENGTH bytes of the simulated program's memory. Start fetch
|
|
|
|
|
at virtual address MEM and store in BUF. Result is number of bytes
|
|
|
|
|
read, or zero if error. */
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
|
|
|
|
int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
|
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-10-14 11:33:18 +02:00
|
|
|
|
/* Store LENGTH bytes from BUF into the simulated program's
|
|
|
|
|
memory. Store bytes starting at virtual address MEM. Result is
|
|
|
|
|
number of bytes write, or zero if error. */
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
|
|
|
|
int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
|
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1998-02-17 05:06:38 +01:00
|
|
|
|
/* Fetch register REGNO storing its raw (target endian) value in the
|
|
|
|
|
LENGTH byte buffer BUF. Return the actual size of the register or
|
|
|
|
|
zero if REGNO is not applicable.
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1998-02-17 05:06:38 +01:00
|
|
|
|
Legacy implementations ignore LENGTH and always return -1.
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1998-02-17 05:06:38 +01:00
|
|
|
|
If LENGTH does not match the size of REGNO no data is transfered
|
|
|
|
|
(the actual register size is still returned). */
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1998-02-17 05:06:38 +01:00
|
|
|
|
int sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf, int length));
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1998-02-17 05:06:38 +01:00
|
|
|
|
|
|
|
|
|
/* Store register REGNO from the raw (target endian) value in BUF.
|
|
|
|
|
Return the actual size of the register or zero if REGNO is not
|
|
|
|
|
applicable.
|
|
|
|
|
|
|
|
|
|
Legacy implementations ignore LENGTH and always return -1.
|
|
|
|
|
|
|
|
|
|
If LENGTH does not match the size of REGNO no data is transfered
|
|
|
|
|
(the actual register size is still returned). */
|
|
|
|
|
|
|
|
|
|
int sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf, int length));
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-04-17 11:19:45 +02:00
|
|
|
|
/* Print whatever statistics the simulator has collected.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-04-17 11:19:45 +02:00
|
|
|
|
VERBOSE is currently unused and must always be zero. */
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
|
|
|
|
void sim_info PARAMS ((SIM_DESC sd, int verbose));
|
|
|
|
|
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
/* Run (or resume) the simulated program. */
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
|
|
|
|
void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal));
|
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
|
|
|
|
/* Asynchronous request to stop the simulation.
|
|
|
|
|
A nonzero return indicates that the simulator is able to handle
|
|
|
|
|
the request */
|
|
|
|
|
|
|
|
|
|
int sim_stop PARAMS ((SIM_DESC sd));
|
|
|
|
|
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
/* Fetch the REASON why the program stopped.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
SIM_EXITED: The program has terminated. SIGRC indicates the target
|
|
|
|
|
dependant exit status.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-10-14 11:33:18 +02:00
|
|
|
|
SIM_STOPPED: The program has stopped. SIGRC uses the host's signal
|
|
|
|
|
numbering as a way of identifying the reaon: program interrupted by
|
|
|
|
|
user via a sim_stop request (SIGINT); a breakpoint instruction
|
|
|
|
|
(SIGTRAP); a completed single step (SIGTRAP); an internal error
|
|
|
|
|
condition (SIGABRT); an illegal instruction (SIGILL); Access to an
|
|
|
|
|
undefined memory region (SIGSEGV); Mis-aligned memory access
|
|
|
|
|
(SIGBUS).
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-11-22 13:52:44 +01:00
|
|
|
|
SIM_SIGNALLED: The program has stopped. The simulator has
|
|
|
|
|
encountered target code that requires the (HOST) signal SIGRC to be
|
|
|
|
|
delivered to the simulated program. Ex: `kill (getpid (),
|
|
|
|
|
TARGET_SIGxxx)'. Where TARGET_SIGxxx has been translated into a
|
|
|
|
|
host signal. FIXME: This is not always possible..
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
SIM_RUNNING, SIM_POLLING: The return of one of these values
|
|
|
|
|
indicates a problem internal to the simulator. */
|
|
|
|
|
|
|
|
|
|
enum sim_stop { sim_running, sim_polling, sim_exited, sim_stopped, sim_signalled };
|
|
|
|
|
|
|
|
|
|
void sim_stop_reason PARAMS ((SIM_DESC sd, enum sim_stop *reason, int *sigrc));
|
1997-03-17 15:19:23 +01:00
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
/* Passthru for other commands that the simulator might support.
|
|
|
|
|
Simulators should be prepared to deal with any combination of NULL
|
|
|
|
|
or empty CMD. */
|
|
|
|
|
|
1997-03-17 15:19:23 +01:00
|
|
|
|
void sim_do_command PARAMS ((SIM_DESC sd, char *cmd));
|
1997-09-25 03:05:31 +02:00
|
|
|
|
|
|
|
|
|
/* Call these functions to set and clear breakpoints at ADDR. */
|
|
|
|
|
|
|
|
|
|
SIM_RC sim_set_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
|
|
|
|
|
SIM_RC sim_clear_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
|
|
|
|
|
SIM_RC sim_clear_all_breakpoints PARAMS ((SIM_DESC sd));
|
|
|
|
|
|
|
|
|
|
/* These functions are used to enable and disable breakpoints. */
|
|
|
|
|
|
|
|
|
|
SIM_RC sim_enable_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
|
|
|
|
|
SIM_RC sim_disable_breakpoint PARAMS ((SIM_DESC sd, SIM_ADDR addr));
|
|
|
|
|
SIM_RC sim_enable_all_breakpoints PARAMS ((SIM_DESC sd));
|
|
|
|
|
SIM_RC sim_disable_all_breakpoints PARAMS ((SIM_DESC sd));
|
1997-08-26 01:14:25 +02:00
|
|
|
|
|
1997-04-18 14:24:52 +02:00
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
/* Provide simulator with a default (global) host_callback_struct.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
THIS PROCEDURE IS DEPRECIATED.
|
1997-06-06 05:02:51 +02:00
|
|
|
|
GDB and NRUN do not use this interface.
|
1997-05-22 06:59:25 +02:00
|
|
|
|
This procedure does not take a SIM_DESC argument as it is
|
|
|
|
|
used before sim_open. */
|
|
|
|
|
|
1997-05-20 03:57:43 +02:00
|
|
|
|
void sim_set_callbacks PARAMS ((struct host_callback_struct *));
|
|
|
|
|
|
1997-05-20 02:05:27 +02:00
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
/* Set the size of the simulator memory array.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
THIS PROCEDURE IS DEPRECIATED.
|
1997-06-06 05:02:51 +02:00
|
|
|
|
GDB and NRUN do not use this interface.
|
1997-05-22 06:59:25 +02:00
|
|
|
|
This procedure does not take a SIM_DESC argument as it is
|
|
|
|
|
used before sim_open. */
|
|
|
|
|
|
1997-05-20 03:57:43 +02:00
|
|
|
|
void sim_size PARAMS ((int i));
|
1997-04-17 08:05:19 +02:00
|
|
|
|
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
/* Run a simulation with tracing enabled.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
THIS PROCEDURE IS DEPRECIATED.
|
1997-06-06 05:02:51 +02:00
|
|
|
|
GDB and NRUN do not use this interface.
|
1997-05-22 06:59:25 +02:00
|
|
|
|
This procedure does not take a SIM_DESC argument as it is
|
|
|
|
|
used before sim_open. */
|
|
|
|
|
|
1997-04-17 08:05:19 +02:00
|
|
|
|
int sim_trace PARAMS ((SIM_DESC sd));
|
|
|
|
|
|
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
/* Configure the size of the profile buffer.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
THIS PROCEDURE IS DEPRECIATED.
|
1997-06-06 05:02:51 +02:00
|
|
|
|
GDB and NRUN do not use this interface.
|
1997-05-22 06:59:25 +02:00
|
|
|
|
This procedure does not take a SIM_DESC argument as it is
|
|
|
|
|
used before sim_open. */
|
1997-05-21 08:54:13 +02:00
|
|
|
|
|
1997-05-22 06:59:25 +02:00
|
|
|
|
void sim_set_profile_size PARAMS ((int n));
|
1997-05-21 08:54:13 +02:00
|
|
|
|
|
1997-06-06 05:02:51 +02:00
|
|
|
|
|
|
|
|
|
/* Kill the running program.
|
1997-08-26 01:14:25 +02:00
|
|
|
|
THIS PROCEDURE IS DEPRECIATED.
|
1997-06-06 05:02:51 +02:00
|
|
|
|
GDB and NRUN do not use this interface.
|
|
|
|
|
This procedure will be replaced as part of the introduction of
|
|
|
|
|
multi-cpu simulators. */
|
|
|
|
|
|
|
|
|
|
void sim_kill PARAMS ((SIM_DESC sd));
|
|
|
|
|
|
1997-11-07 18:49:34 +01:00
|
|
|
|
#ifdef __cplusplus
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
1997-03-17 15:19:23 +01:00
|
|
|
|
#endif /* !defined (REMOTE_SIM_H) */
|