1997-03-17 22:19:23 +08: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
|
|
|
|
|
|
|
|
/* 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 12:59:25 +08:00
|
|
|
|
1997-03-17 22:19:23 +08: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 12:59:25 +08:00
|
|
|
|
1997-04-03 07:24:25 +08:00
|
|
|
/* Values for `kind' arg to sim_open. */
|
1997-05-22 12:59:25 +08:00
|
|
|
|
1997-04-03 07:24:25 +08: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 12:59:25 +08:00
|
|
|
|
1997-04-03 07:24:25 +08:00
|
|
|
/* Return codes from various functions. */
|
1997-05-22 12:59:25 +08:00
|
|
|
|
1997-04-03 07:24:25 +08:00
|
|
|
typedef enum {
|
|
|
|
SIM_RC_FAIL = 0,
|
|
|
|
SIM_RC_OK = 1
|
|
|
|
} SIM_RC;
|
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
|
1997-04-17 17:19:45 +08:00
|
|
|
/* The bfd struct, as an opaque type. */
|
1997-05-22 12:59:25 +08:00
|
|
|
|
1997-04-17 17:19:45 +08:00
|
|
|
struct _bfd;
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-03-17 22:19:23 +08:00
|
|
|
/* Main simulator entry points. */
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Create a simulator instance.
|
|
|
|
(This function is called when the simulator is selected from the
|
|
|
|
gdb command line.)
|
1997-04-03 07:47:49 +08:00
|
|
|
KIND specifies how the simulator will be used. Currently there are only
|
|
|
|
two kinds: standalone and debug.
|
1997-05-22 12:59:25 +08:00
|
|
|
CALLBACK specifies a standard host callback (defined in callback.h).
|
1997-04-03 07:47:49 +08:00
|
|
|
ARGV is passed from the command line and can be used to select whatever
|
1997-04-17 17:19:45 +08:00
|
|
|
run time options the simulator provides. It is the standard NULL
|
|
|
|
terminated array of pointers, with argv[0] being the program name.
|
1997-05-22 12:59:25 +08:00
|
|
|
The result is a descriptor that shall be passed to the other
|
|
|
|
sim_foo functions. */
|
1997-03-17 22:19:23 +08:00
|
|
|
|
1997-05-20 08:05:27 +08:00
|
|
|
SIM_DESC sim_open PARAMS ((SIM_OPEN_KIND kind, struct host_callback_struct *callback, char **argv));
|
1997-03-17 22:19:23 +08:00
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Destory a simulator instance.
|
|
|
|
This may involve freeing target memory and closing any open files
|
|
|
|
and mmap'd areas. You cannot assume sim_kill has already been
|
|
|
|
called.
|
1997-03-17 22:19:23 +08:00
|
|
|
QUITTING is non-zero if we cannot hang on errors. */
|
|
|
|
|
|
|
|
void sim_close PARAMS ((SIM_DESC sd, int quitting));
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-03-17 22:19:23 +08:00
|
|
|
/* Load program PROG into the simulator.
|
1997-04-17 17:19:45 +08:00
|
|
|
If ABFD is non-NULL, the bfd for the file has already been opened.
|
|
|
|
The result is a return code indicating success. */
|
1997-03-17 22:19:23 +08:00
|
|
|
|
1997-04-17 17:19:45 +08:00
|
|
|
SIM_RC sim_load PARAMS ((SIM_DESC sd, char *prog, struct _bfd *abfd, int from_tty));
|
1997-03-17 22:19:23 +08:00
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-03-17 22:19:23 +08:00
|
|
|
/* Prepare to run the simulated program.
|
1997-04-17 17:19:45 +08:00
|
|
|
ARGV and ENV are NULL terminated lists of pointers. */
|
1997-03-17 22:19:23 +08:00
|
|
|
|
1997-04-17 17:19:45 +08:00
|
|
|
SIM_RC sim_create_inferior PARAMS ((SIM_DESC sd, char **argv, char **env));
|
1997-03-17 22:19:23 +08:00
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-03-17 22:19:23 +08:00
|
|
|
/* Kill the running program.
|
|
|
|
This may involve closing any open files and deleting any mmap'd areas. */
|
|
|
|
|
|
|
|
void sim_kill PARAMS ((SIM_DESC sd));
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-03-17 22:19:23 +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. */
|
|
|
|
|
|
|
|
int sim_read PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-03-17 22:19:23 +08:00
|
|
|
/* Store LENGTH bytes from BUF in the simulated program's memory.
|
|
|
|
Result is number of bytes write, or zero if error. */
|
|
|
|
|
|
|
|
int sim_write PARAMS ((SIM_DESC sd, SIM_ADDR mem, unsigned char *buf, int length));
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Fetch register REGNO and store the raw (target endian) value in BUF. */
|
1997-03-17 22:19:23 +08:00
|
|
|
|
|
|
|
void sim_fetch_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf));
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Store register REGNO from the raw (target endian) value in BUF. */
|
1997-03-17 22:19:23 +08:00
|
|
|
|
|
|
|
void sim_store_register PARAMS ((SIM_DESC sd, int regno, unsigned char *buf));
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-04-17 17:19:45 +08:00
|
|
|
/* Print whatever statistics the simulator has collected.
|
|
|
|
VERBOSE is currently unused and must always be zero. */
|
1997-03-17 22:19:23 +08:00
|
|
|
|
|
|
|
void sim_info PARAMS ((SIM_DESC sd, int verbose));
|
|
|
|
|
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Run (or resume) the simulated program. */
|
1997-03-17 22:19:23 +08:00
|
|
|
|
|
|
|
void sim_resume PARAMS ((SIM_DESC sd, int step, int siggnal));
|
|
|
|
|
1997-04-18 20:24:52 +08: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 12:59:25 +08:00
|
|
|
/* Fetch the REASON why the program stopped.
|
|
|
|
SIM_EXITED: The program has terminated. SIGRC indicates the target
|
|
|
|
dependant exit status.
|
|
|
|
SIM_STOPPED: The program has stopped. SIGRC indicates the reason:
|
|
|
|
program interrupted by user via a sim_stop request (SIGINT); a
|
|
|
|
breakpoint instruction (SIGTRAP); a completed step (SIGTRAP); an
|
|
|
|
internal error condition (SIGABRT).
|
|
|
|
SIM_SIGNALLED: The simulator encountered target code that requires
|
|
|
|
the signal SIGRC to be delivered to the simulated program.
|
|
|
|
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 22:19:23 +08:00
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-05-22 12:59:25 +08: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 22:19:23 +08:00
|
|
|
void sim_do_command PARAMS ((SIM_DESC sd, char *cmd));
|
|
|
|
|
1997-04-18 20:24:52 +08:00
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Provide simulator with a default (global) host_callback_struct.
|
|
|
|
THIS PROCEDURE IS IS DEPRECIATED.
|
|
|
|
This procedure does not take a SIM_DESC argument as it is
|
|
|
|
used before sim_open. */
|
|
|
|
|
1997-05-20 09:57:43 +08:00
|
|
|
void sim_set_callbacks PARAMS ((struct host_callback_struct *));
|
|
|
|
|
1997-05-20 08:05:27 +08:00
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Set the size of the simulator memory array.
|
|
|
|
THIS PROCEDURE IS IS DEPRECIATED.
|
|
|
|
This procedure does not take a SIM_DESC argument as it is
|
|
|
|
used before sim_open. */
|
|
|
|
|
1997-05-20 09:57:43 +08:00
|
|
|
void sim_size PARAMS ((int i));
|
1997-04-17 14:05:19 +08:00
|
|
|
|
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Run a simulation with tracing enabled.
|
|
|
|
THIS PROCEDURE IS IS DEPRECIATED.
|
|
|
|
This procedure does not take a SIM_DESC argument as it is
|
|
|
|
used before sim_open. */
|
|
|
|
|
1997-04-17 14:05:19 +08:00
|
|
|
int sim_trace PARAMS ((SIM_DESC sd));
|
|
|
|
|
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
/* Configure the size of the profile buffer.
|
|
|
|
THIS PROCEDURE IS IS DEPRECIATED.
|
|
|
|
This procedure does not take a SIM_DESC argument as it is
|
|
|
|
used before sim_open. */
|
1997-05-21 14:54:13 +08:00
|
|
|
|
1997-05-22 12:59:25 +08:00
|
|
|
void sim_set_profile_size PARAMS ((int n));
|
1997-05-21 14:54:13 +08:00
|
|
|
|
1997-03-17 22:19:23 +08:00
|
|
|
#endif /* !defined (REMOTE_SIM_H) */
|