From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id KXwRE2aF12muzg4AWB0awg (envelope-from ) for ; Thu, 09 Apr 2026 06:54:30 -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=DjObaUvo; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=DjObaUvo; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 47C811E0B1; Thu, 09 Apr 2026 06:54:30 -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_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 015FD1E0B1 for ; Thu, 09 Apr 2026 06:54:29 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 78AC74BA2E2D for ; Thu, 9 Apr 2026 10:54:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78AC74BA2E2D 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=DjObaUvo; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=DjObaUvo Received: from AM0PR02CU008.outbound.protection.outlook.com (mail-westeuropeazon11013055.outbound.protection.outlook.com [52.101.72.55]) by sourceware.org (Postfix) with ESMTPS id 1469D4BA2E0D for ; Thu, 9 Apr 2026 10:53:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1469D4BA2E0D 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 1469D4BA2E0D Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=52.101.72.55 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1775732029; cv=pass; b=Wvo4bLqJV8oSUbSLBPtJPySPE2B/vRtLGbx7AZqeeUDgYpEVY+RH5U9TqI1truTGqZ7ztgOjUxC0VwwL0glcPgYUyx6pb4FQrD3JqsNtocwE+EOBB1dxJvPaTCNfBNdDrBnuh9lmVqGPBtQUtsqM21I38Jq3Z/kEft/PFjN42mY= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1775732029; c=relaxed/simple; bh=dQp2xI/Xs8mb9c7BCxMiH0jqXcjPJJSFlEhB3eml73s=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=VN52AF38mT+zsWe9MrGvV4hyBMa4LoHrYZ9TqGOUB1TRqyTAU+m5RTcm1Z/mSd/Tn4PJ5z96sj+DicDUXwqLdHFs2eWqSKvc6pD6c0S1tStX2ISxMnJDMXwXil3ZGDAjEmh3d5MsOoqMQqEWjdfs6ZC2rR1mSUbg6Nk16VTU5Y4= ARC-Authentication-Results: i=3; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1469D4BA2E0D ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=ZOSA3fs79lTtuCFHjXbxJTs+rN1DYAaVnEUofx+CveafQvRYHyXJ10dLq6Zq8AVrIkQQznEcBA6F3nlTs7ETKy+mzOMZBbNrM/BcfpKsYiV6iry2BXqyXk0yQRY53wy3OTyZ8yxQLaqQ97NiJ4RJN+L0FdC7tWlpZol1s2dGaLLXUyy0g12eduYNe1tey63dy4K34YxOTI89TXJ+GCbdVWx3+UbrBGnGiF+0tf9CmuzLl2nWG9yWF3cw9ZncB3zu1+9YgBLyENKxs6ykGXbSM6rhUObxeZXgdCtIcY5TAH+UKcje2XNHAX1LbLc4CzlVJM2X+SuOlSfd/G9nUZaXKQ== 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=R9ahpKEqI26hBko6w4nTzmAHtAo95+mDtbRVZkUQ3NU=; b=LyzjvltPBBKNCOc08U8BfexZblQo+T0IbXcAdmrTeFVJL0InzsYXZj1ORbe7s4BiqehxWk0YPXWKuUpgcRWXh9lIcKg3DgkzLp6GsYzEjGy2ZD+MDb+zjht+TSXNgwS2dPpfS6Zv3DHy/c9up4dETJS6LcjNIBvg5rp5rTeSYQXM876gSyVMLU56CdNft/zGW+PU6ucWXNrSpisUkPG1VKgmv/8rWVivFfavrXW8T3MNcb9/GStJQgLuWwr5rEXSFlXTyDSt0die1BmUS8F6JAaCAg8xWN2a3e7WqE2IWfAUoYYZH0TfA32TMRXfsWjv+6cbdbmcw/eHhUJQg1znaQ== 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=R9ahpKEqI26hBko6w4nTzmAHtAo95+mDtbRVZkUQ3NU=; b=DjObaUvotUxs3t7eosEiWILR8wLrumqaputW5zEWU6HsaY4i+fnQQcTIberAgvkPvqakwkfB4mdp9+Bbe5WrwqB7Dl+7vHh91hV3/Vr1gn5s1w67YmKUdLr5ITMIrsGEcgCbv27U51koXaYwU3i4LuT99Sip2GqRipz3+A40pG4= Received: from CWLP265CA0407.GBRP265.PROD.OUTLOOK.COM (2603:10a6:400:1b6::20) by DBBPR08MB10674.eurprd08.prod.outlook.com (2603:10a6:10:53d::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.17; Thu, 9 Apr 2026 10:53:39 +0000 Received: from AMS1EPF00000091.eurprd05.prod.outlook.com (2603:10a6:400:1b6:cafe::8c) by CWLP265CA0407.outlook.office365.com (2603:10a6:400:1b6::20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.37 via Frontend Transport; Thu, 9 Apr 2026 10:53:38 +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 AMS1EPF00000091.mail.protection.outlook.com (10.167.242.88) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.17 via Frontend Transport; Thu, 9 Apr 2026 10:53:38 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=l0URvfCZihiS6SDkZu07AcIhsOC5hAiC6HxFHU2pLMqeZ918eV5Fn2ypx55m5IEWdCPM/vjfdP+m1myfMckxJbtxMIUyzUY7ZNnrUVtpf1K9YtZUyhtHKzQhFlxyC3HaDTjvvenvlokSbcqZi7J2iFNFgiJbSHggwM81Br2SeTwKcdOc7YhIZNCuDrgP0mktxnEyBDichYQf03qzKJn9Ro51Dbx/pLi1gtJOt70k6UeQ+H8sMt7p7q+mlfY4SOa67K0sUifo/oF307FIBm74ngbKn5cY2zlE2nAkOsXudF0AVfXNdkalpaT4mEkKQ2APvFbP+1JA3KvaUp5zhliigg== 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=R9ahpKEqI26hBko6w4nTzmAHtAo95+mDtbRVZkUQ3NU=; b=yYg/gYxPY8HByXOZMJ2XvgFilBgqb1IxVi9gRiDTGvnJVD6Motb3OfQDtySdSaix/m/HfBzfmAg6PCkyw0pDntqAclBy87nUQuV67fy08/TvO7WVFSE/ZzUsHAxcYrgTZ28vVSTBUJMtFYR2B8XaBEdQ+j3wjDBRQlSjzGzFitcSPZlloxT3QxJeoBj8wux5V3hmf2lmIGIgr3SdiruJ14IgmdW3iFA7pUJsRC0fThF1trPn8XhxPNlzuAtKvHcHcJrwFXrHLSKpy2vWSed6sEG/l7M3Fim8KfaKGIkywC0VlcuKSigtw1RSt+mfT7TLQ7k3X5YuuZjanyF+/+6Oxw== 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=R9ahpKEqI26hBko6w4nTzmAHtAo95+mDtbRVZkUQ3NU=; b=DjObaUvotUxs3t7eosEiWILR8wLrumqaputW5zEWU6HsaY4i+fnQQcTIberAgvkPvqakwkfB4mdp9+Bbe5WrwqB7Dl+7vHh91hV3/Vr1gn5s1w67YmKUdLr5ITMIrsGEcgCbv27U51koXaYwU3i4LuT99Sip2GqRipz3+A40pG4= Received: from DU7P190CA0002.EURP190.PROD.OUTLOOK.COM (2603:10a6:10:550::30) by GVXPR08MB10587.eurprd08.prod.outlook.com (2603:10a6:150:15c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.18; Thu, 9 Apr 2026 10:52:33 +0000 Received: from DB1PEPF000509FA.eurprd03.prod.outlook.com (2603:10a6:10:550:cafe::ce) by DU7P190CA0002.outlook.office365.com (2603:10a6:10:550::30) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9769.40 via Frontend Transport; Thu, 9 Apr 2026 10:52:31 +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 DB1PEPF000509FA.mail.protection.outlook.com (10.167.242.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9769.17 via Frontend Transport; Thu, 9 Apr 2026 10:52:31 +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; Thu, 9 Apr 2026 10:52:29 +0000 Received: from PF4S4363.arm.com (10.1.34.63) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Thu, 9 Apr 2026 10:52:29 +0000 From: Matthieu Longo To: , Tom Tromey CC: Matthieu Longo Subject: [PATCH v1 3/4] gdb/python: migrate Python initialization to use the new config API (PEP 741) Date: Thu, 9 Apr 2026 11:51:54 +0100 Message-ID: <20260409105155.1416274-4-matthieu.longo@arm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260409105155.1416274-1-matthieu.longo@arm.com> References: <20260409105155.1416274-1-matthieu.longo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DB1PEPF000509FA:EE_|GVXPR08MB10587:EE_|AMS1EPF00000091:EE_|DBBPR08MB10674:EE_ X-MS-Office365-Filtering-Correlation-Id: a0a42f81-e1eb-4ef0-e8a4-08de96264180 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|1800799024|376014|36860700016|82310400026|13003099007|18002099003|22082099003|56012099003; X-Microsoft-Antispam-Message-Info-Original: saM9O/aMCJUAM87Pn8y/pvMF4Omz18sR8PtenL8Cn4NrIQZO/hEkNIkj6aEiEhOt/+w+JzGiJ6UKSXtOmneJ3S5yRg478XUyuk1aS/t+WUsdL4mhj8mqQrNG+1fg3SOhjh5rmKdVwSf0JYD3YSahMEt0i0iQLHS0FafDvAbnEkSToxVuAjFbwEJy94dFDBioe400ETqDRasFSl7KPpeQaJpgi4EnWH22c9Jm1QkhzdY4aK6v2fX5DJikgrtqxYUQWmEoM4ibkXHGSMqsYwS4twh9ON7qLyWfK4JBGHMv64ar4mowpv/27Ly9eoP+Vepn1B7BhZ1hBtd9cVOu06PyZIOxyfgirFBXahwScANpKDlkMi1y1PxJ94BwpSKEXGbFVM/xeiiDetECqDfGL4/JiK5V+gxY8RmGs5saSY9uUZGm8e9/Y4vqCz3QS2jfonrmPqeUs1x+Us6aTdZOvdWMD88BaAft13wz1478+NVuE+HWEXQh03Z4SwGfZ5H9V0TxWcLEL29ulF2Xekc5ID0MRnTKTLXggLnBK2PjsxWeXiCQZPXDQ+0TGKk7tf+PrEin7iz5lQUDHqd+Vl+ef16NkoRg8yNxlHX+/U3n1mUBsmaTnWpE3VODu2X8q3qnkFrFS1THgfelaW+3KOlKevlKa1PHjr3Eq2GrwAjI8ajDJrMfuhLxSJ6KA6lvaTEQcya6ZTccCb9vv7rjFSsE8GAHSxQV1o/WBbKf0fDb1DM99SXPYSN0hiTZks/fdsdf1zSMwO7ChBCHexsNUNDyZ4CzUA== 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)(1800799024)(376014)(36860700016)(82310400026)(13003099007)(18002099003)(22082099003)(56012099003); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: cKGiqaskYQvMRhrglghrNgCq51PNf/NiovdeFFaczU3HYMnX1G214raeIivu7Z8Jo7nZoWcrgOi6QZtNOGJX3r5C+NTSe2xnRcbnMUubppsAL6ji9n/XLKpWeBKLVUcUv1VNLxw8uZ1auvGtgyJYlcnC/YROLKWbgE2xt883upRSecbitf5g7MZlyxQjaGIdjEiY5zLhC+z2qaNON5UzfBz5UoD7Lpk9Y6N7BGpPyb5vmI6EsMWGnWIeyqbiBY5+/0SPxem+xnLhI/9bb5yfBkIwJ4saJ7tF0hL7Y23TUGRp1aiGzaCsGzsPt7H+efRc0AXANwO6MjQflCd/uBYMJA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB10587 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AMS1EPF00000091.eurprd05.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: afb5a2d5-345d-4469-bf52-08de9626198a X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|14060799003|376014|35042699022|82310400026|1800799024|22082099003|13003099007|18002099003|56012099003; X-Microsoft-Antispam-Message-Info: uxaEVBxNIDxxWUSHBXWZd367snFqChZEWKTodEb/FY8+UuXBUqsr5R/aZjOHqGyCuR64tQsxzTnGpi640l++BRY20TifIIZaT1Z6gKC62hHjTIbeRFTuIYBgKno+l7U9Qhb1p6an2smFqwBVEQ4Qj5zC5vMz4DbdO2huPzEYmjxOD+V4VySZ8QRv+0s4hrawsRLa4lV9zMvvYmwS+FnUUN4i8ccgHN2/9b7aeTaDvr6IvodMSjgsv6/8647ZHMw5j48U9ov9qpFp5V+TjMIYZWWBegZkbq4EkVXlSNxTPPjIRXkAqmqvbnKgqvDzpnB1okNNJjGIyeAF7o7KjR16PjfXhdszSdZ3WADqCKi796lfjp1doLBBLboigiSyRHqwNBLYmzU4BThPEk6H7oWLrxlw6dnIZvadcTdRk6n1qVKhal+5O8rvMD84Vis7n4gmUTbrG1mBrb2kxIrFakavBo5MpdKe6uMocSSJm6o7egIlhqETj6s1Or8lQ5HoHMA4/L9rlzJQw5Uezb79UZ3ZF9hEPK6YSzsO+UTxYccaylb7ap9icuPc7wDw0Wpu+ZkBSvHNMNtRGWTyP48jk4eOZn2xAHbb4Ywp/bJ2rn7ZXmz79kcEIfUAMpWAmSzYKDlfTuGUAKBDBXLuqt/MideZvPHvyPyrPXC+YSDAXu5s9glWnJsBFGEDtAtQ/bkrfXLqaPdyXKuIbnfk8j2layAdCYT68XfcTF6VXc7GFMeIRBt/Sbe/1twBEaEgxdJY+N2/0/PBGM7ndaWp90HZNb42dg== 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)(36860700016)(14060799003)(376014)(35042699022)(82310400026)(1800799024)(22082099003)(13003099007)(18002099003)(56012099003); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 1lrM8J0ZoMcbQWNMZ7ZougqXeJgUOBBAmpJVt6597Q6ALRnG5YtkiLOgq8ozCX+kxap5Fh/XOG5V8/OCqGi/jIPttpET/3GUY7VBSTg86TuYqnHMI8gonOnmonetEQW2hnT2c7YzGEqTScMW20QBomLw7czXDa220b9AOVBr3aoG397SP8b1F/knLo4Jc3DRB1g9St1+HVKVQTUlCMrbBb6hUPE050+IB/yWAnsxr9GT2X/Ck6F4VVfgiSOtEK/LrUJ/F2MwI9pyLnANTDP+Ws9b2rJeaxR5g6Lg37FmHfFU1HiRkh/mVglZI+QNAy6A8AkMW24TmGeQvwzF6OYtd2jvUX0K7OzQc8pBNF5CA9gmIMvajCxj28l1v9gQjdNiYTcAnzAY3KUzM5vFcWF2xtjZ+ZgTaRK9jq8QnkCkWxmqEPfp7lnLVmJLiAf2DvVb X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Apr 2026 10:53:38.4619 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a0a42f81-e1eb-4ef0-e8a4-08de96264180 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: AMS1EPF00000091.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR08MB10674 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 | 128 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 127 insertions(+), 1 deletion(-) diff --git a/gdb/python/python.c b/gdb/python/python.c index 85bd88cd243..1a0ff29d1d4 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -2216,6 +2216,100 @@ 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; + bool m_py_initialized; +}; + +gdb_PyInitializer::gdb_PyInitializer () + : m_config (PyInitConfig_Create ()), + m_err (false), + m_py_initialized (false) +{ + if (m_config == nullptr) + { + throw_error (GENERIC_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) + throw_error (GENERIC_ERROR, + _("Python initialization failed: %s"), + err_msg); + + int exit_code; + gdb_assert (PyInitConfig_GetExitCode (m_config, &exit_code) != 0); + throw_error (GENERIC_ERROR, + _("Python initialization failed with exit status: %d"), + exit_code); +} + +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 @@ -2549,7 +2643,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); @@ -2585,6 +2680,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) + { + gdb_printf ("%s\n", exc.what ()); + py_isinitialized = false; + } + return py_isinitialized; #endif } -- 2.53.0