aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gdb/ChangeLog9
-rw-r--r--gdb/Makefile.in3
-rw-r--r--gdb/arm-tdep.c27
-rw-r--r--include/gdb/ChangeLog4
-rw-r--r--include/gdb/sim-arm.h65
-rw-r--r--sim/arm/ChangeLog8
-rw-r--r--sim/arm/Makefile.in8
-rw-r--r--sim/arm/wrapper.c87
8 files changed, 198 insertions, 13 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index af937aa..19dd935 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -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.
diff --git a/gdb/Makefile.in b/gdb/Makefile.in
index 1d5492a..a95117e 100644
--- a/gdb/Makefile.in
+++ b/gdb/Makefile.in
@@ -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)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index 1ce0a5b..f4b84fa 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -36,11 +36,14 @@
#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);
diff --git a/include/gdb/ChangeLog b/include/gdb/ChangeLog
index 571861b..0ea02b3 100644
--- a/include/gdb/ChangeLog
+++ b/include/gdb/ChangeLog
@@ -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
index 0000000..1e49781
--- /dev/null
+++ b/include/gdb/sim-arm.h
@@ -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
diff --git a/sim/arm/ChangeLog b/sim/arm/ChangeLog
index f7dfd13..f9f7160 100644
--- a/sim/arm/ChangeLog
+++ b/sim/arm/ChangeLog
@@ -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".
diff --git a/sim/arm/Makefile.in b/sim/arm/Makefile.in
index 79bbc88..0da765f 100644
--- a/sim/arm/Makefile.in
+++ b/sim/arm/Makefile.in
@@ -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
diff --git a/sim/arm/wrapper.c b/sim/arm/wrapper.c
index 9aa462e..c8361ba 100644
--- a/sim/arm/wrapper.c
+++ b/sim/arm/wrapper.c
@@ -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)
{