Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH v2] Avoid self-test failures on x86-linux
@ 2021-10-18 19:43 Tom Tromey via Gdb-patches
  2021-10-29 13:31 ` Tom Tromey via Gdb-patches
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey via Gdb-patches @ 2021-10-18 19:43 UTC (permalink / raw)
  To: gdb-patches; +Cc: Tom Tromey

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.31.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-29 14:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-18 19:43 [PATCH v2] Avoid self-test failures on x86-linux Tom Tromey via Gdb-patches
2021-10-29 13:31 ` Tom Tromey via Gdb-patches
2021-10-29 14:28   ` Luis Machado via Gdb-patches
2021-10-29 14:47     ` Tom Tromey via Gdb-patches
2021-10-29 14:51       ` Luis Machado via Gdb-patches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox