Add the file include/gdb/sim-arm.h defining an enum that specifies the
authorAndrew Cagney <cagney@redhat.com>
Wed, 12 Jun 2002 21:19:43 +0000 (21:19 +0000)
committerAndrew Cagney <cagney@redhat.com>
Wed, 12 Jun 2002 21:19:43 +0000 (21:19 +0000)
register numbering used by the GDB<->SIM interface.

gdb/ChangeLog
gdb/Makefile.in
gdb/arm-tdep.c
include/gdb/ChangeLog
include/gdb/sim-arm.h [new file with mode: 0644]
sim/arm/ChangeLog
sim/arm/Makefile.in
sim/arm/wrapper.c

index af937aaefd7fb478f4e09850cfafec15bb13aec1..19dd9356228811a76c4268a5d737395568791098 100644 (file)
@@ -1,3 +1,12 @@
+2002-06-12  Andrew Cagney  <ac131313@redhat.com>
+
+       * Makefile.in (sim_arm_h): Define.
+       (arm-tdep.o): Add $(sim_arm_h) and $(gdb_assert_h).
+       * arm-tdep.c: Include "gdb/sim-arm.h" and "gdb_assert.h".
+       (arm_register_sim_regno): New function, map an internal REGNUM
+       onto a simulator register number.
+       (arm_gdbarch_init): Set register_sim_regno.
+
 2002-06-09  Aldy Hernandez  <aldyh@redhat.com>
 
        * MAINTAINERS: Add self.
index 1d5492a317faf98d80d0d3f23b9ba1a74c21ac2c..a95117ed200cc27485ee0573d5401d26c474f0a0 100644 (file)
@@ -573,6 +573,7 @@ dis_asm_h = $(INCLUDE_DIR)/dis-asm.h
 remote_sim_h = $(INCLUDE_DIR)/gdb/remote-sim.h
 demangle_h =    $(INCLUDE_DIR)/demangle.h
 obstack_h =     $(INCLUDE_DIR)/obstack.h
+sim_arm_h =    $(INCLUDE_DIR)/gdb/sim-arm.h
 sim_d10v_h =   $(INCLUDE_DIR)/gdb/sim-d10v.h
 splay_tree_h =  $(INCLUDE_DIR)/splay-tree.h
 
@@ -1307,7 +1308,7 @@ arm-tdep.o: arm-tdep.c $(defs_h) $(frame_h) $(inferior_h) $(gdbcmd_h) \
        $(gdbcore_h) $(gdb_string_h) $(dis_asm_h) $(regcache_h) $(doublest_h) \
        $(value_h) $(arch_utils_h) $(solib_svr4_h) $(arm_tdep_h) \
        $(BFD_SRC)/elf-bfd.h $(INCLUDE_DIR)/coff/internal.h \
-       $(INCLUDE_DIR)/elf/arm.h 
+       $(INCLUDE_DIR)/elf/arm.h $(sim_arm_h) $(gdb_assert_h)
 
 armnbsd-nat.o: armnbsd-nat.c $(defs_h) $(arm_tdep_h) $(inferior_h) \
        $(regcache_h) $(gdbcore_h)
index 1ce0a5b56675dd943a9974dfe332976332870398..f4b84fadf3a5540c90647ddc3d1d44fa72ac8510 100644 (file)
 #include "solib-svr4.h"
 
 #include "arm-tdep.h"
+#include "gdb/sim-arm.h"
 
 #include "elf-bfd.h"
 #include "coff/internal.h"
 #include "elf/arm.h"
 
+#include "gdb_assert.h"
+
 /* Each OS has a different mechanism for accessing the various
    registers stored in the sigcontext structure.
 
@@ -1636,6 +1639,27 @@ arm_register_virtual_size (int regnum)
     return STATUS_REGISTER_SIZE;
 }
 
+/* Map GDB internal REGNUM onto the Arm simulator register numbers.  */
+static int
+arm_register_sim_regno (int regnum)
+{
+  int reg = regnum;
+  gdb_assert (reg >= 0 && reg < NUM_REGS);
+
+  if (reg < NUM_GREGS)
+    return SIM_ARM_R0_REGNUM + reg;
+  reg -= NUM_GREGS;
+
+  if (reg < NUM_FREGS)
+    return SIM_ARM_FP0_REGNUM + reg;
+  reg -= NUM_FREGS;
+
+  if (reg < NUM_SREGS)
+    return SIM_ARM_FPS_REGNUM + reg;
+  reg -= NUM_SREGS;
+
+  internal_error (__FILE__, __LINE__, "Bad REGNUM %d", regnum);
+}
 
 /* NOTE: cagney/2001-08-20: Both convert_from_extended() and
    convert_to_extended() use floatformat_arm_ext_littlebyte_bigword.
@@ -2870,6 +2894,9 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches)
   set_gdbarch_max_register_virtual_size (gdbarch, FP_REGISTER_VIRTUAL_SIZE);
   set_gdbarch_register_virtual_type (gdbarch, arm_register_type);
 
+  /* Internal <-> external register number maps.  */
+  set_gdbarch_register_sim_regno (gdbarch, arm_register_sim_regno);
+
   /* Integer registers are 4 bytes.  */
   set_gdbarch_register_size (gdbarch, 4);
   set_gdbarch_register_name (gdbarch, arm_register_name);
