From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 5a6cGa5dyGpc5RsAWB0awg (envelope-from ) for ; Thu, 08 Oct 2026 23:21:18 -0400 Authentication-Results: simark.ca; dkim=pass (2048-bit key; unprotected) header.d=o2.pl header.i=@o2.pl header.a=rsa-sha256 header.s=20241105 header.b=VJ2dJXwq; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 4E8E51E051; Thu, 08 Oct 2026 23:21:18 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=no autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id CA3871E047 for ; Thu, 08 Oct 2026 23:21:13 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 3F5474BA2E19 for ; Fri, 9 Oct 2026 03:21:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3F5474BA2E19 Authentication-Results: sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=o2.pl header.i=@o2.pl header.a=rsa-sha256 header.s=20241105 header.b=VJ2dJXwq Received: from mx-out.tlen.pl (mx-out.tlen.pl [193.222.135.140]) by sourceware.org (Postfix) with ESMTPS id E9B5E4BA2E03 for ; Fri, 9 Oct 2026 03:20:43 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E9B5E4BA2E03 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=o2.pl Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=o2.pl ARC-Filter: OpenARC Filter v1.0.0 sourceware.org E9B5E4BA2E03 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=193.222.135.140 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791516044; cv=none; b=LVqSH9YailMVJ1Ax7XimrkPa8RSXXM+MSS2mso7zF47qy9p88+H4WPwyNlz60vYndlK5wKCkDViefFY/u/OQsGfS6cLfDWPwi0vI/4JQbqYhoeOb34x1jsYvN4LUDAKG18U4LY0VTBTDOVuq1AjuS4f0b13tpRMvXf7BCG/oE2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1791516044; c=relaxed/simple; bh=o/i9iRlukbIdC5GIjl27pqXbIbrMsyQCdkYTHQXzxcg=; h=DKIM-Signature:Message-ID:Date:MIME-Version:Subject:To:From; b=YvxMqk6o2h4b0ZEG4bRWYlout2ll0M5pHDitko9wlB9cRxh7Nf7oNHdqIb+s4tI3RDtwi8trQQeNvjrpnqxyioG9UlC7RHBFc5/SgFKbnkMHZ+ku0WMmr99op7V8GMV4xKVJ6wBbrWJ2rot2bAJaM8kRdLyPBBxk4QxFsL9xrT8= ARC-Authentication-Results: i=1; sourceware.org; dkim=pass (2048-bit key, unprotected) header.d=o2.pl header.i=@o2.pl header.a=rsa-sha256 header.s=20241105 header.b=VJ2dJXwq DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9B5E4BA2E03 Received: (wp-smtpd smtp.tlen.pl 28999 invoked from network); 9 Oct 2026 05:14:01 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=o2.pl; s=20241105; t=1791515642; bh=FCnY+mo4jAntWg3+XUkzRohto8IihV5Mnw2cphPB9TA=; h=Subject:To:Cc:From; b=VJ2dJXwqUpHPXNh4bkxG6fykMdNjwka+77wgat2ndRL1zCHa4+tFqoRyZSZpDB3ch wCXlYRb+Pufgp6yR5fWJiIzEG8rmiCWyaSDiWrqzckCcuWVn9cgpd8LeMZN0pQiojm wbEQUp+pVbPDAqPefBC/iGbsbj6oH+VhWiDHhezDoI7lO383b/gR273ObX0HMR6s3b XT+9natrvIKZO9zi2b9vGI7aJQeH2eddffTWxZUP5nG/20wMtM/Q80LdDTa6A/sKO+ kyatQ/LX/isduGsjOkMqgTv7YncX3lljFYE8LQSct/RfM9RwDrjvxg1VM9kKzNVX2C 67SnvcodzBT4Q== Received: from [192.168.0.1] (ip-94-42-228-22.multimo.pl [94.42.228.22]) (envelope-sender ) by smtp.tlen.pl (WP-SMTPD) with TLS_AES_256_GCM_SHA384 encrypted SMTP for ; 9 Oct 2026 05:14:01 +0200 Message-ID: <19ebaeb7-1eb1-4e02-a224-c65f1dbdda2c@o2.pl> Date: Fri, 9 Oct 2026 05:14:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [REPOST][PATCH v4] H8/300: sim: Fix simulator hang caused by qsort on Windows/MinGW To: Jeff Law , gdb-patches@sourceware.org Cc: Andrew Burgess References: <20261005060545.242055-1-jdx@o2.pl> Content-Language: pl From: Jan Dubiec In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-WP-MailID: 923579544c08667b657b5e2a26714296 X-WP-AV: skaner antywirusowy Poczty o2 X-WP-SPAM: NO 0000003 [weAW] X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org 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.