From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26040 invoked by alias); 30 May 2002 02:08:44 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 25809 invoked from network); 30 May 2002 02:08:33 -0000 Received: from unknown (HELO localhost.redhat.com) (24.112.240.27) by sources.redhat.com with SMTP; 30 May 2002 02:08:33 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id C92B73D49 for ; Wed, 29 May 2002 22:08:44 -0400 (EDT) Message-ID: <3CF589AC.7020900@cygnus.com> Date: Wed, 29 May 2002 20:10:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0rc2) Gecko/20020518 X-Accept-Language: en-us, en MIME-Version: 1.0 To: gdb-patches@sources.redhat.com Subject: [rfa:sim/arm,arm] Add include/gdb/sim-arm.h Content-Type: multipart/mixed; boundary="------------010403060704070003020102" X-SW-Source: 2002-05/txt/msg01016.txt.bz2 This is a multi-part message in MIME format. --------------010403060704070003020102 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Content-length: 305 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 --------------010403060704070003020102 Content-Type: text/plain; name="diffs" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="diffs" Content-length: 10506 Index: gdb/ChangeLog 2002-05-29 Andrew Cagney * 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 * sim-arm.h: New file. Index: sim/arm/ChangeLog 2002-05-29 Andrew Cagney * 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 + + * sim-arm.h: New file. + 2002-05-23 Andrew Cagney * 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 + + * 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 * 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) { --------------010403060704070003020102--