From 9e6978753df24726a73667b293ac7f0cc94a2fcb Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Wed, 29 Sep 2021 10:14:52 -0600 Subject: [PATCH] Avoid self-test failures on x86-linux The disassembly tests in "maint selftest" will fail on x86-linux. This happens because opcodes rejects an attempt to disassemble for an arch with a 64-bit address size when bfd_vma is 32-bit. This patch avoids this problem by avoiding the test in this case. I chose to do it this way because this seems to be the only situation where opcodes checks the size of bfd_vma. For v2 of this patch, I've also updated memory_error_test to do the same thing. This is needed due to the "improve error reporting from the disassembler" patch. --- gdb/disasm-selftests.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/gdb/disasm-selftests.c b/gdb/disasm-selftests.c index 0a383d6b795..59c09c98381 100644 --- a/gdb/disasm-selftests.c +++ b/gdb/disasm-selftests.c @@ -85,8 +85,19 @@ print_one_insn_test (struct gdbarch *gdbarch) /* PR 21003 */ if (gdbarch_bfd_arch_info (gdbarch)->mach == bfd_mach_arc_arc601) return; + goto generic_case; + case bfd_arch_i386: + { + const struct bfd_arch_info *info = gdbarch_bfd_arch_info (gdbarch); + /* The disassembly tests will fail on x86-linux because + opcodes rejects an attempt to disassemble for an arch with + a 64-bit address size when bfd_vma is 32-bit. */ + if (info->bits_per_address > sizeof (bfd_vma) * CHAR_BIT) + return; + } /* fall through */ default: + generic_case: { /* Test disassemble breakpoint instruction. */ CORE_ADDR pc = 0; @@ -187,6 +198,16 @@ memory_error_test (struct gdbarch *gdbarch) } }; + if (gdbarch_bfd_arch_info (gdbarch)->arch == bfd_arch_i386) + { + const struct bfd_arch_info *info = gdbarch_bfd_arch_info (gdbarch); + /* This test will fail on x86-linux because opcodes rejects an + attempt to disassemble for an arch with a 64-bit address size + when bfd_vma is 32-bit. */ + if (info->bits_per_address > sizeof (bfd_vma) * CHAR_BIT) + return; + } + gdb_disassembler_test di (gdbarch); bool saw_memory_error = false; -- 2.30.2