2008-03-25 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / remote-sim.c
index 8c13888f65153bd49d6689ec7c857b983d8dac74..918eab856f36e2c606689d76f5b030eb3ba26ed3 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, 2007 Free Software Foundation, Inc.
+   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
    Contributed by Cygnus Support.
    Steve Chamberlain (sac@cygnus.com).
@@ -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"
@@ -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 < gdbarch_num_regs (current_gdbarch));
+  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 < gdbarch_num_regs (current_gdbarch); 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;
@@ -308,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 < gdbarch_num_regs (current_gdbarch));
+       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))",
-                               gdbarch_register_name (current_gdbarch, 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'
@@ -332,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;
       }
@@ -343,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 < gdbarch_num_regs (current_gdbarch); 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'
@@ -367,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));
        }
     }
 }
This page took 0.037018 seconds and 4 git commands to generate.