Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Tom de Vries via Gdb-patches <gdb-patches@sourceware.org>
To: gdb-patches@sourceware.org
Subject: [committed][gdb/testsuite] Fix gdb.mi/mi-disassemble.exp with -m32
Date: Thu, 13 Oct 2022 09:44:02 +0200	[thread overview]
Message-ID: <20221013074400.GA6454@delia.home> (raw)

Hi,

With target board unix/-m32 and test-case gdb.mi/mi-disassemble.exp we have:
...
(gdb) ^M
print/x *((unsigned char *) 0x8048485)^M
&"print/x *((unsigned char *) 0x8048485)\n"^M
~"$9 = 0x83\n"^M
^done^M
(gdb) ^M
PASS: gdb.mi/mi-disassemble.exp: get valueof "*((unsigned char *) 0x8048485)"
FAIL: gdb.mi/mi-disassemble.exp: byte at 0x8048485 matches
...
The test-case passes with native.

With native we see in gdb.log that variable longest_insn_bytes is:
...
Longest instruction at 0x0000000000400549 with bytes '48 8b 05 20 01 00 00'
...
and variable split_bytes (added debug puts) ends up as:
...
SPLIT_BYTES: 48 8b 05 20 01 00 00
...

But with unix/-m32 we have longest_insn_byte:
...
Longest instruction at 0x08048481 with bytes '8d 4c 24 04        '
...
and split_bytes ends up as:
...
SPLIT_BYTES: 8d 4c 24 04 {} {} {} {} {} {} {} {}
...
so the trailing whitespace is translated by split to empty bytes, and the
mismatch FAILs are generated for those.

Fix this by stripping the whitespace, which makes us end up with a different
and indeed longer insn:
...
Longest instruction at 0x08048492 with bytes 'dd 05 98 85 04 08'
...

Tested on x86_64-linux, with native and target board unix/-m32.

Committed to trunk.

Thanks,
- Tom

[gdb/testsuite] Fix gdb.mi/mi-disassemble.exp with -m32

---
 gdb/testsuite/gdb.mi/mi-disassemble.exp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gdb/testsuite/gdb.mi/mi-disassemble.exp b/gdb/testsuite/gdb.mi/mi-disassemble.exp
index 4d7c2f2e6e7..cac3689071c 100644
--- a/gdb/testsuite/gdb.mi/mi-disassemble.exp
+++ b/gdb/testsuite/gdb.mi/mi-disassemble.exp
@@ -284,7 +284,7 @@ proc test_disassembly_opcode_format {} {
 
 	-re "^~\".. ($::hex) <\[^>\]+>:\\\\t(\[^\\\\\]+)\\\\t\[^\r\n\]+\r\n" {
 	    set addr $expect_out(1,string)
-	    set bytes $expect_out(2,string)
+	    set bytes [string trim $expect_out(2,string)]
 	    if { [string length $bytes] > [string length $longest_insn_bytes] } {
 		set longest_insn_addr $addr
 		set longest_insn_bytes $bytes

                 reply	other threads:[~2022-10-13  7:44 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=20221013074400.GA6454@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