From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2ZJLJsnf8GlZTgEAWB0awg (envelope-from ) for ; Tue, 28 Apr 2026 12:26:49 -0400 Authentication-Results: simark.ca; dkim=pass (1024-bit key; unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=rMxGbrHJ; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=rMxGbrHJ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 977E41E0BA; Tue, 28 Apr 2026 12:26:49 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-2.4 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPS id 7260E1E067 for ; Tue, 28 Apr 2026 12:26:48 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 3EF214BB8F4E for ; Tue, 28 Apr 2026 16:26:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3EF214BB8F4E Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=rMxGbrHJ; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=rMxGbrHJ Received: from OSPPR02CU001.outbound.protection.outlook.com (mail-norwayeastazlp170130007.outbound.protection.outlook.com [IPv6:2a01:111:f403:c20f::7]) by sourceware.org (Postfix) with ESMTPS id 37A404BB8F51 for ; Tue, 28 Apr 2026 16:26:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 37A404BB8F51 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 37A404BB8F51 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c20f::7 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1777393563; cv=pass; b=k5x8TogxQv4HsLbmUFhDViyyUiSqIiBr9l3X7MFublXxt0iy9ixJJntRxWah3FpVw65JDkLAJoFgsdJz3Nsn7F5zKHYECftwQROQmxTmaDSq978aEfLXfeKSKyXokEu01MWXrmsuKa6IVLnqQrwoyVVwQbU2VkLlWTTthqSjCro= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1777393563; c=relaxed/simple; bh=40mU8L5IFbiZs8kIx+0zJwPK0IbmXCwAG1/Kql3k9GU=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=RBhX14957PmrvS+KfeV06/5XEHn3xWCpV1YIA2uY2BHoCJAVt/i4BdF/yrit1oQjkkOpNejEy9RGy9JqbGLdI0KXXmU5vmZIfOVN/4ojifQmoQM25Dz0dokv26u3+ou+e6mxSoyAETbNE4pd2Y/f2VDrHsz6Vx5YfnT71k5G5iM= ARC-Authentication-Results: i=3; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 37A404BB8F51 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=YT8kLwt/ID46vOla6xJMXUfPM4nLZFC5+rHVDd49tP3Lnd/NfYCuklN02qTSIu1DdA+08Z1y/F/tB8neJMKjvWjsCKt+vqkNC4bT2ptZq7kPzu6r27/u3rvSpyMVwoQyqeLJTlDOXMdTCm5jZsHRYfXIwQXfkQpeF+T6SlJgZO8CksbIpLCE1arkSJEPWkZYRKbn+OwOD8rDYNWgvbbbYFAYTAB6P2CVQSMBBoPBn0ynhgGVtzlNTP/+0HYOjNFdeWgogvLytn6dLfZF8z3zGEvikPrNNSaj0mzjHnIMeByRGl2U8aaZfvPsolWWc71JuONlG3UXkoydE2ZPhYw7zQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3FGQTK0uIOLjFS4Rfi3Jb/A5t4UErwrOlsjMmBn/FWA=; b=lRSqIXNupRg+0lQpejVzoWv7zUqRsHGy5MIElhP8sjGeoBifSKbw00Ndl/hPHLd6ROdEkWx80VY0ufGU021eInOHOgkNkRPKlS/PnyfE3XnPorM3KyO+StKKwo80JUZ3OU+k9s1y5KIGiAeeWfQZO7NbwhrlC9KotIqzZjMNNajhmeKh0TL1DxfvImrzN7OYst1R7V7cl9QA92yYesaemAMfA+V1o2SXeK+mpbTOg3RMheo1Wo9cTK4IrXP8KpXyhhJc/JsjlvTqISFFlFaGI4TdC09RtyNQeOwShHelhICxX3zyaGVP+Jh6jfgt5uVncnYpqj/UTnrlCkvac/LRbA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) 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=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3FGQTK0uIOLjFS4Rfi3Jb/A5t4UErwrOlsjMmBn/FWA=; b=rMxGbrHJrXrOmsRrKqRfUq11vpEE0NgSxST86EY5nxLUdkbYVHqM6LIvfuyuxbfvk/x6CtrsNDFuhlYGrcUC3F7ZNoJTMwQ9nY7apvycp3dHQrvBa8R6sf0J1hy96szjvWKtKIAdasQYLFgHNm216KBw80MFjeWGEUm8UaO/ss8= Received: from DU2PR04CA0248.eurprd04.prod.outlook.com (2603:10a6:10:28e::13) by AS8PR08MB9621.eurprd08.prod.outlook.com (2603:10a6:20b:61a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.26; Tue, 28 Apr 2026 16:25:57 +0000 Received: from DB1PEPF000509FB.eurprd03.prod.outlook.com (2603:10a6:10:28e:cafe::38) by DU2PR04CA0248.outlook.office365.com (2603:10a6:10:28e::13) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9846.26 via Frontend Transport; Tue, 28 Apr 2026 16:25:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 4.158.2.129) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=arm.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 4.158.2.129 as permitted sender) receiver=protection.outlook.com; client-ip=4.158.2.129; helo=outbound-uk1.az.dlp.m.darktrace.com; pr=C Received: from outbound-uk1.az.dlp.m.darktrace.com (4.158.2.129) by DB1PEPF000509FB.mail.protection.outlook.com (10.167.242.37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9791.48 via Frontend Transport; Tue, 28 Apr 2026 16:25:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J1hJXnDPntbq5Acj1tyoFDjtsT1ktcy3iDRgC8guUpxsmdC0X/VKDII2tXfgKJkXNTIsqZW6VmNbWqq0wbj1K2tYWvKEyDEUiY/dOSbrP1ujryH0hLAKjvThITAhgYmAxVIVRqcXVTNOfYNjSeEj3KfMcgewT7rAdcwpk5EKtrrafHTcTsdeGP0wCdwqDopgUQGovIoSHdsZQIywlLHXEpfBXuG5aMkwZzaChDB3p7y0zmFDN05CIXOCvxhVGZq9b8npJ6DwRE8eNonxZJDJldnEgA7R9sG/jl0K8lkDgq8WzaMQYPrZSINLDqY626Rf/5+zKloY2tzSSEwdZjEdyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=3FGQTK0uIOLjFS4Rfi3Jb/A5t4UErwrOlsjMmBn/FWA=; b=Eq7GhbrJoiaZMlSju0g9Jlarxayxre4F5mIXArm5uB9/whW8YBA8NG7YnwpGYwCpp4un6GrbGFOh7UR2F9Hi835LYSJGDC6PfjMtW2aRvFcAIc/1L9BTXifPcsV85qJDu2rKiik7fgT5Ow0ZppBBRQ4Xux3F1GN3dp5uTv1JERbypSzjRHcnuGZuI5PttmDGj6iL/p8jmR1NEaMa1pRlzespvn+s/UQBBD/SwVYfrkT3RdkWE58VSpMfx/Wgc5/PRGpQjEXhcH4VudoEDbQqbKvQ4xycp1BvtJjpUi44he7UewTa2Upn8wmYuq1J3LJC5dub5M/VqKl2yAG6kmEP8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 172.205.89.229) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=3FGQTK0uIOLjFS4Rfi3Jb/A5t4UErwrOlsjMmBn/FWA=; b=rMxGbrHJrXrOmsRrKqRfUq11vpEE0NgSxST86EY5nxLUdkbYVHqM6LIvfuyuxbfvk/x6CtrsNDFuhlYGrcUC3F7ZNoJTMwQ9nY7apvycp3dHQrvBa8R6sf0J1hy96szjvWKtKIAdasQYLFgHNm216KBw80MFjeWGEUm8UaO/ss8= Received: from CW1P123CA0026.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:292::19) by AMDPR08MB11412.eurprd08.prod.outlook.com (2603:10a6:20b:71e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.26; Tue, 28 Apr 2026 16:24:54 +0000 Received: from AM2PEPF0001C710.eurprd05.prod.outlook.com (2603:10a6:400:292:cafe::1a) by CW1P123CA0026.outlook.office365.com (2603:10a6:400:292::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.52 via Frontend Transport; Tue, 28 Apr 2026 16:24:53 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 172.205.89.229) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 172.205.89.229 as permitted sender) receiver=protection.outlook.com; client-ip=172.205.89.229; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (172.205.89.229) by AM2PEPF0001C710.mail.protection.outlook.com (10.167.16.180) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9846.18 via Frontend Transport; Tue, 28 Apr 2026 16:24:53 +0000 Received: from AZ-NEU-EX04.Arm.com (10.240.25.138) by AZ-NEU-EX03.Arm.com (10.240.25.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 28 Apr 2026 16:24:52 +0000 Received: from PF4S4363.arm.com (10.57.21.183) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 28 Apr 2026 16:24:52 +0000 From: Matthieu Longo To: , Tom Tromey CC: Matthieu Longo Subject: [PATCH v2 3/4] gdb/python: migrate Python initialization to use the new config API (PEP 741) Date: Tue, 28 Apr 2026 17:24:15 +0100 Message-ID: <20260428162416.511367-4-matthieu.longo@arm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260428162416.511367-1-matthieu.longo@arm.com> References: <20260428162416.511367-1-matthieu.longo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM2PEPF0001C710:EE_|AMDPR08MB11412:EE_|DB1PEPF000509FB:EE_|AS8PR08MB9621:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a3d8f26-778b-4e55-fdfb-08dea542d407 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|376014|1800799024|36860700016|82310400026|13003099007|22082099003|18002099003|56012099003; X-Microsoft-Antispam-Message-Info-Original: ZNVmnMZ0aRt7pMjzM+Zl1X6r7vjTlBwNToxyGr/EVk+puu+3ksD4dPJKGo5yQB9VWzN1P4ekMmx8Zot8RgO9waaRCKA7VJ7fiDzLr6jbnWqlzj7LEu1Xs65t1RIEBxwHHWpLERO/unnfRlukj5z0L75/D5QVQga1o4gz2V2FxeJLk/aOKQmlaY9YPioFJmm2lIF5RhSR/2tsLbOAlL9Sgdd7ehZY6rELNBd7pT4d0Mj2iVcrJCgtasC6IghErYah3NM7xaNA4D/rrf+Enh4WMq8C2C6CO0FdieiaFievFiG7TJc/Jc1m0u1Rq2LhF+RSnRgw8dLfW7ggFvb4OjROkongRadrv1SYF+JgK+1IqU5J01IB+JtrJXXd3hgqEKeB9oskAKkn6WQ8l1UXyqqA1modpuSIchHo9rakfMT1DTY5p834rhIj/UxfPHO0groGJ7aPbdsZsyjk+RcRqx0tRJYxhzEydPmK2D/RO2lafGMq4Ul/lxItc6l872bW0EHPql2EEqWaaQU7Q0DnYCIzaPrCXKd3sd48d/MN2I7aHRCWFWOJsqdpY5F4QmwJzU1RjeXeaYoECvRc3DFhlR2slLP7pNMgTmq6KfAKfJQftpLbwwGw9mdHE6JhO2yOAocZLT5QEehuuRMJy5ZPi1K8Rz+xaTyW9fYXV2iMkTiZ/pQX+s70mexWn+4wcz6ieMi9SUUdN8tqICk+OJU1BWs0ttVYRaSAESEg8jRmfJaOoc8EYBDE5hOXhrLlJ5XgGE5t+JDJJy0xN5bpYSdU+NBGPA== X-Forefront-Antispam-Report-Untrusted: CIP:172.205.89.229; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(36860700016)(82310400026)(13003099007)(22082099003)(18002099003)(56012099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: rSNRxiONLoWxa4Ch9BAqiIeNWgQ8WhLWWVIzHeI2PC08A7MG4o+xObIKWkW5fB21TvTD2EjRvQI74W3Zky8Gdv3Zfipivv3dFZsQvvB0OFuW7nBA9yKmWe1bAyOdTU3o3ESXfsbtEpMa+rpdt+ATqpZqgnjIoh9QGMN06lqQgVcDl73dL7HEkA8sFjQRQ/9j6NnygdtqtR7DiQDMpv5NMm53MZSb96CpJbApf/sJPV6GWfaxOLnIVJuPihI+x2PoInUzdk0LttMRdRM5ICjiRCeuViTKkHnMVx1oKwK8bRRmZB5GuT/zibPclPp/F5S4myR4CW7GQOWihbVWUJsQ0g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AMDPR08MB11412 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF000509FB.eurprd03.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 6ddc3575-bbb4-4913-926a-08dea542ae00 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|82310400026|36860700016|14060799003|376014|35042699022|13003099007|18002099003|22082099003|56012099003; X-Microsoft-Antispam-Message-Info: wBogog2KFLbB7+aL5Yr11QropjM+B/qqzliRLxARe5P1p3DROm8102cd2720/zjWBlishIqTD/Tm1+GzzMWJznFAtBvnuErBhSTyHs+7AAbQq362TdO29z3AnfWHj+H0p3eGfVkHV2Urz4q7As2pQsjxbX1cGAP943C8QzlN0xD4YI+hX9bzyVQWJrRyz3ht5MUawUs66k0c/GVAbvbs6NdjWj28jhFgtM4M2jnbKH0C8zadiEUjH2zDsoqJtFibaA0F2mdBsjHIPAwWr2nJ0uT5YD1pa6vlhV+tamVX/n79jg6dZJzoHg5onswEdEj5WBriHmAsmoEVqpQ/vQxpvVnRlaVLXxYS2y6xklMTHH4uB9J6EWNQ0ZTFDgVw/EOJTkeGaAU94N0/viALxO1DBgIoGyLDZyvqbyK66k7Mf1NdL+ig0OXPproiGk+YCrS8JPs4dT4cnbRZXIm/t44ZxRbjpbIMsrg+47UOj2dS3rMwdgbwb05nN/4IB/AbY6XN6TmyvDQR9u2piiP4TOjyZUQOsH8kC9MHdHnnrqKgCdPBAqsIV/IO26US5eThCWRO244oMO6hXjUZTQI1g4hak6YP9aaWfZRA46d+Ab9JMUOGKgWhgZoX1XMzAxSCSXA1QUJildHI4mWdBhHhyhPR9E0kP6bhOXE38dfB8xBiVReV2a6AMv5dRk1kh6xt4B8ylV2V2Tvkv1ehPBkzCYYcWCo3wPv50bGAz+9p/6QU5atbOW7LS4VaAbBIPKkX4CNEvStSElkXg+Uzi2yQWo3HAw== X-Forefront-Antispam-Report: CIP:4.158.2.129; CTRY:GB; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:outbound-uk1.az.dlp.m.darktrace.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(82310400026)(36860700016)(14060799003)(376014)(35042699022)(13003099007)(18002099003)(22082099003)(56012099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HmF74HkiKb/XBoxDV2ZV2fcKAhjqIPT+IlYR9TKm20O0efKAK0/lPyFbeGIZGrOSEPbW8tgKQfMGPFf1PhicCSJ2ZTCsnnqR2ziv1ltBNm9nUntGehER4evy9y0+y2ttXWJYErTuXBN+BdcrEyA0QQ8br9D8Zt/8CIRtaADLMin/qbcEG3PVN89kfay32L4z1D7TXRwsGh6+Gc2jJJygsgNpxWcyFXUll9VX9LQ9mPLazhlsEuTdduDiTknv65/SlwUQX2m7nItVTTCO5tVQ3iC60eGQaggPm4Q80CzNPMN+KxOTTmNQEGfDtsNgM8Bt8SC74Gj7KXVodteiG4sqUmA2/xizqZq8hX7XNuXviXv0W84Bm3YLSpe5Zg3Eyo6+QDzvtEk2IVe0sKfTOxivBAMxadCCI5ENikAC/C8QxHuDj+sgJoOiarY9wvnTms8d X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2026 16:25:57.6460 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3a3d8f26-778b-4e55-fdfb-08dea542d407 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[4.158.2.129]; Helo=[outbound-uk1.az.dlp.m.darktrace.com] X-MS-Exchange-CrossTenant-AuthSource: DB1PEPF000509FB.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9621 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gdb-patches-bounces~public-inbox=simark.ca@sourceware.org GDB currently initializes CPython using the PyConfig C API introduced in Python 3.8 (PEP 597). From an ABI stability perspective, this API has a major drawback: it exposes a plain structure whose fields may be added or removed between Python versions. As a result, it was excluded from the Python limited API. Python 3.14 introduced a new configuration API (PEP 741) that avoids exposing plain structures and instead, operates via opaque pointers. This design makes it much more suitable for inclusion in the Python limited API. Indeed, this was the original intent of the PEP-741 author. However, CPython maintainers ultimately decided otherwise. Since GDB aims at using the CPython stable API to avoid rebuilding for each Python version, the absence of a configuration API in the limited C API constitutes a blocker. Nevertheless, this can be worked around by using PEP-741 configuration API, whose design is compatible with the limited C API. It is relatively safe to assume that this API will stay around for some time. In this perspective, this patch adds support for using the PEP-741 config API starting from Python 3.14. When Py_LIMITED_API is defined, the required functions are exposed as external symbols via a workaround header. Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830 --- gdb/python/python.c | 122 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 121 insertions(+), 1 deletion(-) diff --git a/gdb/python/python.c b/gdb/python/python.c index 546d1272007..10a77880340 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -22,6 +22,7 @@ #include "ui-out.h" #include "cli/cli-script.h" #include "cli/cli-cmds.h" +#include "exceptions.h" #include "progspace.h" #include "objfiles.h" #include "value.h" @@ -2210,6 +2211,93 @@ static bool python_dont_write_bytecode_at_python_initialization; to passing `-E' to the python program. */ static bool python_ignore_environment = false; +#if PY_VERSION_HEX >= 0x030e0000 +namespace { + +/* A class wrapper around the new configuration functions introduced by + PEP 741 in Python 3.14. */ +class gdb_PyInitializer +{ +public: + gdb_PyInitializer (); + ~gdb_PyInitializer (); + + void set_opt (const char *opt_name, bool value); + void set_opt (const char *opt_name, const char *value); + + /* Initialize Python with the current config. + Note: this function should be called before the object goes out of scope + or an assertion will be triggered in the destructor at runtime. Setting + options value after this call does not have any effect. */ + void initialize (); + +private: + [[noreturn]] void handle_error (); + + PyInitConfig *m_config; + bool m_err = false; + bool m_py_initialized = false; +}; + +gdb_PyInitializer::gdb_PyInitializer () + : m_config (PyInitConfig_Create ()) +{ + if (m_config == nullptr) + error (_("Python initialization failed: memory allocation failed")); +} + +gdb_PyInitializer::~gdb_PyInitializer () +{ + /* If the condition below is false, the calling context probably forgot to + call initialize(). */ + gdb_assert (m_err || m_py_initialized); + + if (m_config) + PyInitConfig_Free (m_config); +} + +[[noreturn]] void +gdb_PyInitializer::handle_error () +{ + m_err = true; + + const char *err_msg; + if (PyInitConfig_GetError (m_config, &err_msg) == 1) + error (_("Python initialization failed: %s"), err_msg); + + int exit_code; + if (PyInitConfig_GetExitCode (m_config, &exit_code) != 0) + error (_("Python initialization failed with exit status: %d"), exit_code); + else + error (_("Python initialization failed")); +} + +void +gdb_PyInitializer::set_opt (const char *opt_name, bool value) +{ + if (PyInitConfig_SetInt (m_config, opt_name, value) < 0) + handle_error (); +} + +void +gdb_PyInitializer::set_opt (const char *opt_name, const char *value) +{ + if (PyInitConfig_SetStr (m_config, opt_name, value) < 0) + handle_error (); +} + +void +gdb_PyInitializer::initialize () +{ + if (!m_py_initialized && Py_InitializeFromInitConfig (m_config) < 0) + handle_error (); + m_py_initialized = true; +} + +} /* namespace anonymous */ + +#endif /* PY_VERSION_HEX >= 0x030e0000 */ + /* Implement 'show python ignore-environment'. */ static void @@ -2543,7 +2631,8 @@ py_initialize () Py_IgnoreEnvironmentFlag = python_ignore_environment_at_python_initialization ? 1 : 0; return py_initialize_catch_abort (); -#else + +#elif PY_VERSION_HEX < 0x030e0000 PyConfig config; PyConfig_InitPythonConfig (&config); @@ -2579,6 +2668,37 @@ py_initialize () py_isinitialized = true; return true; + +#else + try + { + gdb_PyInitializer py_config; + + py_config.set_opt ("program_name", progname.get ()); + py_config.set_opt ("write_bytecode", + !python_dont_write_bytecode_at_python_initialization); + py_config.set_opt ("isolated", false); + py_config.set_opt ("configure_locale", true); + py_config.set_opt ("pathconfig_warnings", true); + py_config.set_opt ("parse_argv", true); + py_config.set_opt ("safe_path", false); + py_config.set_opt ("configure_c_stdio", true); + py_config.set_opt ("stdio_encoding", "utf-8"); + py_config.set_opt ("stdio_errors", "strict"); + py_config.set_opt ("install_signal_handlers", true); + py_config.set_opt ("use_environment", + !python_ignore_environment_at_python_initialization); + py_config.set_opt ("user_site_directory", true); + + py_config.initialize (); + py_isinitialized = true; + } + catch (const gdb_exception_error &exc) + { + exception_print (gdb_stderr, exc); + py_isinitialized = false; + } + return py_isinitialized; #endif } -- 2.54.0