add autom4te.cache to .cvsignore
[deliverable/binutils-gdb.git] / gdb / remote-sim.c
index 2133f3e1ffdb6024d325d8cd83eb7d888a4d3e63..b49906611272a4793c384afef755067216b72797 100644 (file)
@@ -1,7 +1,7 @@
 /* Generic remote debugging interface for simulators.
 
-   Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
-   2002, 2004, 2005, 2006 Free Software Foundation, Inc.
+   Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+   2004, 2005, 2006, 2007 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
    Steve Chamberlain (sac@cygnus.com).
@@ -43,6 +43,7 @@
 #include "gdb_assert.h"
 #include "sim-regno.h"
 #include "arch-utils.h"
+#include "readline/readline.h"
 
 /* Prototypes */
 
@@ -382,8 +383,8 @@ gdbsim_kill (void)
     printf_filtered ("gdbsim_kill\n");
 
   /* There is no need to `kill' running simulator - the simulator is
-     not running */
-  inferior_ptid = null_ptid;
+     not running.  Mourning it is enough.  */
+  target_mourn_inferior ();
 }
 
 /* Load an executable file into the target process.  This is expected to
@@ -391,13 +392,24 @@ gdbsim_kill (void)
    GDB's symbol tables to match.  */
 
 static void
-gdbsim_load (char *prog, int fromtty)
+gdbsim_load (char *args, int fromtty)
 {
+  char **argv = buildargv (args);
+  char *prog;
+
+  if (argv == NULL)
+    nomem (0);
+
+  make_cleanup_freeargv (argv);
+
+  prog = tilde_expand (argv[0]);
+
+  if (argv[1] != NULL)
+    error (_("GDB sim does not yet support a load offset."));
+
   if (sr_get_debug ())
     printf_filtered ("gdbsim_load: prog \"%s\"\n", prog);
 
-  inferior_ptid = null_ptid;
-
   /* FIXME: We will print two messages on error.
      Need error to either not print anything if passed NULL or need
      another routine that doesn't take any arguments.  */
@@ -455,6 +467,7 @@ gdbsim_create_inferior (char *exec_file, char *args, char **env, int from_tty)
   sim_create_inferior (gdbsim_desc, exec_bfd, argv, env);
 
   inferior_ptid = pid_to_ptid (42);
+  target_mark_running (&gdbsim_ops);
   insert_breakpoints ();       /* Needed to get correct instruction in cache */
 
   clear_proceed_status ();
@@ -493,7 +506,7 @@ gdbsim_open (char *args, int from_tty)
   strcpy (arg_buf, "gdbsim");  /* 7 */
   /* Specify the byte order for the target when it is both selectable
      and explicitly specified by the user (not auto detected). */
-  switch (selected_byte_order ())
+  switch (TARGET_BYTE_ORDER)
     {
     case BFD_ENDIAN_BIG:
       strcat (arg_buf, " -E big");
@@ -529,8 +542,12 @@ gdbsim_open (char *args, int from_tty)
     error (_("unable to create simulator instance"));
 
   push_target (&gdbsim_ops);
-  target_fetch_registers (-1);
   printf_filtered ("Connected to the simulator.\n");
+
+  /* There's nothing running after "target sim" or "load"; not until
+     "run".  */
+  inferior_ptid = null_ptid;
+  target_mark_exited (&gdbsim_ops);
 }
 
 /* Does whatever cleanup is required for a target that we are no longer
@@ -733,6 +750,12 @@ gdbsim_xfer_inferior_memory (CORE_ADDR memaddr, gdb_byte *myaddr, int len,
                             int write, struct mem_attrib *attrib,
                             struct target_ops *target)
 {
+  /* If no program is running yet, then ignore the simulator for
+     memory.  Pass the request down to the next target, hopefully
+     an exec file.  */
+  if (!target_has_execution)
+    return 0;
+
   if (!program_loaded)
     error (_("No program loaded."));
 
@@ -788,21 +811,10 @@ gdbsim_mourn_inferior (void)
     printf_filtered ("gdbsim_mourn_inferior:\n");
 
   remove_breakpoints ();
+  target_mark_exited (&gdbsim_ops);
   generic_mourn_inferior ();
 }
 
-static int
-gdbsim_insert_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
-{
-  return memory_insert_breakpoint (addr, contents_cache);
-}
-
-static int
-gdbsim_remove_breakpoint (CORE_ADDR addr, bfd_byte *contents_cache)
-{
-  return memory_remove_breakpoint (addr, contents_cache);
-}
-
 /* Pass the command argument through to the simulator verbatim.  The
    simulator must do any command interpretation work.  */
 
@@ -852,8 +864,8 @@ init_gdbsim_ops (void)
   gdbsim_ops.to_prepare_to_store = gdbsim_prepare_to_store;
   gdbsim_ops.deprecated_xfer_memory = gdbsim_xfer_inferior_memory;
   gdbsim_ops.to_files_info = gdbsim_files_info;
-  gdbsim_ops.to_insert_breakpoint = gdbsim_insert_breakpoint;
-  gdbsim_ops.to_remove_breakpoint = gdbsim_remove_breakpoint;
+  gdbsim_ops.to_insert_breakpoint = memory_insert_breakpoint;
+  gdbsim_ops.to_remove_breakpoint = memory_remove_breakpoint;
   gdbsim_ops.to_kill = gdbsim_kill;
   gdbsim_ops.to_load = gdbsim_load;
   gdbsim_ops.to_create_inferior = gdbsim_create_inferior;
This page took 0.025885 seconds and 4 git commands to generate.