* stabsread.c (get_substring): Declare second arg as int.
[deliverable/binutils-gdb.git] / gdb / remote-sim.h
index 840457cc4aa18cef844d1e94cba1190cf45bbacf..8c106a29262a75c7eacb6ab1fa28c9b912a64cb5 100644 (file)
@@ -1,5 +1,5 @@
 /* This file defines the interface between the simulator and gdb.
-   Copyright (C) 1993 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994 Free Software Foundation, Inc.
 
 This file is part of GDB.
 
@@ -15,73 +15,128 @@ 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., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 #if !defined (REMOTE_SIM_H)
 #define REMOTE_SIM_H 1
 
-/* Main simulator globals ... */
+#include "callback.h"
+/* This file is used when building stand-alone simulators, so isolate this
+   file from gdb.  */
 
-extern int sim_verbose;
+/* 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
+
+/* Callbacks.
+   The simulator may use the following callbacks (gdb routines) which the
+   standalone program must provide.
+
+   void printf_filtered (char *msg, ...);
+   void error /-* noreturn *-/ (char *msg, ...);
+   void *xmalloc (long size);
+   int sim_callback_write_stdout (char *, int len);
+
+   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.
+*/
 
 /* Main simulator entry points ...
 
-   All functions return 0 for success and non-zero for failure.  */
+   All functions that can get an error must call the gdb routine `error',
+   they can only return upon success.  */
 
 /* 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.
-   ARGS is the raw character string and must be parsed by the simulator.  */
+   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.  */
+
+void sim_open PARAMS ((char *args));
 
-int sim_open PARAMS ((char *name));
+/* 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.  */
+
+void sim_close PARAMS ((int quitting));
 
 /* Load program PROG into the simulator.
-   We use "void *" instead of "bfd *" to isolate this file from BFD.  */
+   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).  */
+
+int sim_load PARAMS ((char *prog, int from_tty));
+
+/* 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.  */
 
-int sim_load PARAMS ((void *bfd_handle, char *args));
+void sim_create_inferior PARAMS ((SIM_ADDR start_address,
+                                 char **argv, char **env));
 
-/* Set the arguments and environment for the program loaded into the
-   simulator.  ARGV and ENV are NULL terminated lists of pointers.
-   If the simulator doesn't support setting arguments, print an error message
-   and return non-zero.  */
+/* Kill the running program.
+   This may involve closing any open files and deleting any mmap'd areas.  */
 
-int sim_set_args PARAMS ((char **argv, char **env));
+void sim_kill PARAMS ((void));
+
+/* 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_ADDR mem, unsigned char *buf, int length));
+
+/* 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_ADDR mem, unsigned char *buf, int length));
 
 /* Fetch register REGNO and store the raw value in BUF.  */
 
-int sim_fetch_register PARAMS ((int regno, char *buf));
+void sim_fetch_register PARAMS ((int regno, unsigned char *buf));
 
 /* Store register REGNO from BUF (in raw format).  */
 
-int sim_store_register PARAMS ((int regno, char *buf));
+void sim_store_register PARAMS ((int regno, unsigned char *buf));
 
-/* Kill the running program.
-   This may involve closing any open files and deleting any mmap'd areas.  */
+/* Print some interesting information about the simulator.
+   VERBOSE is non-zero for the wordy version.  */
+
+void sim_info PARAMS ((int verbose));
 
-int sim_kill PARAMS ((void));
+/* Fetch why the program stopped.
+   SIGRC will contain either the argument to exit() or the signal number.  */
 
-/* Read LENGTH bytes of the simulated program's memory and store in BUF.  */
+enum sim_stop { sim_exited, sim_stopped, sim_signalled };
 
-int sim_read PARAMS ((CORE_ADDR mem, char *buf, int length));
+void sim_stop_reason PARAMS ((enum sim_stop *reason, int *sigrc));
 
-/* Store LENGTH bytes from BUF in the simulated program's memory.  */
+/* Run (or resume) the program.  */
 
-int sim_write PARAMS ((CORE_ADDR mem, char *buf, int length));
+void sim_resume PARAMS ((int step, int siggnal));
 
-/* Print some interesting information about the simulator.  */
+/* Passthru for other commands that the simulator might support. */
 
-int sim_info PARAMS ((void));
+void sim_do_command PARAMS ((char *cmd));
 
-/* Set the simulated cpu's program counter to PC.  */
 
-int sim_set_pc PARAMS ((CORE_ADDR pc));
+/* Callbacks for the simulator to use. */
 
-/* Fetch why the program stopped.  */
+int sim_callback_write_stdout PARAMS ((char *, int));
 
-int sim_stop_signal PARAMS ((void));
+/* Provide simulator with a standard host_callback_struct. */
 
-/* Run (or resume) the program.  */
+void sim_set_callbacks PARAMS ((struct host_callback_struct *));
 
-int sim_resume PARAMS ((int step, int siggnal));
 
 #endif /* !defined (REMOTE_SIM_H) */
This page took 0.024734 seconds and 4 git commands to generate.