* [rfa:sim/arm,arm] Add include/gdb/sim-arm.h
@ 2002-05-29 20:10 Andrew Cagney
2002-06-12 5:54 ` Richard Earnshaw
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2002-05-29 20:10 UTC (permalink / raw)
To: gdb-patches
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
Hello,
The attached patch better pins down the ARM <-> SIM interface by
introducing an enum to specify the register numbers to be used across
the interface.
Ok?
I guess I need to get the sim/arm and arm-tdep maintainers to both agree
agree with each other and agree to the change :-)
enjoy,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 10506 bytes --]
Index: gdb/ChangeLog
2002-05-29 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.
Index: include/gdb/ChangeLog
2002-05-29 Andrew Cagney <ac131313@redhat.com>
* sim-arm.h: New file.
Index: sim/arm/ChangeLog
2002-05-29 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.
Index: gdb/Makefile.in
===================================================================
RCS file: /cvs/src/src/gdb/Makefile.in,v
retrieving revision 1.202
diff -u -r1.202 Makefile.in
--- gdb/Makefile.in 29 May 2002 16:39:53 -0000 1.202
+++ gdb/Makefile.in 30 May 2002 01:50:00 -0000
@@ -572,6 +572,7 @@
remote_sim_h = $(INCLUDE_DIR)/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
@@ -1293,7 +1294,7 @@
$(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: gdb/arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.62
diff -u -r1.62 arm-tdep.c
--- gdb/arm-tdep.c 21 May 2002 15:36:02 -0000 1.62
+++ gdb/arm-tdep.c 30 May 2002 01:50:07 -0000
@@ -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.
@@ -1635,6 +1638,27 @@
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.
@@ -2868,6 +2892,9 @@
set_gdbarch_max_register_raw_size (gdbarch, FP_REGISTER_RAW_SIZE);
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);
Index: include/gdb/ChangeLog
===================================================================
RCS file: /cvs/src/src/include/gdb/ChangeLog,v
retrieving revision 1.4
diff -u -r1.4 ChangeLog
--- include/gdb/ChangeLog 24 May 2002 00:12:18 -0000 1.4
+++ include/gdb/ChangeLog 30 May 2002 01:50:10 -0000
@@ -1,3 +1,7 @@
+2002-05-29 Andrew Cagney <ac131313@redhat.com>
+
+ * sim-arm.h: New file.
+
2002-05-23 Andrew Cagney <ac131313@redhat.com>
* sim-d10v.h: New file. Moved from include/sim-d10v.h.
Index: include/gdb/sim-arm.h
===================================================================
RCS file: include/gdb/sim-arm.h
diff -N include/gdb/sim-arm.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/gdb/sim-arm.h 30 May 2002 01:50:10 -0000
@@ -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: sim/arm/ChangeLog
===================================================================
RCS file: /cvs/src/src/sim/arm/ChangeLog,v
retrieving revision 1.59
diff -u -r1.59 ChangeLog
--- sim/arm/ChangeLog 29 May 2002 19:01:36 -0000 1.59
+++ sim/arm/ChangeLog 30 May 2002 01:50:11 -0000
@@ -1,3 +1,11 @@
+2002-05-29 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-05-29 Nick Clifton <nickc@cambridge.redhat.com>
* armcopro.c (XScale_check_memacc): Set the FSR and FAR registers
Index: sim/arm/Makefile.in
===================================================================
RCS file: /cvs/src/src/sim/arm/Makefile.in,v
retrieving revision 1.4
diff -u -r1.4 Makefile.in
--- sim/arm/Makefile.in 20 May 2002 14:32:48 -0000 1.4
+++ sim/arm/Makefile.in 30 May 2002 01:50:11 -0000
@@ -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 @@
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/remote-sim.h
Index: sim/arm/wrapper.c
===================================================================
RCS file: /cvs/src/src/sim/arm/wrapper.c,v
retrieving revision 1.20
diff -u -r1.20 wrapper.c
--- sim/arm/wrapper.c 27 May 2002 14:12:00 -0000 1.20
+++ sim/arm/wrapper.c 30 May 2002 01:50:11 -0000
@@ -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 @@
{
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 @@
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)
{
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfa:sim/arm,arm] Add include/gdb/sim-arm.h
2002-05-29 20:10 [rfa:sim/arm,arm] Add include/gdb/sim-arm.h Andrew Cagney
@ 2002-06-12 5:54 ` Richard Earnshaw
2002-06-12 9:18 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Richard Earnshaw @ 2002-06-12 5:54 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches, Richard.Earnshaw
> Hello,
>
> The attached patch better pins down the ARM <-> SIM interface by
> introducing an enum to specify the register numbers to be used across
> the interface.
>
> Ok?
>
> I guess I need to get the sim/arm and arm-tdep maintainers to both agree
> agree with each other and agree to the change :-)
It looks ok to me, if Nick is also happy with it.
Of course, I'll have to change it all when I add the privileged mode
registers ;-)
R.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfa:sim/arm,arm] Add include/gdb/sim-arm.h
2002-06-12 5:54 ` Richard Earnshaw
@ 2002-06-12 9:18 ` Andrew Cagney
2002-06-12 9:28 ` Nick Clifton
0 siblings, 1 reply; 5+ messages in thread
From: Andrew Cagney @ 2002-06-12 9:18 UTC (permalink / raw)
To: Richard.Earnshaw; +Cc: gdb-patches, Nick Clifton
> Hello,
>>
>> The attached patch better pins down the ARM <-> SIM interface by
>> introducing an enum to specify the register numbers to be used across
>> the interface.
>>
>> Ok?
>>
>> I guess I need to get the sim/arm and arm-tdep maintainers to both agree
>> agree with each other and agree to the change :-)
>
>
> It looks ok to me, if Nick is also happy with it.
>
> Of course, I'll have to change it all when I add the privileged mode
> registers ;-)
That's the idea. At least you can now change it all without breaking it
all :-)
Nick?
Andrew
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfa:sim/arm,arm] Add include/gdb/sim-arm.h
2002-06-12 9:18 ` Andrew Cagney
@ 2002-06-12 9:28 ` Nick Clifton
2002-06-12 14:23 ` Andrew Cagney
0 siblings, 1 reply; 5+ messages in thread
From: Nick Clifton @ 2002-06-12 9:28 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Richard.Earnshaw, gdb-patches
Hi Andrew,
> That's the idea. At least you can now change it all without breaking
> it all :-)
>
> Nick?
Fine with me, :-)
Cheers
Nick
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [rfa:sim/arm,arm] Add include/gdb/sim-arm.h
2002-06-12 9:28 ` Nick Clifton
@ 2002-06-12 14:23 ` Andrew Cagney
0 siblings, 0 replies; 5+ messages in thread
From: Andrew Cagney @ 2002-06-12 14:23 UTC (permalink / raw)
To: Nick Clifton; +Cc: Richard.Earnshaw, gdb-patches
Thanks! I've checked this in.
Andrew
> Index: gdb/ChangeLog
> 2002-05-29 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.
>
> Index: include/gdb/ChangeLog
> 2002-05-29 Andrew Cagney <ac131313@redhat.com>
>
> * sim-arm.h: New file.
>
> Index: sim/arm/ChangeLog
> 2002-05-29 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.
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-06-12 21:23 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-05-29 20:10 [rfa:sim/arm,arm] Add include/gdb/sim-arm.h Andrew Cagney
2002-06-12 5:54 ` Richard Earnshaw
2002-06-12 9:18 ` Andrew Cagney
2002-06-12 9:28 ` Nick Clifton
2002-06-12 14:23 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox