aboutsummaryrefslogtreecommitdiff
path: root/gdb/arm-tdep.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2021-09-13 20:16:36 +0200
committerTom de Vries <tdevries@suse.de>2021-09-13 20:16:36 +0200
commit3047c7869d38d4d7f84720d815d31085f3c788fa (patch)
treef4acc1d3c2c07c549a46ccb48c01ac43f15e0ac3 /gdb/arm-tdep.c
parentcad152f2211282b938f11b021f2acf3df517557e (diff)
downloadgdb-3047c7869d38d4d7f84720d815d31085f3c788fa.zip
gdb-3047c7869d38d4d7f84720d815d31085f3c788fa.tar.gz
gdb-3047c7869d38d4d7f84720d815d31085f3c788fa.tar.bz2
[gdb/tdep] Fix exec check in gdb_print_insn_arm
With a gdb build with --enable-targets=all we run into a KFAIL: ... KFAIL: gdb.gdb/unittest.exp: executable loaded: maintenance selftest, \ failed none (PRMS: gdb/27891) ... due to: ... Running selftest print_one_insn.^M Self test failed: arch armv8.1-m.main: self-test failed at \ disasm-selftests.c:165^M ... The test fails because we expect disassembling of one arm insn to consume 4 bytes and produce (using verbose = true in disasm-selftests.c): ... arm mov r0, #0 ... but instead the disassembler uses thumb mode and only consumes 2 bytes and produces: ... arm movs r0, r0 ... The failure does not show up in the "no executable loaded" variant because this code in gdb_print_insn_arm isn't triggered: ... if (current_program_space->exec_bfd () != NULL) info->flags |= USER_SPECIFIED_MACHINE_TYPE; ... and consequently we do this in print_insn: ... if ((info->flags & USER_SPECIFIED_MACHINE_TYPE) == 0) info->mach = bfd_mach_arm_unknown; ... and don't set force_thumb to true in select_arm_features. The code in gdb_print_insn_arm makes the assumption that the disassembly architecture matches the exec architecture, which in this case is incorrect, because the exec architecture is x86_64, and the disassembly architecture is armv8.1-m.main. Fix that by explicitly checking it: ... if (current_program_space->exec_bfd () != NULL && (current_program_space->exec_bfd ()->arch_info == gdbarch_bfd_arch_info (gdbarch))) ... This fixes the print_one_insn failure, so remove the KFAIL. Tested on x86_64-linux. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27891
Diffstat (limited to 'gdb/arm-tdep.c')
-rw-r--r--gdb/arm-tdep.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index e4e7aec..ab6999a 100644
--- a/gdb/arm-tdep.c
+++ b/gdb/arm-tdep.c
@@ -7727,7 +7727,9 @@ gdb_print_insn_arm (bfd_vma memaddr, disassemble_info *info)
the assert on the mismatch of info->mach and
bfd_get_mach (current_program_space->exec_bfd ()) in
default_print_insn. */
- if (current_program_space->exec_bfd () != NULL)
+ if (current_program_space->exec_bfd () != NULL
+ && (current_program_space->exec_bfd ()->arch_info
+ == gdbarch_bfd_arch_info (gdbarch)))
info->flags |= USER_SPECIFIED_MACHINE_TYPE;
return default_print_insn (memaddr, info);