Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Jan Dubiec <jdx@o2.pl>
To: Jeff Law <jeffrey.law@oss.qualcomm.com>, gdb-patches@sourceware.org
Cc: Andrew Burgess <aburgess@redhat.com>
Subject: Re: [REPOST][PATCH v4] H8/300: sim: Fix simulator hang caused by qsort on Windows/MinGW
Date: Fri, 9 Oct 2026 05:14:01 +0200	[thread overview]
Message-ID: <19ebaeb7-1eb1-4e02-a224-c65f1dbdda2c@o2.pl> (raw)
In-Reply-To: <a0633ef6-71e7-4b30-ba99-a20d12903643@oss.qualcomm.com>

On 8.10.2026 04:04, Jeff Law wrote:
[...]

> This seems generally sensible to me.  I'd probably kill that ldm/stm 
> special case, particularly if the new comparator avoids the problem.

I'm not sure what you mean by "new". That said, using a stable sorting 
algorithm avoids the problem, but only incidentally.

The root of the problem is that the third nibble of the LDM/STM opcode 
is marked as DATA in h8_opcodes[]. As a result, if h8_opcodes[] is 
sorted in the "wrong" order, decode() may decode MOV.L @ERs+, ERd as 
LDM/STM. The first three bytes of the MOV.L instruction are 01 00 6D, 
whereas those of LDM/STM are 01 X0 6D, where X is 1, 2, or 3. That's why 
I added the special case.

IMO, the LDM/STM definition should be split into three separate 
instructions, as specified in the "H8S/2600 Series, H8S/2000 Series 
Software Manual". However, I didn't want to modify h8_opcodes[] because 
it is also used by other tools.

Also, the simulator is slightly slower when using a stable sorting 
algorithm.

> I'd instead be more interested in tripping an assert if we ever have two 
> things compare equal
An assert doesn't make sense here because equal comparisons occur "all 
the time". For H8/300H, the comparator is called 80919 times and returns 
zero 22434 times. For H8S, the corresponding numbers are 94315/26963, 
and for H8SX, 79552/23240. The h8_opcodes[] array contains 8484 elements.

/J.D.


  reply	other threads:[~2026-10-09  3:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-05  6:05 Jan Dubiec
2026-10-08  2:04 ` Jeff Law
2026-10-09  3:14   ` Jan Dubiec [this message]
2026-10-09  3:32     ` Jeff Law

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=19ebaeb7-1eb1-4e02-a224-c65f1dbdda2c@o2.pl \
    --to=jdx@o2.pl \
    --cc=aburgess@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jeffrey.law@oss.qualcomm.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