From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id SUvvDKNF8mKWpyMAWB0awg (envelope-from ) for ; Tue, 09 Aug 2022 07:31:47 -0400 Received: by simark.ca (Postfix, from userid 112) id 294DE1E5EA; Tue, 9 Aug 2022 07:31:47 -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=Ne6/6tDR; 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=-3.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_DYNAMIC, UNPARSEABLE_RELAY,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from sourceware.org (ip-8-43-85-97.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 A823E1E222 for ; Tue, 9 Aug 2022 07:31:46 -0400 (EDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 44C77385734F for ; Tue, 9 Aug 2022 11:31:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 44C77385734F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1660044705; bh=8qWiaeO2r9MAPSq3vUR9KIA5lN3Uh3NyNPVw3kwNncM=; 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=Ne6/6tDRuz/omjy+LavoNYm1O3PV5CHJUyVp8xL4VvZ6IuCGdztJtklFyXMjpIfu2 8ftDiYPEwzr4gv/M1o7ojCcUsgFOd7zZ0QFpmcPqTa/mqBVJ4+vbY+5eg9sw0a1SiW 0sScMcOiICDVeQ/Gajhu89t+elduHWPnwQcyOuHk= Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70081.outbound.protection.outlook.com [40.107.7.81]) by sourceware.org (Postfix) with ESMTPS id 344F23857349 for ; Tue, 9 Aug 2022 11:31:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 344F23857349 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=HCa5vHD/51QrXRyJMCDe7hV6zq9qrMSfXQc4HNZyRkbrqmLBUKWzNHp4B76mGyQGk8p+DXgdlQmSNE6t6dzUNkTcDCgQ+TmZnqrkAud2lmcb1hhS6UxQXXfHM6qjOXA9aK02N8RL9Ept+5/RrodbLU9sjH1IO0QPIJPtELiwm67A0E/K7rtebpQu1gR8ssra86BTtx0yUBQ+tyP5NjrkaDAhq4E3RPb2YiKIY0a2Lhfxa7FTApM0Totu3F7i2/y7923y0qcq4/s+WLVAtLTctidHJwxiDbuFMP8FetAmBjwrBntCE//47HuSQ1qgWv3eVadlHMuAEpskKw1ZYOqA3g== 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=8qWiaeO2r9MAPSq3vUR9KIA5lN3Uh3NyNPVw3kwNncM=; b=c6KrglOPOOjDYgYHwQX5pg4ipqjnygMOrZGuUdE+3QX+xbXd9MId62fbex4n29t8fCROQot4jO8JxK9IbNCsfytme9QojMir/7J2aURsJLIp0NjsNIlDez5UKetmTngAZLjVgkZg3ihL3oGznuoD3/rsm9xXjl6qySb9ZfyGDr6vElck08AKFpg49of0Y5OVc/aiXxEtSZRlcWnfuqMIGQkPTBeOpTPTme4EPDqxn4KAKKiLGMGL5PtMjWMj0stVE8VvXEwHkxq1Wm5UdFBZN3Oh+KYxLAEqPFCyderbH2M5nZqPdK8ux5Sn+mdBlKSDMvk6uXLO8SWTwtUDtDtz8w== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) 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 AM5PR04CA0009.eurprd04.prod.outlook.com (2603:10a6:206:1::22) by VI1PR08MB5518.eurprd08.prod.outlook.com (2603:10a6:803:13a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 9 Aug 2022 11:31:19 +0000 Received: from VE1EUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::da) by AM5PR04CA0009.outlook.office365.com (2603:10a6:206:1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.21 via Frontend Transport; Tue, 9 Aug 2022 11:31:19 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by VE1EUR03FT061.mail.protection.outlook.com (10.152.19.220) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16 via Frontend Transport; Tue, 9 Aug 2022 11:31:18 +0000 Received: ("Tessian outbound 63c09d5d38ac:v123"); Tue, 09 Aug 2022 11:31:17 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 03c6b1bdc76ffcb4 X-CR-MTA-TID: 64aa7808 Received: from f7359193fd6b.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 099F3AB8-8E64-4ADD-BAFD-ACDC658E6D22.1; Tue, 09 Aug 2022 11:31:11 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f7359193fd6b.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 09 Aug 2022 11:31:11 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IWF9xAfE/UQ/KtaQaa36L98HBJJIpCMMpu840acSiwidiIX4c0lM1EOye4C6SuHi3s2fBHQi24x4bvG4P0dvU4ACXoniCMh7vE4nQ9N5FrEssn6LBN2KhcT3WCr9hGJZcY88iktT7Z348LFdUHsIjWyBz4k1mwWESoRLmLShUW1IM1Tf2y1WDsAg+6fzguisVGXyF0d9b8V+nDiZdQ9A9RbCLwxJflGUVHLV8BYHFu/wQ9NpLEbIUIImc1piGsUzZLY+oAl8TbVaPNezUcXc+qu2BV/oaYx0jMIX55d9uoqwid7086jwL39QfUhnRfyB1HK4voMcLZXoy6Y+WM3Ryg== 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=8qWiaeO2r9MAPSq3vUR9KIA5lN3Uh3NyNPVw3kwNncM=; b=HKVmN9Cr3V1BbA67YZjLjNqY+HyzT9vAM1zzrbGq80EwOWVNcOIBXUdfqL2/w7cEvWAbZ5TDwCxs8DkCm3/zoaoOSWSss/whq7pGmCmHiKzUSoql+MZI5wMwCNjRNHzJFQyVctaDY6CkGQWQKC3EyrWoM/c0CpqA7b5UQeB6GV5s41PSfF5t+ppBVEYdgVXJU756Ixu9EQZOy3NAsCsC7LavVeUBLLv4uOxVtR3Jac3u1kBicbrGPJxCc+JRtwCTXPZCaOg/QdizMGpwttEp91u4XTfXWhyoivwNwEgp3e7IUhyzMnzAAYpc8FVWy/DXU5cg5E4ZQ6199qocm4VMRA== 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 DU0PR08MB8834.eurprd08.prod.outlook.com (2603:10a6:10:47b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16; Tue, 9 Aug 2022 11:31:09 +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.019; Tue, 9 Aug 2022 11:31:09 +0000 Message-ID: Date: Tue, 9 Aug 2022 12:31:07 +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> In-Reply-To: <6fe1ae85-a72a-e256-1c88-f9a9b303c0b8@suse.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: LO4P265CA0240.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:350::20) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 777e7813-30bb-41ff-6e16-08da79faad76 X-MS-TrafficTypeDiagnostic: DU0PR08MB8834:EE_|VE1EUR03FT061:EE_|VI1PR08MB5518: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: QZBvf3/n2/kUKADR5sH++Aqzk2DI8SQI9BZiMLiCL/+84SQILQEXvci98odMVQy4us1DW50WVnXxVxDD7EpWAZ4ezaB4EoU9k0ubGSb6M7j8OS+vYuGO53ACIvvCDrl7akFkalCPOP+9diit7LtmNdpmPMnRtLJX4C7lCOARqekCOkEthDSZTmfXOxnT6gI38IAi83wFsyR+wBMFn2chZnmsqMEqM/e9MzOpHnCadyjG7TY73y5mH73I+cXqVQwKNC4p0HZ/f7ERcYs2qxpS7X4zMpnxoV+evCFhV957nK860cSxCZ7BselVYiIM+gSSgsCjrsORBpSo6R2B0OX1lswgvyVqckwXcEJT/UDRNqDIoNjijxd+Fnrqyy9G9+v2VytY+h7E55L2inv/iLfu5Op93DbiVGuT42WnUDqdl0c2xa3ZSnb8k2/j24u49qfwWgzX0PKKTth1pOJuQ/kYmuWO67cyBHvjwnw+EDT2thob5mEYAyZfFqlVRiUwnD03y2M5VaqfAedKrA5DaWAWKceLrfdFyfnNi8J+kHlST7PQ8byA3uHhdb9NGpy369wG342nq1t9gDb8HhLsjk3cBwds82XZ7pRSrwAJAXJC5pr6jc7+AqI2DR69JTKEH18NwcWMGa6Y2UirCjHk5yd+Vz4YoOSd0c+HRRLvdaflMamnzzlxZMEXoApz+SZZba6SOoUcSI5dVOG4K+BxNjsOIgqTf5j0HqrjbZbNZ7wXNYIpCNtIpRs6CI/2BbYpqM/zBWqkA7XQqIRmcfAYojhq+JierrgORVyaqB/n2qzp30VwqtsT5I0PuJgZ3N/rWkt7+rQwDBCSl8c++oHnLRU5+g== 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)(376002)(346002)(366004)(396003)(136003)(186003)(2616005)(83380400001)(38100700002)(2906002)(478600001)(316002)(41300700001)(6506007)(8936002)(53546011)(6486002)(44832011)(4326008)(66946007)(5660300002)(6512007)(26005)(66556008)(36756003)(8676002)(86362001)(66476007)(31686004)(31696002)(43740500002)(45980500001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8834 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: VE1EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 79d2089f-395b-4cf6-ad22-08da79faa7ea X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Cy9QaQo70IlO5kCMTUgEOIRkJ6Gb6ddw2ripuMMPJIudEq5Nbf2Cwu6AD6AKOAWLtBpR/08Tv4VLUHf5h8cycPUBKk3OgTnzRS6pQW0r/eMvrmz6FMEeb2SeQJ3A7494M+i39y54q7dqvIIBeDr+XlJynyZaLUc+PflhwFgpE46Gwwh9gx7UsXg4e2zq6wRIfhWWTDTFOGgc/yoP1o2372T4snXQenJSMmx0VRnoMiWgYSs+kZOqo3/9lcCC63LuwiaEZgod0SSTTShGJufUl1gYGlAhenuYRqUhrgX9mjsU2TogOXZhsGin5r69owefB15eK2P3hUoUqLJnxMH2aWhDG/MBpdkBkbFllfuFgqM3a+Fp9mB9OgmsND4Ywh1GuCL6EfkAW/ZAHfgH4AFyLMJfYMwpf+OBh4f+ieviySo+M1TDdtmABI3raNVHQrcFuBAO0ztasAYmSdFBDl7XR4NJUxderQe8UZ6pQEhU2KcKN0kec1ax+l7Qy8PJt8WB965TFlZRZs/VgRVO2FxYbhUhw0sY0bUpxaP5wUGeCUbyQCdGtE7FjeSBexm6St8EAPIw4SEzjpL4a2oXLjNeI9iUKsZ183hJqVL+9gxP6ApbRwcVfuOGnATxYZIaqSzrfwjdCG0gu5JN6ZyKzjl3A7xYu2IiSmZa6V7Sp5yHa1e9HNcuG3m8/lOfUxvR+1c0N363e8OyueAJMpIlIp/eZiiT6WdCSjqsykOQtzQK/FVqdxoi1RcMo/C341nalq1O3XjfNiTWyPo9LWVVC7YWBJRZSxsINb/EF8KTBpzMWb5CCyMrz3xsKadahNsmoKD+0/4NrqurTtkVqTdtYC+b6Q== 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)(346002)(396003)(136003)(39860400002)(376002)(46966006)(36840700001)(40470700004)(83380400001)(36756003)(31686004)(2906002)(40460700003)(107886003)(2616005)(6506007)(26005)(47076005)(336012)(6512007)(53546011)(186003)(82740400003)(5660300002)(70206006)(41300700001)(70586007)(8936002)(44832011)(36860700001)(82310400005)(8676002)(478600001)(31696002)(4326008)(86362001)(6486002)(40480700001)(81166007)(356005)(316002)(43740500002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2022 11:31:18.4101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 777e7813-30bb-41ff-6e16-08da79faad76 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: VE1EUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5518 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" Hi Tom, On 8/9/22 10: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? Good point. > > 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. I guess, though I was going to rework the patch based on Andrew's comments. Didn't get to it yet though.