From 25f8c692704d6713c7a13d11069bc70b6d758ceb Mon Sep 17 00:00:00 2001 From: Jonathan Larmour Date: Thu, 15 Mar 2012 18:53:43 +0000 Subject: [PATCH] * arm-tdep.c: Include "remote.h" and "features/arm-with-m-fpa-layout.c". (arm_register_g_packet_guesses): New function. (arm_gdbarch_init): Don't force a target description with registers when the executable is detected as M-profile. Instead set gdbarch->tdep->is_m. Register `g' packet guesses. (_initialize_arm_tdep): Initialize the new target description. * features/arm-with-m-fpa-layout.xml: New description. * features/arm-with-m-fpa-layout.c: New, generated. --- gdb/ChangeLog | 12 +++++++ gdb/arm-tdep.c | 42 +++++++++++++++++++++++- gdb/features/arm-with-m-fpa-layout.c | 44 +++++++++++++++++++++++++ gdb/features/arm-with-m-fpa-layout.xml | 45 ++++++++++++++++++++++++++ 4 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 gdb/features/arm-with-m-fpa-layout.c create mode 100644 gdb/features/arm-with-m-fpa-layout.xml diff --git a/gdb/ChangeLog b/gdb/ChangeLog index 875d6757d49..476431539a1 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,3 +1,15 @@ +2012-03-15 Jonathan Larmour + Pedro Alves + + * arm-tdep.c: Include "remote.h" and "features/arm-with-m-fpa-layout.c". + (arm_register_g_packet_guesses): New function. + (arm_gdbarch_init): Don't force a target description with + registers when the executable is detected as M-profile. Instead + set gdbarch->tdep->is_m. Register `g' packet guesses. + (_initialize_arm_tdep): Initialize the new target description. + * features/arm-with-m-fpa-layout.xml: New description. + * features/arm-with-m-fpa-layout.c: New, generated. + 2012-03-15 Joel Brobecker * breakpoint.c (breakpoint_xfer_memory): Add assertion. diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c index b4da01d8e7e..a3cdc7c495c 100644 --- a/gdb/arm-tdep.c +++ b/gdb/arm-tdep.c @@ -40,6 +40,7 @@ #include "dwarf2-frame.h" #include "gdbtypes.h" #include "prologue-value.h" +#include "remote.h" #include "target-descriptions.h" #include "user-regs.h" #include "observer.h" @@ -55,6 +56,7 @@ #include "vec.h" #include "features/arm-with-m.c" +#include "features/arm-with-m-fpa-layout.c" #include "features/arm-with-iwmmxt.c" #include "features/arm-with-vfpv2.c" #include "features/arm-with-vfpv3.c" @@ -9664,6 +9666,41 @@ arm_register_reggroup_p (struct gdbarch *gdbarch, int regnum, return default_register_reggroup_p (gdbarch, regnum, group); } + +/* For backward-compatibility we allow two 'g' packet lengths with + the remote protocol depending on whether FPA registers are + supplied. M-profile targets do not have FPA registers, but some + stubs already exist in the wild which use a 'g' packet which + supplies them albeit with dummy values. The packet format which + includes FPA registers should be considered deprecated for + M-profile targets. */ + +static void +arm_register_g_packet_guesses (struct gdbarch *gdbarch) +{ + if (gdbarch_tdep (gdbarch)->is_m) + { + /* If we know from the executable this is an M-profile target, + cater for remote targets whose register set layout is the + same as the FPA layout. */ + register_remote_g_packet_guess (gdbarch, + /* r0-r12,sp,lr,pc; f0-f7; fps,cpsr */ + (16 * INT_REGISTER_SIZE) + + (8 * FP_REGISTER_SIZE) + + (2 * INT_REGISTER_SIZE), + tdesc_arm_with_m_fpa_layout); + + /* The regular M-profile layout. */ + register_remote_g_packet_guess (gdbarch, + /* r0-r12,sp,lr,pc; xpsr */ + (16 * INT_REGISTER_SIZE) + + INT_REGISTER_SIZE, + tdesc_arm_with_m); + } + + /* Otherwise we don't have a useful guess. */ +} + /* Initialize the current architecture based on INFO. If possible, re-use an architecture from ARCHES, which is a list of @@ -9798,7 +9835,7 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) && (attr_arch == TAG_CPU_ARCH_V6_M || attr_arch == TAG_CPU_ARCH_V6S_M || attr_profile == 'M')) - tdesc = tdesc_arm_with_m; + is_m = 1; #endif } @@ -10055,6 +10092,8 @@ arm_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) tdep->have_neon_pseudos = have_neon_pseudos; tdep->have_neon = have_neon; + arm_register_g_packet_guesses (gdbarch); + /* Breakpoints. */ switch (info.byte_order_for_code) { @@ -10291,6 +10330,7 @@ _initialize_arm_tdep (void) /* Initialize the standard target descriptions. */ initialize_tdesc_arm_with_m (); + initialize_tdesc_arm_with_m_fpa_layout (); initialize_tdesc_arm_with_iwmmxt (); initialize_tdesc_arm_with_vfpv2 (); initialize_tdesc_arm_with_vfpv3 (); diff --git a/gdb/features/arm-with-m-fpa-layout.c b/gdb/features/arm-with-m-fpa-layout.c new file mode 100644 index 00000000000..ad9b75d8018 --- /dev/null +++ b/gdb/features/arm-with-m-fpa-layout.c @@ -0,0 +1,44 @@ +/* THIS FILE IS GENERATED. Original: arm-with-m-fpa-layout.xml */ + +#include "defs.h" +#include "osabi.h" +#include "target-descriptions.h" + +struct target_desc *tdesc_arm_with_m_fpa_layout; +static void +initialize_tdesc_arm_with_m_fpa_layout (void) +{ + struct target_desc *result = allocate_target_description (); + struct tdesc_feature *feature; + struct tdesc_type *field_type, *type; + + feature = tdesc_create_feature (result, "org.gnu.gdb.arm.m-profile"); + tdesc_create_reg (feature, "r0", 0, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r1", 1, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r2", 2, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r3", 3, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r4", 4, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r5", 5, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r6", 6, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r7", 7, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r8", 8, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r9", 9, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r10", 10, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r11", 11, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "r12", 12, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "sp", 13, 1, NULL, 32, "data_ptr"); + tdesc_create_reg (feature, "lr", 14, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "pc", 15, 1, NULL, 32, "code_ptr"); + tdesc_create_reg (feature, "", 16, 1, NULL, 96, "arm_fpa_ext"); + tdesc_create_reg (feature, "", 17, 1, NULL, 96, "arm_fpa_ext"); + tdesc_create_reg (feature, "", 18, 1, NULL, 96, "arm_fpa_ext"); + tdesc_create_reg (feature, "", 19, 1, NULL, 96, "arm_fpa_ext"); + tdesc_create_reg (feature, "", 20, 1, NULL, 96, "arm_fpa_ext"); + tdesc_create_reg (feature, "", 21, 1, NULL, 96, "arm_fpa_ext"); + tdesc_create_reg (feature, "", 22, 1, NULL, 96, "arm_fpa_ext"); + tdesc_create_reg (feature, "", 23, 1, NULL, 96, "arm_fpa_ext"); + tdesc_create_reg (feature, "", 24, 1, NULL, 32, "int"); + tdesc_create_reg (feature, "xpsr", 25, 1, NULL, 32, "int"); + + tdesc_arm_with_m_fpa_layout = result; +} diff --git a/gdb/features/arm-with-m-fpa-layout.xml b/gdb/features/arm-with-m-fpa-layout.xml new file mode 100644 index 00000000000..e3a114966ac --- /dev/null +++ b/gdb/features/arm-with-m-fpa-layout.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.30.2