index 571861b75cf32f5283aa8fb7f133294723c8a589..0ea02b3f8c452e811675c9c0b3236d74dfe4aa6d 100644 (file)
@@ -1,3 +1,7 @@
+2002-06-12  Andrew Cagney  <ac131313@redhat.com>
+
+       * sim-arm.h: New file.
+
 2002-06-08  Andrew Cagney  <cagney@redhat.com>
 
        * callback.h: Copy to here from directory above.
diff --git a/include/gdb/sim-arm.h b/include/gdb/sim-arm.h
new file mode 100644 (file)
index 0000000..1e49781
--- /dev/null
@@ -0,0 +1,65 @@
+/* This file defines the interface between the Arm simulator and GDB.
+
+   Copyright 2002 Free Software Foundation, Inc.
+
+   Contributed by Red Hat.
+
+   This file is part of GDB.
+
+   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 (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 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., 59 Temple Place - Suite 330, Boston, MA
+   02111-1307, USA.  */
+
+#if !defined (SIM_ARM_H)
+#define SIM_ARM_H
+
+#ifdef __cplusplus
+extern "C" { // }
+#endif
+
+enum sim_arm_regnum
+{
+  SIM_ARM_R0_REGNUM,
+  SIM_ARM_R1_REGNUM,
+  SIM_ARM_R2_REGNUM,
+  SIM_ARM_R3_REGNUM,
+  SIM_ARM_R4_REGNUM,
+  SIM_ARM_R5_REGNUM,
+  SIM_ARM_R6_REGNUM,
+  SIM_ARM_R7_REGNUM,
+  SIM_ARM_R8_REGNUM,
+  SIM_ARM_R9_REGNUM,
+  SIM_ARM_R10_REGNUM,
+  SIM_ARM_R11_REGNUM,
+  SIM_ARM_R12_REGNUM,
+  SIM_ARM_R13_REGNUM,
+  SIM_ARM_R14_REGNUM,
+  SIM_ARM_R15_REGNUM, /* PC */
+  SIM_ARM_FP0_REGNUM,
+  SIM_ARM_FP1_REGNUM,
+  SIM_ARM_FP2_REGNUM,
+  SIM_ARM_FP3_REGNUM,
+  SIM_ARM_FP4_REGNUM,
+  SIM_ARM_FP5_REGNUM,
+  SIM_ARM_FP6_REGNUM,
+  SIM_ARM_FP7_REGNUM,
+  SIM_ARM_FPS_REGNUM,
+  SIM_ARM_PS_REGNUM
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
index f7dfd133ca400f5b176c1b1e59a65c909e220973..f9f7160adb2fe121e31cb3dc883ba5e03f961d74 100644 (file)
@@ -1,3 +1,11 @@
+2002-06-12  Andrew Cagney  <ac131313@redhat.com>
+
+       * Makefile.in: Update copyright.
+       (wrapper.o): Specify dependencies.
+       * wrapper.c: Include "gdb/sim-arm.h".
+       (sim_store_register, sim_fetch_register): Rewrite using `enum
+       arm_sim_regs' and a switch.
+
 2002-06-09  Andrew Cagney  <cagney@redhat.com>
 
        * wrapper.c: Include "gdb/callback.h" and "gdb/remote-sim.h".
index 79bbc88d6c392083a7068db11fb6d383bd1f7a1a..0da765fd7035ca1835d1ebc248aae16f964f0a48 100644 (file)
@@ -1,5 +1,5 @@
 #    Makefile template for Configure for the arm sim library.
-#    Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+#    Copyright 1995, 1996, 1997, 2002 Free Software Foundation, Inc.
 #    Written by Cygnus Support.
 # 
 # This program is free software; you can redistribute it and/or modify
@@ -48,3 +48,9 @@ armsupp.o: armsupp.c armdefs.h armemu.h
 thumbemu.o: thumbemu.c armdefs.h armemu.h
 
 bag.o: bag.c bag.h
+
+wrapper.o: armdefs.h armemu.h dbg_rdi.h \
+       $(srcdir)/../common/run-sim.h \
+       $(srcdir)/../common/sim-utils.h \
+       $(srcdir)/../../include/gdb/sim-arm.h \
+       $(srcdir)/../../include/gdb/remote-sim.h
index 9aa462ebb983d840f25120c4ca060d7191238320..c8361ba9faea2b6b770bd93c48affba2bd286607 100644 (file)
@@ -36,6 +36,7 @@
 #include "ansidecl.h"
 #include "sim-utils.h"
 #include "run-sim.h"
+#include "gdb/sim-arm.h"
 
 host_callback *sim_callback;
 
@@ -386,13 +387,45 @@ sim_store_register (sd, rn, memory, length)
 {
   init ();
 
-  if (rn == 25)
+  switch ((enum sim_arm_regs) rn)
     {
+    case SIM_ARM_R0_REGNUM:
+    case SIM_ARM_R1_REGNUM:
+    case SIM_ARM_R2_REGNUM:
+    case SIM_ARM_R3_REGNUM:
+    case SIM_ARM_R4_REGNUM:
+    case SIM_ARM_R5_REGNUM:
+    case SIM_ARM_R6_REGNUM:
+    case SIM_ARM_R7_REGNUM:
+    case SIM_ARM_R8_REGNUM:
+    case SIM_ARM_R9_REGNUM:
+    case SIM_ARM_R10_REGNUM:
+    case SIM_ARM_R11_REGNUM:
+    case SIM_ARM_R12_REGNUM:
+    case SIM_ARM_R13_REGNUM:
+    case SIM_ARM_R14_REGNUM:
+    case SIM_ARM_R15_REGNUM: /* PC */
+    case SIM_ARM_FP0_REGNUM:
+    case SIM_ARM_FP1_REGNUM:
+    case SIM_ARM_FP2_REGNUM:
+    case SIM_ARM_FP3_REGNUM:
+    case SIM_ARM_FP4_REGNUM:
+    case SIM_ARM_FP5_REGNUM:
+    case SIM_ARM_FP6_REGNUM:
+    case SIM_ARM_FP7_REGNUM:
+    case SIM_ARM_FPS_REGNUM:
+      ARMul_SetReg (state, state->Mode, rn, frommem (state, memory));
+      break;
+
+    case SIM_ARM_PS_REGNUM:
       state->Cpsr = frommem (state, memory);
       ARMul_CPSRAltered (state);
+      break;
+
+    default:
+      return 0;
     }
-  else
-    ARMul_SetReg (state, state->Mode, rn, frommem (state, memory));
+
   return -1;
 }
 
@@ -407,14 +440,46 @@ sim_fetch_register (sd, rn, memory, length)
 
   init ();
 
-  if (rn < 16)
-    regval = ARMul_GetReg (state, state->Mode, rn);
-  else if (rn == 25)
-    /* FIXME: use PS_REGNUM from gdb/config/arm/tm-arm.h.  */
-    regval = ARMul_GetCPSR (state);
-  else
-    /* FIXME: should report an error.  */
-    regval = 0;
+  switch ((enum sim_arm_regs) rn)
+    {
+    case SIM_ARM_R0_REGNUM:
+    case SIM_ARM_R1_REGNUM:
+    case SIM_ARM_R2_REGNUM:
+    case SIM_ARM_R3_REGNUM:
+    case SIM_ARM_R4_REGNUM:
+    case SIM_ARM_R5_REGNUM:
+    case SIM_ARM_R6_REGNUM:
+    case SIM_ARM_R7_REGNUM:
+    case SIM_ARM_R8_REGNUM:
+    case SIM_ARM_R9_REGNUM:
+    case SIM_ARM_R10_REGNUM:
+    case SIM_ARM_R11_REGNUM:
+    case SIM_ARM_R12_REGNUM:
+    case SIM_ARM_R13_REGNUM:
+    case SIM_ARM_R14_REGNUM:
+    case SIM_ARM_R15_REGNUM: /* PC */
+      regval = ARMul_GetReg (state, state->Mode, rn);
+      break;
+
+    case SIM_ARM_FP0_REGNUM:
+    case SIM_ARM_FP1_REGNUM:
+    case SIM_ARM_FP2_REGNUM:
+    case SIM_ARM_FP3_REGNUM:
+    case SIM_ARM_FP4_REGNUM:
+    case SIM_ARM_FP5_REGNUM:
+    case SIM_ARM_FP6_REGNUM:
+    case SIM_ARM_FP7_REGNUM:
+    case SIM_ARM_FPS_REGNUM:
+      memset (memory, 0, length);
+      return 0;
+
+    case SIM_ARM_PS_REGNUM:
+      regval = ARMul_GetCPSR (state);
+      break;
+
+    default:
+      return 0;
+    }
 
   while (length)
     {