From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [committed][gdb/tdep] Fix exec check in gdb_print_insn_arm
Date: Mon, 13 Sep 2021 20:20:42 +0200 [thread overview]
Message-ID: <20210913182036.GA15450@delia.home> (raw)
Hi,
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
Committed to trunk. Approved in bugzilla by Luis.
Thanks,
- Tom
[gdb/tdep] Fix exec check in gdb_print_insn_arm
---
gdb/arm-tdep.c | 4 +++-
gdb/testsuite/gdb.gdb/unittest.exp | 7 -------
2 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c
index e4e7aec4e1c..ab6999ae209 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);
diff --git a/gdb/testsuite/gdb.gdb/unittest.exp b/gdb/testsuite/gdb.gdb/unittest.exp
index 61a6c0efb4b..3622243492c 100644
--- a/gdb/testsuite/gdb.gdb/unittest.exp
+++ b/gdb/testsuite/gdb.gdb/unittest.exp
@@ -51,13 +51,6 @@ proc run_selftests { binfile } {
set num_ran $expect_out(1,string)
set num_failed $expect_out(2,string)
gdb_assert "$num_ran > 0" "$test, ran some tests"
-
- if { $binfile != "" } {
- # There's a known issue here (see PR gdb/27891),
- # however, we should not have more than 1 failure.
- gdb_assert "$num_failed <= 1" "$test, failed no more than 1"
- setup_kfail "gdb/27891" "*-*-*"
- }
gdb_assert "$num_failed == 0" "$test, failed none"
}
-re "Selftests have been disabled for this build.\r\n$gdb_prompt $" {
reply other threads:[~2021-09-13 18:21 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210913182036.GA15450@delia.home \
--to=gdb-patches@sourceware.org \
--cc=tdevries@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox