Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom Tromey via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tromey@adacore.com>
Subject: [PATCH v2] Avoid self-test failures on x86-linux
Date: Mon, 18 Oct 2021 13:43:08 -0600	[thread overview]
Message-ID: <20211018194308.177367-1-tromey@adacore.com> (raw)

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


             reply	other threads:[~2021-10-18 19:43 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-18 19:43 Tom Tromey via Gdb-patches [this message]
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

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=20211018194308.177367-1-tromey@adacore.com \
    --to=gdb-patches@sourceware.org \
    --cc=tromey@adacore.com \
    /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