From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from CAN01-YQB-obe.outbound.protection.outlook.com (mail-yqbcan01on2055.outbound.protection.outlook.com [40.107.116.55]) by sourceware.org (Postfix) with ESMTPS id 102FE3848346 for ; Mon, 13 Nov 2023 19:51:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 102FE3848346 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=efficios.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=efficios.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 102FE3848346 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.116.55 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1699905094; cv=pass; b=MyduEG1IXD3wQBxh6jEQYtaNzjT159U/jcjRSYKWsx7pj3CMSZ5jvd0dZtq5blP3+wjHQzIpabXzpw6cEK09vpfNWSAHM8hQUVcf2RCL4335PgjSAOg7bGbZp6s1deMlzvDGm9c3BICLugQF+sWWu405CNaeF8FsdMmoZlJz49s= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1699905094; c=relaxed/simple; bh=j1KkT4AKaB0WCduMP5v5wFROkWlM9SWhywqnuII7GgA=; h=DKIM-Signature:Message-ID:Date:Subject:To:From:MIME-Version; b=u/WUwuZzXjyzg75cE0iyOFDEwpB2n8HXGyrcKs//lnIXFCUYzq/a3eeVMcjmagXrhnLZnH0txAnvs8DVE0T9+u3Mq0NVNAr2mk0HVyc5cBItEQG+ZmoMctG0/AZCjqouJ0n6qRYJ20Mk00ccQ1C0XVtEtcEr3AUesZ+/JATjyIA= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n6YqCpOFG07mPLaExDZUEvKG5b7tBgpSfMK5o/EIIMyU32/33zC31UihS5nW5pSaYuH9lpiKCcODpsO/KZsk7sMcWF79YkBUV61K7ZAs9hwBJQz+tjQG9pb+Q6DiZGI9KyizYZYm2Z8zqnFB+pAFrq9/bLgzq1ryl4LTX1hbgqcPLIWVND59IY4rUjFM3It5tAmHBr07YF75WaN2x6hC+oMS2Kk1LjxbjwyyctlSYY1JnTgMRC0/yCQIlnba/0QkpgmBzAgtYBHlC7BSPt5J/FbQyFV28Lr7gqf0EVv/UaUDBVEqt42ouB76hMylfselx7Rs+0iuucpPVkTxYkmGPA== 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=qXy4zfs2yiGZCZwBIXDJyoaOdOMQIP44+ePQz+KQacQ=; b=MmKoy+SMfog4vtAoRuXtfiOVW32CBCN0LCUfNx1c4kj4jGfzErG7XDMEZlqIgxg97dF+jmjbs/i/5JAhERzmMAASNUlmqYD8Q2smuG6l7ioXHqdEbAVxT9KuLtWAr8XHPEKpHX2G5IijvP6+rLxZU9E7XzdgDz8BllO6ovD7WP1thgVaAPpF52RS4qUFe1h6ujXxCTEnCx9PitNaCD4aYxZbZ8ozDYkxwhmjZaMpHQH45yrUdnrsN5+Bz9r6UBEsU4VEVDgGGsZwf5PMCjnCd8u/cgIJ3l/XA/79IdDp8ig0n0f1uvLvOWcbUfhRKX7IfjsxNMiTcwixmqfzWIGWmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=efficios.com; dmarc=pass action=none header.from=efficios.com; dkim=pass header.d=efficios.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=efficios.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qXy4zfs2yiGZCZwBIXDJyoaOdOMQIP44+ePQz+KQacQ=; b=bBpLio3Vbnox+35xg5NJVqEfLbz0v7CpJLkaUGElu64du2Ky8vrN/esDJJiHlPnuP1sk8Fy8D3iqEPBEb4lCAg0OF8hc6jPOXFQHSDlZ9gbG5USUMaClntOQ0EB2G7K8dNkjKWogOlQCdtQnXmVMzBfZnyHjZne/rSW7UYh3R5yxLhvPmdY3ppDQuWqluJWtRuTvOta/NpVkutPh7bXKzLl5WrXk2iusH40fWTyyVjIWssW2skA7Sh+n2lwtiOe9Ock/JJYfnjktGUz1UobTEerqQKpI2MnY43YHvvoCZgvbbrv+eZEsaaZ0CvI6Yb3tI6YZpWn4P2lTI/8iNqa+yg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=efficios.com; Received: from YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:a::23) by YT3PR01MB6019.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:68::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6977.28; Mon, 13 Nov 2023 19:51:29 +0000 Received: from YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM ([fe80::9378:63a0:1c28:2df7]) by YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM ([fe80::9378:63a0:1c28:2df7%3]) with mapi id 15.20.6977.019; Mon, 13 Nov 2023 19:51:29 +0000 Message-ID: <0c13a505-b04a-4d48-afa0-91517a87de70@efficios.com> Date: Mon, 13 Nov 2023 14:51:28 -0500 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 06/24] gdb: fix bugs in {get,put}_frame_register_bytes To: Andrew Burgess , Simon Marchi , gdb-patches@sourceware.org References: <20231108051222.1275306-1-simon.marchi@polymtl.ca> <20231108051222.1275306-7-simon.marchi@polymtl.ca> <8734x9snoj.fsf@redhat.com> Content-Language: fr From: Simon Marchi In-Reply-To: <8734x9snoj.fsf@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: MN2PR16CA0025.namprd16.prod.outlook.com (2603:10b6:208:134::38) To YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM (2603:10b6:b01:a::23) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: YT1PR01MB2828:EE_|YT3PR01MB6019:EE_ X-MS-Office365-Filtering-Correlation-Id: 04e1acbd-7663-4958-caf5-08dbe481edd1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5jxWRS+D4CETbM1Nd/LS1Z452JGggW8aamBPzwH5MNqGHWlwYaw/3KO5XivwwTlbHiOfybQhSUVao9gbAE5VkOGK+lKnF/BVpVqCHleCusRMWaXrFQdLt2bmC/QXUAUxEVL4KEFACOw/0VhyeHnviABv/DBlD/1uHU1izy2w+1LrPUlQz789RwpbRphdno+q2goRP21MpddQLUTox+cKhw3JcblXR5QpRdbpeFNJNPwlq8gUhcPl1E2UdRu2ZsX9/Tt4fGSllTrrKxBUOrfseyiyABRWBU9mHuSCZIH0uJmyrQluFv4eMHP88dd/ArL1GAfrm1TiFmEZQri0pBM8lEN9ceUSieDlPbaXrgSHLiSnsdVD5o7GFyW3FyI0WnYoeAzEP6P3a9lymcAXdKX+VlMRbF/xNXW0d+0Pae+WIEZaM10nNyj8HLxWSFyLH4ekZHGPMuICdSJy+Ubn0C0SKT9pYUGSLY0beF1dY4zOz8XV9RCcWr/gFpXZSMYQeh5G305fbCI61rkPD9UKPGGmyzWlbinSaXKTTZk03uqmyaEbNtZ18DT/pH9emHM95cjF6scaHwAj3RYZ4Bbe4Y5eZTttPAsqw/gTCf0XPRHVxiH1OMt+UgqDMyGo/w2KSwNfsjFPdJQzWnAeo2C/slsQqw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM;PTR:;CAT:NONE;SFS:(13230031)(136003)(376002)(396003)(366004)(346002)(39830400003)(230922051799003)(64100799003)(451199024)(1800799009)(186009)(2906002)(83380400001)(36756003)(31696002)(38100700002)(8676002)(8936002)(6486002)(478600001)(44832011)(53546011)(6506007)(110136005)(316002)(66476007)(66556008)(66946007)(31686004)(5660300002)(2616005)(41300700001)(26005)(6512007)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d3I0dlNFSVdjZ2haWXpuTjVwVHNqQnc3VmNDNTcvTmNnMFNueVFWdFpzWThC?= =?utf-8?B?ZVovYkM3aEd0ZVVBZmtCaFVXNUl2WVU2Q2dXcGRsRU1FcVdSS2VmQlNBdm8y?= =?utf-8?B?YWQvTExOclpURm1YdVNHQVBNbFlOci9tZ3ZYYlQ5N2x0cEZ4cDQ1Uk5Kd29w?= =?utf-8?B?d3VYc1ZFRjRtakZzWGQ1OENJWWlldlBqcEFvbWxoSWgrcU03Y3JCSGJmbmda?= =?utf-8?B?VDhOMkxNWUMzOXpzMWFWSmxQWDF3TlJEZFlIUVVESXlub09oRmN1NVBGNlJh?= =?utf-8?B?NWJTb3luSXc3RnhIZnR1Tlk0RkFxWjliRkNmZ2dia1o3bm1aM0pRZVM4ckNv?= =?utf-8?B?WHoxcmZCMDBRcldxSzE0cUdqV09VVHB2SzJXM0gyVFpqSkd3dG5lZmNTRHRh?= =?utf-8?B?TWpvVW1uZllFRmhHSzZUQ1BLc1E0aXdFYUJRR29hU1EyRmtCNGlZRlRtMjVq?= =?utf-8?B?clA1b0x2U0FzaFBFTmNDL0pWdStpT1pjSmZSbEI3YVFFOUNmaHYxSHBOSUtZ?= =?utf-8?B?SVc2UHJVdlBpUzkwbGEwZnZGTVdjMFN3L0d1OTR0b1lJNjBBdThhZXlsTzhj?= =?utf-8?B?VWdicFNvanpXcUo0UTBGTUNvTk9jalZ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ll4VVpPUDZvOXJ6RE9FZVBHcXIxWkF2?= =?utf-8?B?azN6YzdaQzBGTWVLV01wejdYWkZ4NW53ck1keFNQaXE4STJyNFg2aG5EbVpW?= =?utf-8?B?aWtLNzJJTE1KTTNZRDFFVXFHQms4MFRhbncwVHNXaC91UE9vSXU3OWxFdTlP?= =?utf-8?B?Yzd5YWRsZ1poUmpsSkF1V0hxNDRNSDIwTXZ2UGIyY053eEpLNDVLOFpxQ0dV?= =?utf-8?B?b3FES2NyMWt1dm50U2xaMVphaE1OWndZbXVsbGxVVFk3MTcwc2xqdUdINnhn?= =?utf-8?B?RGF3blJ6TzREY1dLTzd3NW5EVnE3QWdaWnhRb0d4a2FweDlHWW01UmJzbDQ3?= =?utf-8?B?TFdlTVVKM3VFRUlLNytPRFhudjF5UjVqaks2MDlSM2F2L040ZHdBSGZTQUNV?= =?utf-8?B?WmJHeEFCNU9aSExUMU15RHo4OHQ3RHRVTUZvOUgvdlV1eDdTWmIyZ0tGbWli?= =?utf-8?B?NkpXZDF2TkROemgrd2MxS1lrWVdKdFMxdVBkK0lCMTEzeTZYUXBkemVwR1Fp?= =?utf-8?B?MUZ1bnJPU1RuQ0NMUlFPM1BKUy93TGYyQmExTEhCa2dUV010UURzcU8wblUy?= =?utf-8?Q?SFkogYJObTHC46Wxh9V01Kuae?= X-OriginatorOrg: efficios.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04e1acbd-7663-4958-caf5-08dbe481edd1 X-MS-Exchange-CrossTenant-AuthSource: YT1PR01MB2828.CANPRD01.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Nov 2023 19:51:29.7157 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4f278736-4ab6-415c-957e-1f55336bd31e X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ftADIHuUw7mmhfq8Ge3JVtjYbyTjAlHZLK0Uv2BsDuhtzqQQCd/tgSGxA4axF87nHt25XIFHeJGhpMmI7K9RhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: YT3PR01MB6019 X-Spam-Status: No, score=-3032.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 11/13/23 10:00, Andrew Burgess wrote: > Simon Marchi writes: > >> From: Simon Marchi >> >> I found this only by inspection: the myaddr pointer in >> {get,put}_frame_register_bytes is reset to `buffer.data ()` at each >> iteration. This means that we will always use the bytes at the >> beginning of `buffer` to read or write to the registers, instead of >> progressing in `buffer`. >> >> Fix this by re-writing the functions to chip away the beginning of the >> buffer array_view as we progress in reading or writing the data. >> >> These bugs was introduced almost 3 years ago [1], and yet nobody >> complained. I'm wondering which architecture relies on that register >> "overflow" behavior (reading or writing multiple consecutive registers >> with one {get,put}_frame_register_bytes calls), and in which situation. >> I find these functions a bit dangerous, if a caller mis-calculates >> things, it could end up silently reading or writing to the next >> register, even if it's not the intent. >> >> If I could change it, I would prefer to have functions specifically made >> for that ({get,put}_frame_register_bytes_consecutive or something like >> that) and make {get,put}_frame_register_bytes only able to write within >> a single register (which I presume represents most of the use cases of >> the current {get,put}_frame_register_bytes). If a caller mis-calculates >> things and an overflow occurs while calling >> {get,put}_frame_register_bytes, it would hit an assert. The problem is >> knowing which callers rely on the overflow behavior and which don't. > > I agree that this overflow behaviour sucks. > > I have a memory of being told (years ago now) that this was a result of > some older compilers not emitting correct DWARF for compound value > locations, instead the compiler would just emit a single register > location, and assume that the debugger would read from consecutive DWARF > registers. Note, this code assumes that the DWARF register numbering is > the same as GDB's register numbering, which is not always the case. > > Personally, I'd love for GDB to be more aggressive about removing some > of this legacy behaviour. What I'd like to do is move things like this > behind a switch, say 'set maintenance deprecated-features on|off', which > would be off by default, but when it is turned on we'd print a message > saying: > > The feature you turned this on for is deprecated, and will be removed > from future versions of GDB. To avoid this feature removed, please > file a bug report here describing the deprecated feature that > you are using. > > Then if nobody complains after a couple of years, we can start deleting > things. > > Anyway... just putting my thoughts down. I think this patch is fine. Agreed, it would be nice. > Approved-By: Andrew Burgess Thanks, Simon