#include "gdbcore.h"
#include "remote-sim.h"
#include "remote-utils.h"
+#include "callback.h"
+
+/* Prototypes */
+
+static void dump_mem PARAMS ((char *buf, int len));
+
+static void gdbsim_fetch_register PARAMS ((int regno));
+
+static void gdbsim_store_register PARAMS ((int regno));
+
+static void gdbsim_kill PARAMS ((void));
+
+static void gdbsim_load PARAMS ((char *prog, int fromtty));
+
+static void gdbsim_create_inferior PARAMS ((char *exec_file, char *args, char **env));
+
+static void gdbsim_open PARAMS ((char *args, int from_tty));
+
+static void gdbsim_close PARAMS ((int quitting));
+
+static void gdbsim_detach PARAMS ((char *args, int from_tty));
+
+static void gdbsim_resume PARAMS ((int pid, int step, enum target_signal siggnal));
+
+static int gdbsim_wait PARAMS ((int pid, struct target_waitstatus *status));
+
+static void gdbsim_prepare_to_store PARAMS ((void));
+
+static int gdbsim_xfer_inferior_memory PARAMS ((CORE_ADDR memaddr,
+ char *myaddr, int len,
+ int write,
+ struct target_ops *target));
+
+static void gdbsim_files_info PARAMS ((struct target_ops *target));
+
+static void gdbsim_mourn_inferior PARAMS ((void));
+
+static void simulator_command PARAMS ((char *args, int from_tty));
/* Naming convention:
sim_* are the interface to the simulator (see remote-sim.h).
-
+ sim_callback_* are the stuff which the simulator can see inside GDB.
gdbsim_* are stuff which is internal to gdb. */
/* Forward data declarations */
}
-int
-gdbsim_write_stdout (arg, len)
-char *arg;
-int len;
-{
- int i;
- char b[2];
- for (i = 0; i< len; i++) {
- b[0] = arg[i];
- b[1] = 0;
- if (target_output_hook)
- target_output_hook (b);
- else
- fputs_filtered (b, gdb_stdout);
- }
- return len;
-}
-
static void
gdbsim_store_register (regno)
int regno;
program_loaded = 1;
if (sim_load (prog, fromtty) != 0)
- gr_load_image (prog, fromtty);
+ generic_load (prog, fromtty);
}
entry_pt = (CORE_ADDR) bfd_get_start_address (exec_bfd);
- gdbsim_kill (NULL, NULL);
+ gdbsim_kill ();
remove_breakpoints ();
init_wait_for_inferior ();
if (sr_get_debug ())
printf_filtered ("gdbsim_open: args \"%s\"\n", args ? args : "(null)");
+ sim_set_callbacks (&default_callback);
+ default_callback.init (&default_callback);
+
sim_open (args);
push_target (&gdbsim_ops);
target_fetch_registers (-1);
-
printf_filtered ("Connected to the simulator.\n");
}
int pid, step;
enum target_signal siggnal;
{
+ if (inferior_pid != 42)
+ error ("The program is not being run.");
+
if (sr_get_debug ())
printf_filtered ("gdbsim_resume: step %d, signal %d\n", step, siggnal);
generic_mourn_inferior ();
}
-/* Put a command string, in args, out to MONITOR. Output from MONITOR
- is placed on the users terminal until the prompt is seen. FIXME: We
- read the characters ourseleves here cause of a nasty echo. */
+/* Pass the command argument through to the simulator verbatim. The
+ simulator must do any command interpretation work. */
static void
simulator_command (args, from_tty)
char *args;
int from_tty;
{
+ /* The user may give a command before the simulator is opened, so
+ ensure that the callbacks have been set up. */
+ sim_set_callbacks (&default_callback);
+ default_callback.init (&default_callback);
+
sim_do_command (args);
}