*** empty log message ***
[deliverable/binutils-gdb.git] / gdb / remote-sim.c
index 425d1a69253fe2b489bb83e7c1b9d5b4660a8a38..e845b36f7cc7d306a2da71f589f085647424aa96 100644 (file)
@@ -10,7 +10,7 @@
 
    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
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -19,9 +19,7 @@
    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., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "inferior.h"
@@ -91,7 +89,7 @@ static void gdbsim_resume (ptid_t ptid, int step, enum target_signal siggnal);
 
 static ptid_t gdbsim_wait (ptid_t ptid, struct target_waitstatus *status);
 
-static void gdbsim_prepare_to_store (void);
+static void gdbsim_prepare_to_store (struct regcache *regcache);
 
 static void gdbsim_files_info (struct target_ops *target);
 
@@ -271,24 +269,25 @@ gdb_os_error (host_callback * p, const char *format,...)
 }
 
 int
-one2one_register_sim_regno (int regnum)
+one2one_register_sim_regno (struct gdbarch *gdbarch, int regnum)
 {
   /* Only makes sense to supply raw registers.  */
-  gdb_assert (regnum >= 0 && regnum < NUM_REGS);
+  gdb_assert (regnum >= 0 && regnum < gdbarch_num_regs (gdbarch));
   return regnum;
 }
 
 static void
 gdbsim_fetch_register (struct regcache *regcache, int regno)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
   if (regno == -1)
     {
-      for (regno = 0; regno < NUM_REGS; regno++)
+      for (regno = 0; regno < gdbarch_num_regs (gdbarch); regno++)
        gdbsim_fetch_register (regcache, regno);
       return;
     }
 
-  switch (REGISTER_SIM_REGNO (regno))
+  switch (gdbarch_register_sim_regno (gdbarch, regno))
     {
     case LEGACY_SIM_REGNO_IGNORE:
       break;
@@ -300,7 +299,6 @@ gdbsim_fetch_register (struct regcache *regcache, int regno)
        int nr_bytes;
        memset (buf, 0, MAX_REGISTER_SIZE);
        regcache_raw_supply (regcache, regno, buf);
-       set_register_cached (regno, -1);
        break;
       }
       
@@ -309,18 +307,23 @@ gdbsim_fetch_register (struct regcache *regcache, int regno)
        static int warn_user = 1;
        char buf[MAX_REGISTER_SIZE];
        int nr_bytes;
-       gdb_assert (regno >= 0 && regno < NUM_REGS);
+       gdb_assert (regno >= 0 && regno < gdbarch_num_regs (gdbarch));
        memset (buf, 0, MAX_REGISTER_SIZE);
        nr_bytes = sim_fetch_register (gdbsim_desc,
-                                      REGISTER_SIM_REGNO (regno),
-                                      buf, register_size (current_gdbarch, regno));
-       if (nr_bytes > 0 && nr_bytes != register_size (current_gdbarch, regno) && warn_user)
+                                      gdbarch_register_sim_regno
+                                        (gdbarch, regno),
+                                      buf,
+                                      register_size (gdbarch, regno));
+       if (nr_bytes > 0
+           && nr_bytes != register_size (gdbarch, regno) && warn_user)
          {
            fprintf_unfiltered (gdb_stderr,
                                "Size of register %s (%d/%d) incorrect (%d instead of %d))",
-                               REGISTER_NAME (regno),
-                               regno, REGISTER_SIM_REGNO (regno),
-                               nr_bytes, register_size (current_gdbarch, regno));
+                               gdbarch_register_name (gdbarch, regno),
+                               regno,
+                               gdbarch_register_sim_regno
+                                 (gdbarch, regno),
+                               nr_bytes, register_size (gdbarch, regno));
            warn_user = 0;
          }
        /* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0'
@@ -333,7 +336,7 @@ gdbsim_fetch_register (struct regcache *regcache, int regno)
          {
            printf_filtered ("gdbsim_fetch_register: %d", regno);
            /* FIXME: We could print something more intelligible.  */
-           dump_mem (buf, register_size (current_gdbarch, regno));
+           dump_mem (buf, register_size (gdbarch, regno));
          }
        break;
       }
@@ -344,21 +347,23 @@ gdbsim_fetch_register (struct regcache *regcache, int regno)
 static void
 gdbsim_store_register (struct regcache *regcache, int regno)
 {
+  struct gdbarch *gdbarch = get_regcache_arch (regcache);
   if (regno == -1)
     {
-      for (regno = 0; regno < NUM_REGS; regno++)
+      for (regno = 0; regno < gdbarch_num_regs (gdbarch); regno++)
        gdbsim_store_register (regcache, regno);
       return;
     }
-  else if (REGISTER_SIM_REGNO (regno) >= 0)
+  else if (gdbarch_register_sim_regno (gdbarch, regno) >= 0)
     {
       char tmp[MAX_REGISTER_SIZE];
       int nr_bytes;
       regcache_cooked_read (regcache, regno, tmp);
       nr_bytes = sim_store_register (gdbsim_desc,
-                                    REGISTER_SIM_REGNO (regno),
-                                    tmp, register_size (current_gdbarch, regno));
-      if (nr_bytes > 0 && nr_bytes != register_size (current_gdbarch, regno))
+                                    gdbarch_register_sim_regno
+                                      (gdbarch, regno),
+                                    tmp, register_size (gdbarch, regno));
+      if (nr_bytes > 0 && nr_bytes != register_size (gdbarch, regno))
        internal_error (__FILE__, __LINE__,
                        _("Register size different to expected"));
       /* FIXME: cagney/2002-05-27: Should check `nr_bytes == 0'
@@ -368,7 +373,7 @@ gdbsim_store_register (struct regcache *regcache, int regno)
        {
          printf_filtered ("gdbsim_store_register: %d", regno);
          /* FIXME: We could print something more intelligible.  */
-         dump_mem (tmp, register_size (current_gdbarch, regno));
+         dump_mem (tmp, register_size (gdbarch, regno));
        }
     }
 }
@@ -734,7 +739,7 @@ gdbsim_wait (ptid_t ptid, struct target_waitstatus *status)
    debugged.  */
 
 static void
-gdbsim_prepare_to_store (void)
+gdbsim_prepare_to_store (struct regcache *regcache)
 {
   /* Do nothing, since we can store individual regs */
 }
This page took 0.025339 seconds and 4 git commands to generate.