From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id IvHMKYU4+mLCWCcAWB0awg (envelope-from ) for ; Mon, 15 Aug 2022 08:13:57 -0400 Received: by simark.ca (Postfix, from userid 112) id 9F7031E5EA; Mon, 15 Aug 2022 08:13:57 -0400 (EDT) Authentication-Results: simark.ca; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.a=rsa-sha256 header.s=default header.b=wjU97QGy; dkim-atps=neutral X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-4.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id F16EF1E21F for ; Mon, 15 Aug 2022 08:13:56 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 72AE0385800D for ; Mon, 15 Aug 2022 12:13:56 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72AE0385800D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660565636; bh=mvvzuIti6kEu6aYMYzGd5RqFuGP/6Yrvtg/LpuPwN0Y=; h=Date:Subject:To:References:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=wjU97QGy1jvorDzO3hC6Kk3TaWdEsHpQw+A2wp8MH2DiPGHYoqKfHnKY46fIf1RDu 6i4sdy3xgx6N4pkdc5/l9FdVYp79c6XrkSjz9S86+peGfvd/eHNZktUfkC15Qz7+jP GLXL/OCDiKK3H/FLEAlC/VCOC1MozwnTp4dKDhUY= Received: from EUR01-VE1-obe.outbound.protection.outlook.com (mail-eopbgr140077.outbound.protection.outlook.com [40.107.14.77]) by sourceware.org (Postfix) with ESMTPS id E4FE03858C74 for ; Mon, 15 Aug 2022 12:13:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E4FE03858C74 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Px82U+yfpX11a/I0Kg1/b7q7k2KYOmv9Bme2+HCG9M4Lfa4B8SFLQPS8Qu6yHGkoiNXP9Azo5lnw7+3RsF1gUxswQVEeid3pbWLGPZ9USKXwriu7dqCvCaKALpFJxqoZhLiFHq080midgSyFWI1X2mrfwnIAKhMbmElwjM0/LAsmtMp6ivfB4EQkvAdr6fSKfVGnUx+6PqRFSWgUAQz8iqADz1nFF75v+RHMCbDzOO+rJk4cC9jWc3CveQTtiLHEA/Wbm0RvETvrIYLxfOdPGPXymJe2rnbBChILT9fHeLUzKryruupe6V9YXZTZny0RRQ49vqJMSf6IQVMjsZgUhg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mvvzuIti6kEu6aYMYzGd5RqFuGP/6Yrvtg/LpuPwN0Y=; b=PGWH/QgwqG/H0RgskCzG/miIB1QL12iHByQyGnH4a3NPAgwDuXnLfi4w51O7557OgikrrTk1nCqg1jmDROulJt8dTNBREZeKUEorGoSKbJ/MfXdlqkUYB+MYOwtH8u6SCnom9gH2DbzZvIOezCa+eSflJ0mHJB2Fa7IrsCUke+jocM0H0i1WuE93QYL74o2W6P0UPmuih8EHE9HhI+lENe6g6W14vstggT9jTba2XK1wCtOifBpmKJLawoFlvLeL5mkeIuylUZXZnNCBzY3tXOdOByUvOU4+xpMND4qIlb0is2UZ7YdwjyOP+QVc8fY7e44VHLVeEQfCUzQmfBa9jw== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=temperror (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=temperror action=none header.from=arm.com; dkim=timeout (key query timeout) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from AS8PR04CA0052.eurprd04.prod.outlook.com (2603:10a6:20b:312::27) by GV1PR08MB7938.eurprd08.prod.outlook.com (2603:10a6:150:8d::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Mon, 15 Aug 2022 12:13:22 +0000 Received: from AM7EUR03FT044.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:312:cafe::de) by AS8PR04CA0052.outlook.office365.com (2603:10a6:20b:312::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.19 via Frontend Transport; Mon, 15 Aug 2022 12:13:21 +0000 X-MS-Exchange-Authentication-Results: spf=temperror (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=timeout (key query timeout) header.d=armh.onmicrosoft.com;dmarc=temperror action=none header.from=arm.com; Received-SPF: TempError (protection.outlook.com: error in processing during lookup of arm.com: DNS Timeout) Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT044.mail.protection.outlook.com (100.127.140.169) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11 via Frontend Transport; Mon, 15 Aug 2022 12:13:21 +0000 Received: ("Tessian outbound 73dd6a25223d:v123"); Mon, 15 Aug 2022 12:13:20 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 240acd9ed0c5a323 X-CR-MTA-TID: 64aa7808 Received: from b6978a08a679.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 25B05BE7-037A-4ED2-9B44-28D6AB21FE28.1; Mon, 15 Aug 2022 12:13:14 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b6978a08a679.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 15 Aug 2022 12:13:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ShAUmj3sVRXZoSZ+oJf3fFhtVOetXASA7ZOnMR8NIdQZgdo7IUdcd+kOTVZUsb9UTh61+X1iKW1iboHomcmsDfZK23RgUjokSNeQ3icWxRXKCWVsqJ8q+AAZn2uG7UGfeYGTYnE64AJu6WKP91UGzN8z5oF7b2sINIsWHzr1ahF7bmE6q9CxLtUEoMM0dWH8ZzH0DZTBZ/4kPfO7YZG7og+E7Zuxh0Wt2njX/pAupaZt8aCv5nbGn/M+M+1q2FbKyy/AzxLL6Rg+cmPqg8KyMvWI5K+qA7bOGd9bRf+Ni4x9dzaVXJlGDJ4DDtsWtTHTqP7+dtUvhzI/a2Nn5wlu1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mvvzuIti6kEu6aYMYzGd5RqFuGP/6Yrvtg/LpuPwN0Y=; b=JBFUsqMSPwyZW4oyBcvCRupGEeVCV+AnGVgtG3Y09x2UUMTyD04xCe1KQWZPhQO6bbm/bskU/2vOy0sqar5bYefgC02t52pKJwFB1uyLgWnDQvd4hwnfmdpqbdoaG5+fWMz7WjsvYARyoPPTvsAzCXpc0XOKJdS6ArH2/eA6h7jCm3iBYZJ2GEVc4T6QHoG04y77jsp4Fnnb7+va0gBcEgBGLBuf1lk599B/JIzLr1uXg8mVuseTxxxIzqXjtehplSUSOggoIyqVmSHxktVXyyMp0EW/NpFgxGnYT8a4qBokwDMIaQx6p2AY91HQMjoW4haw0nJRoEDYlDQD0glpGg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) by AS2PR08MB8648.eurprd08.prod.outlook.com (2603:10a6:20b:55f::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Mon, 15 Aug 2022 12:13:13 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::cc64:9170:b12d:de8]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::cc64:9170:b12d:de8%4]) with mapi id 15.20.5504.028; Mon, 15 Aug 2022 12:13:13 +0000 Message-ID: <2b88a4ec-7986-d8b7-8327-069e984350c8@arm.com> Date: Mon, 15 Aug 2022 13:13:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH] [Arm] Fix endianness handling for arm record self tests Content-Language: en-US To: Tom de Vries , gdb-patches@sourceware.org References: <20220808101203.168954-1-luis.machado@arm.com> <6fe1ae85-a72a-e256-1c88-f9a9b303c0b8@suse.de> <54574882-62aa-ee50-f878-7aaff48d9efb@suse.de> In-Reply-To: <54574882-62aa-ee50-f878-7aaff48d9efb@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P123CA0259.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:194::12) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 2798fb8e-faef-4d39-f5d5-08da7eb78b96 X-MS-TrafficTypeDiagnostic: AS2PR08MB8648:EE_|AM7EUR03FT044:EE_|GV1PR08MB7938:EE_ x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: GIqUbYPQfvPXlMe/OZTNr3boWvckh9uqmprORhDrt5LvZMdUaWbNdd87G1yb1iZA83CO1xeC+KqN+sNj0aVDayvAc2+X5Rq86w+Ak7Zdlk7DyIxHipHpQl7V+zHz0rM9hhVw6B0bWgZYYZE94GEJlOs9zmMgqfBrDpV7rDDQIk8V0xMWO+ROmGsWmJkAoKKVHmFsVpsRcCcVFy9pPisY1/t4WKyANU2R5WeQ3/zlSDF6b6IjpFQsLDJ0T8GieTdvV76eHsaZ/i3E1D2dfNYxQyZlFtHgP2vNMbYMlXTZ5JPoTceW3FNpPZZuhMhIMZFkWleRyv6w+lfB530PV5bcmZ04TfATp/HjN1KFM8k+R6CJ5CLT8+EZ83qAHuQnLHJiHDL+VAqif3RES86WFxb+YaeYcsy8Ugr9ixRapotHwSPZUV8L2H4ymfTJx2ke+rYwmUW3SDIedk6ZMLf921nffGKeytjaJcq/rtF4BL/zXzGCNkTaQIsqL1mmNzenmmLdGiddi4T16MgY2oi1e7oAnNmKYT4SZcSjmUwpp6KEaDGctIifmoKP+VM8qvifpJxA0Y612iZRGMWpDt9GtMDP8a7GP6pCBcqTPco3J6VC4DQOP9hW7rVKpuLZVHcvbC6mgpZsMTA7K/wTOpXkkAmXMV6bfiq0zq3bWHezL/Eq1eNRbvnxcA3Jy3dxwbdECa+pMPA1OG8C4d1reX2lIW0/9EOM8xniqxTOK7Ch5+8Tb7+JeYRk0Lj8k4SQ00kVfYjZZ7V8Qem34nIdGNocj58+DNFKIgG4CwLc0HegKDPPwoz6TOOC8CHoAv7MClAVfvsehaNHVWC9lAIYTnpR32v0lg== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VI1PR08MB3919.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(39860400002)(136003)(376002)(346002)(396003)(366004)(5660300002)(44832011)(316002)(66556008)(41300700001)(31696002)(4326008)(66476007)(86362001)(6506007)(36756003)(53546011)(8676002)(6512007)(26005)(31686004)(2906002)(66946007)(8936002)(83380400001)(2616005)(186003)(478600001)(38100700002)(6486002)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB8648 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 688d6273-3f33-41f0-d4eb-08da7eb7867e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: utamcxFazfcZcyDc7RrE+gVqv3m8zjuM//7qhCuJWQFE7L2oQPfdy+3+6zIJgMfvrD18c48YXtApdN26wumGJY0OIBke6f27jTs83sz8SMPBh81zseStc8FBnLmXn+aoxokmPCm55chvDDG1oTirShjO04r/Pfs7m05zvFrV7D3n1rvgQwpPZtdz8HXLODmzwYQB2Eq3l1nSQi25x2s2cJIq+kaCZdJOqmP+tsbJ9QsPbdCt6aYZtYxAYbYzlh8/4J4I0a5KH2rGbGlMLZAmW9PmWHtVxD6kQEsZmtyRKvcWfIRRQaybJ/3rgIxeaKz1+HK+Q2s28QC9Ioha7N+/iUkfc4Xp1LubwilYioTXsDszTHW3UMIlw/1LoLFc689sEiRlZR1yhBSFta5svWarR0soHcIqV1hl2vEGB4pSzvOQMY3pdppulxL3qJbq7YIg/Baeq6JQmOGBQ8emVyLOV1hcV0OIqA301ZQVRzf+V5jWPHGWV0M68ljrjpcEZpryTn2PO+7z0QFawe5utXShP1lr7qcQ/WGkFMdY65JP/a7VjA5DGSkU4mXGZ5rWlA+pS1FMn/x7kqbLyzdoA38mqcv8VpdR8TNpDWETYK1A2Lw7mp2/yHqL1nsl9npQ33gj6LNVbrc+0rUGx8vqTDPKWwvixRznEFgIZ5qY03NpoQ3xAtSb6hrU3qyFWfosfyzOJZPSxw04y8MQP9sOIqULfFqRZ3xRvRr+ilcAcuEqkAWtPqaNYwvR7KBQSWZkyehGWGENGODBiotHc558OrmO7xceLTxtiFlMBy2rULqYhFS1NCKiWaydvCwzuUhXMb7b3DN0/pyn8PFtLWMlnV/kvIGDIcRU29ZoPFaxHWpB/TBs8SXH6HZqWITY8CcTzRRb X-Forefront-Antispam-Report: CIP:63.35.35.123; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:64aa7808-outbound-1.mta.getcheckrecipient.com; PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com; CAT:NONE; SFS:(13230016)(4636009)(376002)(136003)(396003)(39860400002)(346002)(40470700004)(46966006)(36840700001)(356005)(336012)(63350400001)(63370400001)(47076005)(40460700003)(83380400001)(107886003)(186003)(2616005)(36756003)(44832011)(2906002)(8676002)(31696002)(36860700001)(4326008)(70206006)(86362001)(82310400005)(70586007)(6506007)(8936002)(81166007)(6512007)(82740400003)(53546011)(316002)(26005)(41300700001)(6486002)(31686004)(5660300002)(40480700001)(478600001)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Aug 2022 12:13:21.1762 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2798fb8e-faef-4d39-f5d5-08da7eb78b96 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[63.35.35.123]; Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT044.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB7938 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Luis Machado via Gdb-patches Reply-To: Luis Machado Cc: mark@klomp.org Errors-To: gdb-patches-bounces+public-inbox=simark.ca@sourceware.org Sender: "Gdb-patches" On 8/9/22 10:57, Tom de Vries wrote: > On 8/9/22 11:43, Tom de Vries wrote: >> On 8/8/22 12:12, Luis Machado wrote: >>> The arm record tests handle 16-bit and 32-bit thumb instructions, but the >>> code is laid out in a way that handles the 32-bit thumb instructions as >>> two 16-bit parts. >>> >>> This is fine, but it is prone to host-endianness issues given how the two >>> 16-bit parts are stored and how they are accessed later on. Arm is >>> little-endian by default, so running this test with a GDB built with >>> --enable-targets=all and on a big endian host will run into the following: >>> >>> Running selftest arm-record. >>> Process record and replay target doesn't support syscall number -2036195 >>> Process record does not support instruction 0x7f70ee1d at address 0x0. >>> Self test failed: self-test failed at ../../binutils-gdb/gdb/arm-tdep.c:14482 >>> >>> Investigating this a bit further, there seems to be a chance to do a simple >>> fix through a type template, using uint16_t for 16-bit thumb instructions >>> and uint32_t for 32-bit thumb instructions. >>> >>> This patch implements this. >>> >> >> Hi Luis, >> >> LGTM. >> >> I noticed btw that this: >> ... >> diff --git a/gdb/arm-tdep.c b/gdb/arm-tdep.c >> index 57b865a0819..1e6d9ba65be 100644 >> --- a/gdb/arm-tdep.c >> +++ b/gdb/arm-tdep.c >> @@ -14489,6 +14489,29 @@ arm_record_test (void) >>       SELF_CHECK (arm_record.reg_rec_count == 1); >>       SELF_CHECK (arm_record.arm_regs[0] == 7); >>     } >> + >> + >> +  /* 32-bit instructions.  */ >> +  { >> +    arm_insn_decode_record arm_record; >> + >> +    memset (&arm_record, 0, sizeof (arm_insn_decode_record)); >> +    arm_record.gdbarch = gdbarch; >> + >> +    /* Use the endian-free representation of the instruction here.  The test >> +       will handle endianness conversions.  */ >> +    static const uint32_t insns[] = { >> +      /* mov     r5, r0 */ >> +      0xe1a05000, >> +    }; >> + >> +    enum bfd_endian endian = gdbarch_byte_order_for_code (arm_record.gdbarch); >> +    instruction_reader_thumb reader (endian, insns); >> +    int ret = decode_insn (reader, &arm_record, ARM_RECORD, >> +                          ARM_INSN_SIZE_BYTES); >> + >> +    SELF_CHECK (ret == 0); >> +  } >>   } >> >>   /* Instruction reader from manually cooked instruction sequences.  */ >> ... >> works fine, so I wonder if instruction_reader_thumb is a misnomer, perhaps we call it instruction_reader_selftest or some such, and add the arm32 insn to cover that case? I suppose the code was originally made to test thumb 16-bit instructions. I've incorporated this change in the patch. Thanks! >> >> Also I wondered if these checks >> ... >>      SELF_CHECK (len == 4 || len == 2); >>      SELF_CHECK (memaddr % 2 == 0); >>      SELF_CHECK ((memaddr / 2) < m_insns_size); >> ... >> can be made more specific based on the template argument T. Indeed. > > Also, I think this is more clear: > ... > -store_unsigned_integer (buf, sizeof (T), m_endian, >                          m_insns[memaddr / 2]); > +store_unsigned_integer (buf, sizeof (T), m_endian, >                          m_insns[memaddr / sizeof (T)]); > ... > > Thanks, > - Tom