public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2] Avoid self-test failures on x86-linux
@ 2021-10-18 19:43 Tom Tromey
  2021-10-29 13:31 ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 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

* Re: [PATCH v2] Avoid self-test failures on x86-linux
  2021-10-18 19:43 [PATCH v2] Avoid self-test failures on x86-linux Tom Tromey
@ 2021-10-29 13:31 ` Tom Tromey
  2021-10-29 14:28   ` Luis Machado
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2021-10-29 13:31 UTC (permalink / raw)
  To: Tom Tromey via Gdb-patches; +Cc: Tom Tromey

>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:

Tom> The disassembly tests in "maint selftest" will fail on x86-linux.
Tom> This happens because opcodes rejects an attempt to disassemble for an
Tom> arch with a 64-bit address size when bfd_vma is 32-bit.

Tom> This patch avoids this problem by avoiding the test in this case.  I
Tom> chose to do it this way because this seems to be the only situation
Tom> where opcodes checks the size of bfd_vma.

Tom> For v2 of this patch, I've also updated memory_error_test to do the
Tom> same thing.  This is needed due to the "improve error reporting from
Tom> the disassembler" patch.

I'm checking this in.

Tom

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

* Re: [PATCH v2] Avoid self-test failures on x86-linux
  2021-10-29 13:31 ` Tom Tromey
@ 2021-10-29 14:28   ` Luis Machado
  2021-10-29 14:47     ` Tom Tromey
  0 siblings, 1 reply; 5+ messages in thread
From: Luis Machado @ 2021-10-29 14:28 UTC (permalink / raw)
  To: Tom Tromey, Tom Tromey via Gdb-patches

On 10/29/21 10:31 AM, Tom Tromey via Gdb-patches wrote:
>>>>>> "Tom" == Tom Tromey via Gdb-patches <gdb-patches@sourceware.org> writes:
> 
> Tom> The disassembly tests in "maint selftest" will fail on x86-linux.
> Tom> This happens because opcodes rejects an attempt to disassemble for an
> Tom> arch with a 64-bit address size when bfd_vma is 32-bit.
> 
> Tom> This patch avoids this problem by avoiding the test in this case.  I
> Tom> chose to do it this way because this seems to be the only situation
> Tom> where opcodes checks the size of bfd_vma.
> 
> Tom> For v2 of this patch, I've also updated memory_error_test to do the
> Tom> same thing.  This is needed due to the "improve error reporting from
> Tom> the disassembler" patch.
> 
> I'm checking this in.
> 
> Tom
> 

Isn't this a broader issue? I recently reported some failures in the 
gdb.base/all-architectures-2.exp, where disassembling fails due to 
(apparently) some recent changes in error reporting.

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

* Re: [PATCH v2] Avoid self-test failures on x86-linux
  2021-10-29 14:28   ` Luis Machado
@ 2021-10-29 14:47     ` Tom Tromey
  2021-10-29 14:51       ` Luis Machado
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Tromey @ 2021-10-29 14:47 UTC (permalink / raw)
  To: Luis Machado; +Cc: Tom Tromey, Tom Tromey via Gdb-patches

Luis> Isn't this a broader issue? I recently reported some failures in the
Luis> gdb.base/all-architectures-2.exp, where disassembling fails due to 
Luis> (apparently) some recent changes in error reporting.

Do you have a link?

I've only run into this particular problem, and when I wrote the fix, I
looked through opcodes to find other similar instances, and didn't find
any.

Tom

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

* Re: [PATCH v2] Avoid self-test failures on x86-linux
  2021-10-29 14:47     ` Tom Tromey
@ 2021-10-29 14:51       ` Luis Machado
  0 siblings, 0 replies; 5+ messages in thread
From: Luis Machado @ 2021-10-29 14:51 UTC (permalink / raw)
  To: Tom Tromey; +Cc: Tom Tromey via Gdb-patches, andrew.burgess

On 10/29/21 11:47 AM, Tom Tromey wrote:
> Luis> Isn't this a broader issue? I recently reported some failures in the
> Luis> gdb.base/all-architectures-2.exp, where disassembling fails due to
> Luis> (apparently) some recent changes in error reporting.
> 
> Do you have a link?

I haven't filed a PR yet. I pinged Andrew about it on IRC to check if 
that was intended behavior or not.
> 
> I've only run into this particular problem, and when I wrote the fix, I
> looked through opcodes to find other similar instances, and didn't find
> any.

It is not immediately obvious that the gdb.base/all-architectures*.exp 
failures are related to disassembler self tests. I wouldn't expect so, 
given those tests invoke "disassemble" explicitly.

^ 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
2021-10-29 13:31 ` Tom Tromey
2021-10-29 14:28   ` Luis Machado
2021-10-29 14:47     ` Tom Tromey
2021-10-29 14:51       ` Luis Machado

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).