From 5c941edc7b0d6e0bed596293d81867453d1462e9 Mon Sep 17 00:00:00 2001 From: Antonio Borneo Date: Thu, 1 Nov 2018 14:50:27 +0100 Subject: [PATCH] target/arm: add support for multi-architecture gdb GDB can be built for multi-architecture through the command ./configure --enable-targets=all && make Such multi-architecture GDB requires the target's architecture to be selected either manually by the user through the GDB command "set architecture" or automatically by the target description sent by the remote target (i.e. OpenOCD). Commit e65acd889c61a424c7bd72fdee5d6a3aee1d8504 ("gdb_server: add support for architecture element") already provides the required infrastructure to support multi-architecture gdb. arm-none-eabi-gdb 8.2 uses "arm" as default architecture, but also supports the following values: "arm_any", "armv2", "armv2a", "armv3", "armv3m", "armv4", "armv4t", "armv5", "armv5t", "armv5te", "armv5tej", "armv6", "armv6k", "armv6kz", "armv6-m", "armv6s-m", "armv6t2", "armv7", "armv7e-m", "armv8-a", "armv8-m.base", "armv8-m.main", "armv8-r", "ep9312", "iwmmxt", "iwmmxt2", "xscale". These values can be displayed on arm gdb prompt by typing "set architecture " followed by a TAB for autocompletion. Set the gdb architecture value for all arm targets to "arm". Change-Id: I176cb89878606e1febd546ce26543b3e7849500a Signed-off-by: Antonio Borneo Reviewed-on: http://openocd.zylin.com/4754 Tested-by: jenkins Reviewed-by: Spencer Oliver --- src/target/arm.h | 1 + src/target/arm11.c | 1 + src/target/arm720t.c | 1 + src/target/arm7tdmi.c | 1 + src/target/arm920t.c | 1 + src/target/arm926ejs.c | 1 + src/target/arm946e.c | 1 + src/target/arm966e.c | 1 + src/target/arm9tdmi.c | 1 + src/target/armv4_5.c | 14 ++++++++++++++ src/target/cortex_a.c | 2 ++ src/target/cortex_m.c | 1 + src/target/fa526.c | 1 + src/target/feroceon.c | 2 ++ src/target/hla_target.c | 1 + src/target/xscale.c | 1 + 16 files changed, 31 insertions(+) diff --git a/src/target/arm.h b/src/target/arm.h index 316ff9ab8..10a053ced 100644 --- a/src/target/arm.h +++ b/src/target/arm.h @@ -263,6 +263,7 @@ struct reg_cache *armv8_build_reg_cache(struct target *target); extern const struct command_registration arm_command_handlers[]; int arm_arch_state(struct target *target); +const char *arm_get_gdb_arch(struct target *target); int arm_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class); diff --git a/src/target/arm11.c b/src/target/arm11.c index 13fbd207a..443866149 100644 --- a/src/target/arm11.c +++ b/src/target/arm11.c @@ -1362,6 +1362,7 @@ struct target_type arm11_target = { .assert_reset = arm11_assert_reset, .deassert_reset = arm11_deassert_reset, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm11_read_memory, diff --git a/src/target/arm720t.c b/src/target/arm720t.c index bcbfa9dff..3d12aba22 100644 --- a/src/target/arm720t.c +++ b/src/target/arm720t.c @@ -560,6 +560,7 @@ struct target_type arm720t_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm720t_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm720t_read_memory, diff --git a/src/target/arm7tdmi.c b/src/target/arm7tdmi.c index 9dcb302d9..e1e91c3a0 100644 --- a/src/target/arm7tdmi.c +++ b/src/target/arm7tdmi.c @@ -699,6 +699,7 @@ struct target_type arm7tdmi_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm7_9_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm7_9_read_memory, diff --git a/src/target/arm920t.c b/src/target/arm920t.c index 7927a2bea..39d75902c 100644 --- a/src/target/arm920t.c +++ b/src/target/arm920t.c @@ -1693,6 +1693,7 @@ struct target_type arm920t_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm920t_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm920t_read_memory, diff --git a/src/target/arm926ejs.c b/src/target/arm926ejs.c index 58de77850..07c519a53 100644 --- a/src/target/arm926ejs.c +++ b/src/target/arm926ejs.c @@ -804,6 +804,7 @@ struct target_type arm926ejs_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm926ejs_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm7_9_read_memory, diff --git a/src/target/arm946e.c b/src/target/arm946e.c index 06c9fc30d..5e25d71ec 100644 --- a/src/target/arm946e.c +++ b/src/target/arm946e.c @@ -756,6 +756,7 @@ struct target_type arm946e_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm7_9_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, /* .read_memory = arm7_9_read_memory, */ diff --git a/src/target/arm966e.c b/src/target/arm966e.c index 0429c54b5..c9d7f01aa 100644 --- a/src/target/arm966e.c +++ b/src/target/arm966e.c @@ -259,6 +259,7 @@ struct target_type arm966e_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm7_9_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm7_9_read_memory, diff --git a/src/target/arm9tdmi.c b/src/target/arm9tdmi.c index 82b430f88..6425027f4 100644 --- a/src/target/arm9tdmi.c +++ b/src/target/arm9tdmi.c @@ -902,6 +902,7 @@ struct target_type arm9tdmi_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm7_9_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm7_9_read_memory, diff --git a/src/target/armv4_5.c b/src/target/armv4_5.c index 96a63e497..af8fd9a7f 100644 --- a/src/target/armv4_5.c +++ b/src/target/armv4_5.c @@ -1179,6 +1179,20 @@ const struct command_registration arm_command_handlers[] = { COMMAND_REGISTRATION_DONE }; +/* + * gdb for arm targets (e.g. arm-none-eabi-gdb) supports several variants + * of arm architecture. You can list them using the autocompletion of gdb + * command prompt by typing "set architecture " and then press TAB key. + * The default, selected automatically, is "arm". + * Let's use the default value, here, to make gdb-multiarch behave in the + * same way as a gdb for arm. This can be changed later on. User can still + * set the specific architecture variant with the gdb command. + */ +const char *arm_get_gdb_arch(struct target *target) +{ + return "arm"; +} + int arm_get_gdb_reg_list(struct target *target, struct reg **reg_list[], int *reg_list_size, enum target_register_class reg_class) diff --git a/src/target/cortex_a.c b/src/target/cortex_a.c index 0a55a2006..07644fa09 100644 --- a/src/target/cortex_a.c +++ b/src/target/cortex_a.c @@ -3171,6 +3171,7 @@ struct target_type cortexa_target = { .deassert_reset = cortex_a_deassert_reset, /* REVISIT allow exporting VFP3 registers ... */ + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = cortex_a_read_memory, @@ -3250,6 +3251,7 @@ struct target_type cortexr4_target = { .deassert_reset = cortex_a_deassert_reset, /* REVISIT allow exporting VFP3 registers ... */ + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = cortex_a_read_phys_memory, diff --git a/src/target/cortex_m.c b/src/target/cortex_m.c index 4ce776cd0..e8ad770ec 100644 --- a/src/target/cortex_m.c +++ b/src/target/cortex_m.c @@ -2518,6 +2518,7 @@ struct target_type cortexm_target = { .deassert_reset = cortex_m_deassert_reset, .soft_reset_halt = cortex_m_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = armv7m_get_gdb_reg_list, .read_memory = cortex_m_read_memory, diff --git a/src/target/fa526.c b/src/target/fa526.c index 9f6b80551..bb9f7353a 100644 --- a/src/target/fa526.c +++ b/src/target/fa526.c @@ -364,6 +364,7 @@ struct target_type fa526_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm920t_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm920t_read_memory, diff --git a/src/target/feroceon.c b/src/target/feroceon.c index 6b14ab6a8..21963e55e 100644 --- a/src/target/feroceon.c +++ b/src/target/feroceon.c @@ -710,6 +710,7 @@ struct target_type feroceon_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm926ejs_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm7_9_read_memory, @@ -747,6 +748,7 @@ struct target_type dragonite_target = { .deassert_reset = arm7_9_deassert_reset, .soft_reset_halt = arm7_9_soft_reset_halt, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = arm7_9_read_memory, diff --git a/src/target/hla_target.c b/src/target/hla_target.c index 9ebf24168..567a61dc3 100644 --- a/src/target/hla_target.c +++ b/src/target/hla_target.c @@ -820,6 +820,7 @@ struct target_type hla_target = { .resume = adapter_resume, .step = adapter_step, + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = armv7m_get_gdb_reg_list, .read_memory = adapter_read_memory, diff --git a/src/target/xscale.c b/src/target/xscale.c index 87a3d0f78..3ac455390 100644 --- a/src/target/xscale.c +++ b/src/target/xscale.c @@ -3703,6 +3703,7 @@ struct target_type xscale_target = { .deassert_reset = xscale_deassert_reset, /* REVISIT on some cores, allow exporting iwmmxt registers ... */ + .get_gdb_arch = arm_get_gdb_arch, .get_gdb_reg_list = arm_get_gdb_reg_list, .read_memory = xscale_read_memory,