From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2061e.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eab::61e]) by sourceware.org (Postfix) with ESMTPS id 3AD473857836 for ; Fri, 5 Nov 2021 11:58:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 3AD473857836 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z8NZl8PlQEaoAqFUZN9U/9PXdLFFyGC0mb0S1AjDri2S7yULC7QEv8bXHVFPC9Qp3cWrOn6znHuyyFfhpx10GLeLvxaJCwAhs/V+TKZBZ+5woZn2sh2LKJ4kedXxrrdTAYC/wmTUxftlJo/mpBh6t/cIpoJMxWHK/2/AiF3UFMcZ0rrEOKm8/5tS9pSc7lQx62BIBVfDrSJaVs5wa57QS/3yvVQimfCtEmSn0Jhvfnh0zyBmHu4HhARKOsp9P7eB5Lx9lf30PNl4+LXorHoJZeXI5lv+2qNzpkcbQoS/KQKb7Yf0zhwlHviKirOR5+y3kYIqKmBM40ONI3Dyc0snyw== 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=cIXiDW+BRUNTm87AEwIURljIquFOj2YYbw0BmfDPJh0=; b=f0lVMCgTp9FDpWyO8YJ8yT2B763EutGrntrQdwKNdIQCz1IEIXUDDS698oKcXQ+99AJ599UGCwYnEHP9/ILhFVAOamtxCaYOLJonJAhtWdpKEjc6DYcvsb/5SUNGzZAAejry3h0IPxBeOQbXGBYgX5ygfoROIx1pf8GE1uUlvKuKu7re6XvcNqCryMAYHTkV0rEkB3ajRv3Y3hEBc596QJzUbBoUO1EDeQiiNBLKruB0+mPNGJuPAl5zDBFLPHsyhMMYdJvcZslor9K3jQHfH12PpCwIIkzo4CY4KZU04gans+n2MtwId8lsWq0LK9RqKtHM0zKMe5zzvmaBc6VpGA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none Received: from BL1PR12MB5061.namprd12.prod.outlook.com (2603:10b6:208:310::13) by BL1PR12MB5048.namprd12.prod.outlook.com (2603:10b6:208:30a::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10; Fri, 5 Nov 2021 11:58:24 +0000 Received: from BL1PR12MB5061.namprd12.prod.outlook.com ([fe80::2948:1a2c:8400:9e7f]) by BL1PR12MB5061.namprd12.prod.outlook.com ([fe80::2948:1a2c:8400:9e7f%4]) with mapi id 15.20.4669.011; Fri, 5 Nov 2021 11:58:24 +0000 Subject: Re: [PATCH v3 06/28] Add read method to location description classes To: Simon Marchi , Lancelot SIX Cc: gdb-patches@sourceware.org References: <20211014093235.69756-1-zoran.zaric@amd.com> <20211014093235.69756-7-zoran.zaric@amd.com> <20211025183356.4cw5xqpvyprgayfs@ubuntu.lan> <7baf311a-d347-b5d3-e07b-b53c87ef1d38@polymtl.ca> <2f7bde51-cbca-6f14-cb22-52bcf7682cd1@amd.com> <461d4faa-95d0-1d7e-13db-13fbf3fc00d5@polymtl.ca> From: Zoran Zaric Message-ID: <9a622124-3261-2bc5-6c55-8acdbe97c7ef@amd.com> Date: Fri, 5 Nov 2021 11:58:20 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 In-Reply-To: <461d4faa-95d0-1d7e-13db-13fbf3fc00d5@polymtl.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-ClientProxiedBy: AM6PR04CA0039.eurprd04.prod.outlook.com (2603:10a6:20b:f0::16) To BL1PR12MB5061.namprd12.prod.outlook.com (2603:10b6:208:310::13) MIME-Version: 1.0 Received: from [IPv6:2a00:23c7:1093:6301:1f9:e2b0:611d:9c73] (2a00:23c7:1093:6301:1f9:e2b0:611d:9c73) by AM6PR04CA0039.eurprd04.prod.outlook.com (2603:10a6:20b:f0::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4669.10 via Frontend Transport; Fri, 5 Nov 2021 11:58:23 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 40736948-163e-4604-4df0-08d9a05391f0 X-MS-TrafficTypeDiagnostic: BL1PR12MB5048: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DDw2wevPw9oDlexIdGv4X1a0QIFZy8wWZGZXI87YETsR268BwKAJ4JxwueAnMQH9uA4PA9Ur88HXClBww+M/X1Pv19Ku8V0REl+WY5fTDrCciaxRNx10wwcwcBw6GYC44jv+WRyzZ5gvfdewzfSE9niO3yrjuLPycZrsenMId/EPIJoe+jy1N1iinFr76i4nH4GW7M9kuvBdjxD3ME7legh9yCUmbLyig7WfKzKfokU1agX4v/HhFD/f8NLtP0duEHSpvjHSQnSUbOuJ6xpz5hjA6VtPeOdkA0/idR4xgNMA7XHUuIcHgZqLMpGTCTu231kkpvTsN18c37Ud4W8vymVvfzHp+IQkXGPtBn2/GElJxuuBDEAXd7CePoGGSTZ4DvGXV51dLFso2Asdte+owTii6KZK+CRC3ez8jaqygZftZ4vXGYop2N6vZYR56L1jReboLWCM2CB4ndZlOHWyUYVmpWRvtApLL4URQYLjPAIwS8JZEJw9StSft4e1TMsSvR/yvf8jxXSyPjVasGFm7Rs6DiXve7brDBrQH/UgAIQU6b3jJQ/ocwjNsc0KavIBzLM/dZYrcUzSQuk8Sngqh6xoKB9yhKYk3QqbsHVbnlhgKH5V6+mkwqY5U4Xb9KA4UE55vJMlQvOhIyOlkKPreZgA0SS1CrDbeT7kRp9vv6+YrLe3ZQGzBwDJ94mhsYNWJXXChVdcN1Ej53gBQjCNITVmBvgQRQjqX8FJGtiE334o/ahhgWwZ67elRz670Xwj X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BL1PR12MB5061.namprd12.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(366004)(86362001)(44832011)(66476007)(5660300002)(2906002)(53546011)(66556008)(31696002)(186003)(36756003)(110136005)(2616005)(8676002)(38100700002)(508600001)(316002)(31686004)(4326008)(6486002)(8936002)(83380400001)(66946007)(45980500001)(43740500002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Z0FDNFBqaDhLU1RkK0lsTngzRVRvYTViVFpXZy9lMG0rcmRjMjlwcmR6eFh2?= =?utf-8?B?NW94c0VWRHVnejM2aGRjcXBUeHlxLzQ2blU1TTVqemw5Y00vUmpycEU3NnBI?= =?utf-8?B?TFVUaDhHTjZ1RzJDSFJKYzExTTBtM3JoWkdrOGdnWS9zWVhqaldyclZZaVFB?= =?utf-8?B?WGV2U1NLMmZLTWpNb1BOcWxLeHdIRlZjT0JadU4xS1Y5N2I0aVd2ckJ6Wk9q?= =?utf-8?B?YWdVNEZWeXA4cmVXMVp5ZmJsRTFHU0tmakdzOUhHVEF6d2pnQ0E2VWx2NGtO?= =?utf-8?B?ejkzODJIMWgvQWNDMnFaOW43UFMzaXdQV3lwRTBOTmlYbGZaMXVXdVdRUDlX?= =?utf-8?B?QVhOU05RcUtVR01VVzMvUHVuQThzT0s1VzR6R1BQQkMrdkpvMkNSc3BvMGVS?= =?utf-8?B?cnZzMXZrWk9LY2NxaH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-8?Q?LKrUkcrbU606L86vvSigdiOuQo8vndNej1KJdiEMeo=3D?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 40736948-163e-4604-4df0-08d9a05391f0 X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5061.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2021 11:58:24.1895 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: +E7sKSC2G3jVxuoFYIe3zdQOIni6nB5n7RMcU0A2rnWEYDL49i3B2KKOJWFp5C/QnFd3dnPVRYvllm9J0gn4MQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5048 X-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, MSGID_FROM_MTA_HEADER, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org 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: , X-List-Received-Date: Fri, 05 Nov 2021 11:58:29 -0000 On 11/3/21 7:03 PM, Simon Marchi wrote: > [CAUTION: External Email] > >> The problem that I have with this idea is that DWARF doesn't speak in >> terms of addressable memory units, but in terms of byte representation of an architecture. >> >> The addressable memory units only describe what an underlying memory read write interface need to consider, but from a location description point of view we need a byte/bit correlation that describes all location description kinds uniformly and the addressable memory units is not it. >> >> For example, how would this work in the case of registers? In most architectures they are only addressable as a whole. >> >> Another problem here is that the m_offset is not equivalent to offset >> or embedded offset from struct value. This is especially true for memory location descriptions where the m_offset member is an offset from the beginning of the memory location as a whole aka the address itself. >> >> Previously the only way to add an offset to a memory location is to implicitly convert it to the value on the expression stack, add an offset to it and then convert it back to an address. This means that if the expression yielded unaddressable address, the read would just fail and the gdb would not try to compensate by reading more then copy with an offset. >> >> Considering all of this, the only correct thing to do here is either use hard coded value of 8 (like was done before my changes) or use the TARGET_BYTE_CHAR instead until there is a need for a proper byte/bit correlation target hook. >> >> I can also see that we are using gdbarch_addressable_memory_unit_size >> call for some struct value API (for example value_contents_copy) for offset and embedded offset regardless of the location description kind. >> >> This is obviously wrong, but it was not detected from the DWARF side because the only way how one can add an offset to a register location is through the lval_computed interface which goes around these issues. >> >> Because now this is not the case, I can solve this issue by making sure that when a dwarf_entry class is converted to a struct value object, the struct value offset member (and the corresponding bit offset member) are still talking about offset in terms of addressable units for all locations description kinds. > > I spoke with Zoran offline about this. In the end, the conclusion is > that there are too many unknowns on how things are expected to work with > non-8-bit-bytes targets. On one hand, the DWARF standard makes it > sound (section 1.3.2 of DWARF 5) like a "byte" can be other sizes than 8 > bits: > > DWARF can be used with a wide range of processor architectures, whether byte > or word oriented, linear or segmented, with any word or byte size. > > So when you apply an offset measured in bytes in a location, that would > be using the target processor byte size. And that would apply to all > locations, registers, memory and others (especially since you want to > treat all locations kinds the same). > > But as you have mentioned, all areas of GDB are not consistent regarding > this. Some code paths today use an hard-coded 8 when applying offsets. > I think this is more related to the fact that when we upstreamed these > bits (in my previous life), we changed whatever code paths our GDB was > taking, not all. > > Since there isn't even one architecture upstream using non-8-bit-bytes, > you can't even take a peek to see how it works. So I would say, do > whatever is the easiest for you (except using TARGET_CHAR_BIT :)). If > that's assuming 8-bit offsets everywhere, go for it. If it's using > gdbarch_addressable_memory_unit_size-sized offsets for all location > kinds, go for it. This means the behavior of GDB for non-8-bit-bytes > target can change, but IMO that's ok. The current code is likely not > entirely correct as is anyway. And if somebody downstream is still > using GDB for such a target, they'll have to contribute fixes if they > want to. We can't guess what's right. And if nobody is using such a > target downstream, then it doesn't change anything. > > Simon > I agree with this. Also, the reason why I use the HOST_CHAR_SIZE is because Pedro Alves suggested for me to use it instead of the hard coded number 8 because apparently, that constant is always guaranteed to have a value 8. Thanks for all the reviews guys. I've just uploaded a new series with all the fixes. Zoran