From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2061.outbound.protection.outlook.com [40.107.20.61]) by sourceware.org (Postfix) with ESMTPS id 325353858D20 for ; Wed, 20 Sep 2023 05:50:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 325353858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v06tLIFbPLveKV+olU+EXF8PolGPh0LiEw/5zulRS+Y=; b=QnMq3nXrWzCyd57avxIrMjSTpY2kzRwClJeNr1mLPEOI3cxZ2ijoaMRo4hZpa60SyeXz1+4Ui7yswu6qRqcF7VGuLRqN9JMLNkMEZvnBGOUHF9m14fZJ6APxujetm/HJvjJWUzxP3BcdsAL5Sck6UX11bUVM0+iGpMhGHcBksOM= Received: from DU2PR04CA0248.eurprd04.prod.outlook.com (2603:10a6:10:28e::13) by DBBPR08MB6172.eurprd08.prod.outlook.com (2603:10a6:10:1f4::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.19; Wed, 20 Sep 2023 05:50:00 +0000 Received: from DBAEUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28e:cafe::dc) by DU2PR04CA0248.outlook.office365.com (2603:10a6:10:28e::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.28 via Frontend Transport; Wed, 20 Sep 2023 05:50:00 +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 DBAEUR03FT004.mail.protection.outlook.com (100.127.142.103) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6813.16 via Frontend Transport; Wed, 20 Sep 2023 05:50:00 +0000 Received: ("Tessian outbound b5a0f4347031:v175"); Wed, 20 Sep 2023 05:50:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 80165339c3b5debc X-CR-MTA-TID: 64aa7808 Received: from d64b9b06f893.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 3B778AB3-E6DF-4C71-800F-50DD797461C1.1; Wed, 20 Sep 2023 05:49:53 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d64b9b06f893.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 20 Sep 2023 05:49:53 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VNVUvhkQE1WZfbWz31tR24v4qev6PNzpNldRC3y/ZUFr6wiNiRliLG2KpXL2g8/zo7zNk1zPGJYfBlwTO4gxHn8X5Y/goy1+hLVFQ5VnpoKNyNeNCUv8XSbFOt+70N0p7tsn0zdW9+eZ09iuoIj/1dpV5zaRBJHd/oQLa1tYhGYw4lYKqzczYP2spECJpWfyfZYfw6t97IBrvyGFnhBSboziBWPJ8vCFt3ySZg1bjK34DMMXKjiiBjk5CxZYvTre0OCn/N/ZW4TcDDVO1Ce2dI2xHBMJK4JXaN6oo+JIaaVqGUxf7P/tIpwNFWZKG0vSaTz5BJfietjzYo1E49Owgg== 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=v06tLIFbPLveKV+olU+EXF8PolGPh0LiEw/5zulRS+Y=; b=dM10DXqxfOZX7bx1nQ1tLQu3Sw0+Uxxbxsb8NBnoZyiod0J8fVZGk6EBx5ERurTNuaJ7sPtVHKBfnOo0kG7C1LdEMfjt8V4RKT/ZkJtlyRHD3VPLiZKXwPML0HaaAo9cNgh2MnZhEjSsp8TvTiP+tT+WKjmCOC/gAFl3MWES02exuWM4LmzcfHr5RiJMeU6oei+qsaE9tRWskSl57LcaAVR6nDcqgZxxQd74mm/U+5F4/GBz+wK6LjIlhQWXL3xxjRzhlbrnlFIxLpfJ06Nn5JD1HwO79cuQZ/Neot7gyXtEvRmXrQOnOFaItzTyiaTsK5p+Fe0iXZN65DaBzKf3UQ== 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v06tLIFbPLveKV+olU+EXF8PolGPh0LiEw/5zulRS+Y=; b=QnMq3nXrWzCyd57avxIrMjSTpY2kzRwClJeNr1mLPEOI3cxZ2ijoaMRo4hZpa60SyeXz1+4Ui7yswu6qRqcF7VGuLRqN9JMLNkMEZvnBGOUHF9m14fZJ6APxujetm/HJvjJWUzxP3BcdsAL5Sck6UX11bUVM0+iGpMhGHcBksOM= 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 PAVPR08MB9604.eurprd08.prod.outlook.com (2603:10a6:102:31b::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6792.27; Wed, 20 Sep 2023 05:49:50 +0000 Received: from VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7743:60fe:4859:2df2]) by VI1PR08MB3919.eurprd08.prod.outlook.com ([fe80::7743:60fe:4859:2df2%6]) with mapi id 15.20.6792.026; Wed, 20 Sep 2023 05:49:49 +0000 Message-ID: Date: Wed, 20 Sep 2023 06:49:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [PATCH v7 15/18] [gdb/generic] corefile/bug: Add hook to control the use of target description notes from corefiles Content-Language: en-US To: Simon Marchi , gdb-patches@sourceware.org Cc: thiago.bauermann@linaro.org References: <20230918212651.660141-1-luis.machado@arm.com> <20230918212651.660141-16-luis.machado@arm.com> <957943ea-a51a-4cdb-b86e-68d2fb85de9d@polymtl.ca> From: Luis Machado In-Reply-To: <957943ea-a51a-4cdb-b86e-68d2fb85de9d@polymtl.ca> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO2P123CA0087.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:138::20) To VI1PR08MB3919.eurprd08.prod.outlook.com (2603:10a6:803:c4::31) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: VI1PR08MB3919:EE_|PAVPR08MB9604:EE_|DBAEUR03FT004:EE_|DBBPR08MB6172:EE_ X-MS-Office365-Filtering-Correlation-Id: f8805c61-2951-430f-f5ae-08dbb99d6d7f 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: FrN01h59AUR9zyMc33PO9Wg0Feu1Pgl/eOI9cPShohcnqeHkA+Q1SnA3lcTCT8y/vHoVIRcArtjK5QW0jjBz6kLEHOmmjPItLjRp/8yJ/i2MokVW/dlNIkX9N9BgFm7uOVDOtUaHQu/u+PCrIvYhApb5g5jyPClf13HsV8fZ4GhFevw25BLsig2Ff39tnZZJq3Shof4gNDfTauD11++vSOlGtKDY3huZID8yTmLbAN2Z16C02f7In9wCTp4T5ykJ5yAkgQd53RK4Kbclj+EuR/PCg2Bo92W9+zjY6GVhZpPt2UPHFDHJ6bxs9KlDf4TqasG/GMRaQW++lWJl1BDRGEGwYpnGnkMiJRAH89QnnU3+C1tComPRRn8RQ7NCPXj5JYqTWcYl6n0T52y3HQr73IxLywXJoDMfprJPgFj0sAl69e09awoYXCu0s5JZXWY29Wvjg8Z3LDhMCP+2SeL6kD++jTitLD9esEmnWH1uCiB8rOzPiOGixqKSQ8bg17z1P3nvWmKz1G9wvzZig1wM0miKQTsCku0+DD3uXA5VvcRtkHn4wVd+HVfbttoRgGpeTYRnG/Dn2q00XEO4fd947Mp0fndy+gQfGRtgJ43Dp7PeLy2gcmD+v/768ahBrfOUS8gScgauNNRL9Aqn+sgj3fnWqbMNBTN9OYMLy2dDPJg= 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:(13230031)(136003)(396003)(376002)(366004)(39860400002)(346002)(451199024)(1800799009)(186009)(41300700001)(66556008)(4326008)(316002)(66476007)(66946007)(8676002)(44832011)(8936002)(31686004)(478600001)(6512007)(6666004)(2906002)(2616005)(26005)(5660300002)(86362001)(83380400001)(53546011)(31696002)(38100700002)(36756003)(6486002)(6506007)(41533002)(43740500002)(45980500001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9604 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: DBAEUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b88010ff-02d9-4a97-4100-08dbb99d66e1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FvgT0RYg/B25YNqX/xJceI4CUZB5WDZiJEbPEJpvLShaFg1FWDJdMXHa63zHc8NvNvLCltx/AWIDKDqVUtxeoBFI4twGOPDIwrNsSs0Gf4Qy74oAtOVkfvV5q7KyRWtQCLlJ2VQYrelbSO+AmVArDXo5BS7bEi6RY/RvAWvd1Fws0qqCTGMZZnHZNNrnj3fxYgxm6Kck5gy+5RcCi/TZOZaxubI1QElmH3O6uX+J0aNQJDw3K6MFkQ8DjSmEUMygSLgXjXVjv76u4CY23Eu/XSoejdmsy02pUb/qcINoo3yAfwsUowVjV0PEvjnHem0BZfm5AN6mfMSjJFYWwvzJ7Wvj6gjoCuMnbsi8wvMeSpHKrHTrKLoYA/JuV32M65wfmV8xGwOKPkGowU7VF3+kYpRRNlWYluvWMU+11g9Sg1az9cw/o4Kj/fRS/MaLmeUxR/pUqQazOtxseiPo4cml29anjfXa/mYTtFQkoxZZClYlXX+MqOkqZna+SRZDqfdJE2mLuXabrX4+F+s76Nn0dEioXa7Qk0hLwXez8lrdjvZG3hqqtPOk+hR9z3GfYNt1rZnky0wwc03A+yLcIMhgod1A/zWZB5CcVl0TT06zHgU4XL1zSxigIWakXguxxoPfYlWN1RvOTnQNi7Aaj+keC2UA4r58JIoy9R0AySwNMJqM25xP2K6c78lwHdp0LSmkTgIN9i6nKDX30ol96pOzCU2RQIhOFfwx5heguCCiqi77pxm+XiVSgG5mduZ8Z61XoCBMY9FTJGYlAO1yxew9nO4EnRv6C3kB/SA67nXOUb0= 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:(13230031)(4636009)(396003)(346002)(39860400002)(376002)(136003)(82310400011)(1800799009)(186009)(451199024)(36840700001)(40470700004)(46966006)(478600001)(6666004)(6512007)(6506007)(6486002)(53546011)(8936002)(8676002)(44832011)(83380400001)(70586007)(31686004)(70206006)(316002)(5660300002)(40460700003)(107886003)(36860700001)(82740400003)(86362001)(31696002)(36756003)(40480700001)(4326008)(26005)(336012)(47076005)(2906002)(41300700001)(2616005)(81166007)(356005)(41533002)(43740500002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Sep 2023 05:50:00.1007 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f8805c61-2951-430f-f5ae-08dbb99d6d7f 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: DBAEUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB6172 X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY 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 9/19/23 21:49, Simon Marchi wrote: > On 9/18/23 17:26, Luis Machado wrote: >> New entry in v7. >> >> --- > > Note: when you use `---` in a commit message, git-am drops whatever > comes after that, so here we lose the commit message when applying. I > think the intention is that you'd put whatever you don't want to appear > in the commit message (like the "new in version X" notes) after the > `---`. I'll try to do that from now on. > Yeah, that's a bad marker indeed. Is that configuration-specific though? >> >> Due to the nature of the AArch64 SVE/SME extensions in GDB, each thread >> can potentially have distinct target descriptions/gdbarches. >> >> When loading a gcore-generated core file, at the moment GDB gives priority >> to the target description dumped to NT_GDB_TDESC. Though technically correct >> for most targets, it doesn't work correctly for AArch64 with SVE or SME >> support. >> >> The correct approach for AArch64/Linux is to either have per-thread target >> description notes in the corefiles or to rely on the >> gdbarch_core_read_description hook, so it can figure out the proper target >> description for a given thread based on the various available register notes. >> >> The former, although more correct, doesn't address the case of existing gdb's >> that only output a single target description note. >> >> This patch goes for the latter, and adds a new gdbarch hook to conditionalize >> the use of the corefile target description note. The hook is called >> use_target_description_from_corefile_notes. >> >> The hook defaults to returning true, meaning targets will use the corefile >> target description note. AArch64 Linux overrides the hook to return false >> when it detects any of the SVE or SME register notes in the corefile. >> >> Otherwise it should be fine for AArch64 Linux to use the corefile target >> description note. >> >> When we support per-thread target description notes, then we can augment >> the AArch64 Linux hook to rely on those notes. >> >> Regression-tested on aarch64-linux Ubuntu 22.04/20.04. > > The question that came to mind when reading this is (I already asked you > on IRC, but perhaps someone else has an idea): if GDB has to know how to > infer target descriptions from the core file contents (the > kernel-generated core files don't include target description notes, only > GDB-generated core files do), what advantage do we have of storing and > reading the target description in the core? Are there any scenarios > where the target description note conveys something that GDB wouldn't > figure out by analyzing the core file content? > According to the original commit that added NT_GDB_TDESC, there are potential use case around dumping a core file from a remote session. That remote target may potentially have more registers than what gdb might be able to infer. >> diff --git a/gdb/gdbarch_components.py b/gdb/gdbarch_components.py >> index 846467b8d83..bbb9b188286 100644 >> --- a/gdb/gdbarch_components.py >> +++ b/gdb/gdbarch_components.py >> @@ -2732,3 +2732,22 @@ Read core file mappings >> predefault="default_read_core_file_mappings", >> invalid=False, >> ) >> + >> +Method( >> + comment=""" >> +Return true if the target description for all threads should be read from the >> +target description core file note(s). Return false if the target description >> +for all threads should be inferred from the core file contents/sections. >> + >> +The corefile's bfd is passed through OBFD. >> + >> +This hook should be used by targets that can have distinct target descriptions >> +for each thread when the core file only holds a single target description >> +note. > > I think the last paragraph should be left out. An arch could decide not > to use the target description note for whatever reason it sees fit, this > is just one example. The reason for AArch64 appears to be sufficiently > described in the AArch64-specific files. > Will do, thanks. >> +""", >> + type="bool", >> + name="use_target_description_from_corefile_notes", >> + params=[("struct bfd *", "obfd")], > > Can you name the parameter core_bfd maybe? Just a bit more precise. > That was my first try, but unfortunately core_bfd seems to be a macro, and it doesn't play well in this context. Maybe a longer name that dodges the core_bfd macro? /* Binary File Diddler for the core file. */ #define core_bfd (current_program_space->cbfd.get ()) > Otherwise: > > Approved-By: Simon Marchi > > Simon