From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id GRGvIwAUq2m1MBkAWB0awg (envelope-from ) for ; Fri, 06 Mar 2026 12:50:56 -0500 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=BhlngslZ; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=BhlngslZ; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 64FF41E089; Fri, 06 Mar 2026 12:50:56 -0500 (EST) 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 5F0BB1E089 for ; Fri, 06 Mar 2026 12:50:54 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 9FABC4BA23F2 for ; Fri, 6 Mar 2026 17:50:53 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9FABC4BA23F2 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=BhlngslZ; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=BhlngslZ Received: from GVXPR05CU001.outbound.protection.outlook.com (mail-swedencentralazon11013069.outbound.protection.outlook.com [52.101.83.69]) by sourceware.org (Postfix) with ESMTPS id 632EC4BA23E1 for ; Fri, 6 Mar 2026 17:50:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 632EC4BA23E1 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 632EC4BA23E1 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=52.101.83.69 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1772819422; cv=pass; b=gKMvjf93ZwJc77CNil3dXNvQihwDpIzlqxP620xuKy4WprG4r6p/QR5BNDN7xmA2exZKCvvShbkVlMCMFScklJh2+yhub5Q55HJzi0TqVu8WCR6czy6OBZsZBMS5K71ycgdpAYUv5nQviuju4VrgEW3dMk1zl1SCQWx0LB/6P/s= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1772819422; c=relaxed/simple; bh=fjVv+/IndgdvUFZcRIJBwRjo1I788TNX9PfPxt4v7Co=; h=DKIM-Signature:DKIM-Signature:Message-ID:Date:Subject:To:From: MIME-Version; b=mAlonNNcChcl2PR56cDdocvCLDSRzYEjgPoGitRFBBFSRsZ6gB3t4ROg/FjEgRK0PBCYDOnUFPO7O0Bc6nr1s+lblYCaEgsr29RNnuUsXRoOOgDjiNK/NEc7jkWlNQvEDruQhSbBUTKK8Onq4V1PpaB7NM02K2LJvrja97JAP0Y= ARC-Authentication-Results: i=3; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 632EC4BA23E1 ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=xpckDmZ7CKjANnIPXhd0ozkJTglmZHKL5OhYQATqyo740KbG7BY11rinR0ib4/aNv2T4wFMUYdUXOA2575Hcq6tajTMh/l0bXGGHBVqTktdEK8vCOKtE1JF6YuLqxObL1fGc6MVkK48nK1LAau+hMqZec/91bEG3jy607zhxyipKRRCRWh3dv9L4K9W0COfWOajbNDxVEKpYp2zNVNBuAJYZzs5OPgH+9P7qm5QwysKXT/7eyBGgClGbyv/297uCbD1SjChQkNM5awkVak3a31NFMwZB5MreyIA/aMY7pF7HSXG7p1Me6LZAmqaBv98LU8vaTLfcmXxA9lnFrbo5ug== 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=2y/VI/vRbVQw9PauFj+e/Cc70+4MJM6fNdzo34zoicQ=; b=pisbs6toEEpha1O9z4Zo0yqOqiM0Xkyz746DVsQQ7lcNgnoORSTC7FZj2f7YHd96hGWiggGYQ/1bSJssiECT0mV0S57OosDA0SyyuUZmkf+zH7M/d23ikVDhKIJbl2PJgLh7ShEGqo4X9PkI2l1isE+Ba/d+DRRvrISTlbiStoH0pnetqFu/bxOqaEIaTLc3uUNwmLeubrcDMMe4zwsOE5Hhf/TRfJudVMU0BFmn6fFCnpRFNlKLVPZeYN+/CDW4L6GNiKUsQJmOUDMz8AMNBT6XK78dChReHkxmmS5iwqUX1/7gRN91P72SnX/OospVXfBxv6QmB4iQZ25UXytSYQ== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=tromey.com 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] dkim=[1,1,header.d=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=2y/VI/vRbVQw9PauFj+e/Cc70+4MJM6fNdzo34zoicQ=; b=BhlngslZuqYTV+NQ5IO9bf7UPWrMgSuDm/7zDbfen2wbFUXsJm+NY2DYcWfp5x9H2UTwzayIbIVTW2YnGrBrk4qnpRTdk2viWoTOe5EeI7hqFKkKcddwP1NKTi/cX2EKYIzReJ6oKl3TSN8kAcitlmEsnGA/7pQh8Rdpt/8ZONQ= Received: from PA7P264CA0108.FRAP264.PROD.OUTLOOK.COM (2603:10a6:102:34c::8) by VI0PR08MB10827.eurprd08.prod.outlook.com (2603:10a6:800:203::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9654.22; Fri, 6 Mar 2026 17:50:14 +0000 Received: from AM4PEPF00025F9B.EURPRD83.prod.outlook.com (2603:10a6:102:34c:cafe::60) by PA7P264CA0108.outlook.office365.com (2603:10a6:102:34c::8) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9678.19 via Frontend Transport; Fri, 6 Mar 2026 17:50:14 +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 AM4PEPF00025F9B.mail.protection.outlook.com (10.167.16.10) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9700.0 via Frontend Transport; Fri, 6 Mar 2026 17:50:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=J9N1Y56FHR8yKkB3M19pzdP7sCEvM38SR6IIMohuvgOnlUl4dgybCVld//ncSAt09tZ595fT2BCZapar78KSrfjK/9O49PKGwtEiyKX69M7OVWeS3wSD59H+7TRxCs436a1x0mg06qeqJ8tg0IAQQmi30sNccU0v5i5MRV1I5abPdHvj7jnjbwHiYf4cpXTBIGFcIaeip6u1raM966AkjgelwrTBQ1b2mqzGs+0Fcg7ayRlwEXL+n+5L8Y9QoYlXwpGCpCIClcU2cvyFCRKCSGpsngZ3PX/fq7KqApAZVrt6bmeUNf/EieXQlSGRwOxoN/ZdR2IeD2oPpLcSMUt/Sg== 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=2y/VI/vRbVQw9PauFj+e/Cc70+4MJM6fNdzo34zoicQ=; b=Rh6bE5+qsS5QOqi4Ra3mS4c86AXmvVpA+TeWgwP94X1W7gRMkKjBaRXM6BQpwxxQSIk4JEYJF2hKD4xO80wDB/483diVI+USTteZxToOTCNvoA1vXcIEXzcW/xreP7k+zAcl/36pm/ZTkMELb34Kd866q6Vt6tEpOjvdKtT1KAWsy8EcCT/pibLZHCuTzH9nLP+JH4lV2ZP3I0sU87chcarsJOIiD1njrPsLcTvvpL9uEWc6t5BLzLBzJv9Et3B7kULXXwjvvxIW/RrZ8b91spT+tB7c7mx2OXDBSQmqreTKhVUj2XY8x/es7pdqbOaduhtEGJwzn1aG+4puJdrFoQ== 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=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2y/VI/vRbVQw9PauFj+e/Cc70+4MJM6fNdzo34zoicQ=; b=BhlngslZuqYTV+NQ5IO9bf7UPWrMgSuDm/7zDbfen2wbFUXsJm+NY2DYcWfp5x9H2UTwzayIbIVTW2YnGrBrk4qnpRTdk2viWoTOe5EeI7hqFKkKcddwP1NKTi/cX2EKYIzReJ6oKl3TSN8kAcitlmEsnGA/7pQh8Rdpt/8ZONQ= Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; Received: from DB3PR08MB9010.eurprd08.prod.outlook.com (2603:10a6:10:42b::8) by DB3PR08MB8940.eurprd08.prod.outlook.com (2603:10a6:10:431::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9678.17; Fri, 6 Mar 2026 17:49:11 +0000 Received: from DB3PR08MB9010.eurprd08.prod.outlook.com ([fe80::f37c:c9c2:6d9a:9543]) by DB3PR08MB9010.eurprd08.prod.outlook.com ([fe80::f37c:c9c2:6d9a:9543%5]) with mapi id 15.20.9678.017; Fri, 6 Mar 2026 17:49:11 +0000 Message-ID: <40f9c944-66e7-4a6d-8b86-80c7796feb6b@arm.com> Date: Fri, 6 Mar 2026 17:49:09 +0000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 4/9] gdb: add new helpers for retrieving a type's fully qualified name To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20260303161659.397427-1-matthieu.longo@arm.com> <20260303161659.397427-5-matthieu.longo@arm.com> <877brsrb7o.fsf@tromey.com> Content-Language: en-US From: Matthieu Longo In-Reply-To: <877brsrb7o.fsf@tromey.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P123CA0104.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:191::19) To DB3PR08MB9010.eurprd08.prod.outlook.com (2603:10a6:10:42b::8) MIME-Version: 1.0 X-MS-TrafficTypeDiagnostic: DB3PR08MB9010:EE_|DB3PR08MB8940:EE_|AM4PEPF00025F9B:EE_|VI0PR08MB10827:EE_ X-MS-Office365-Filtering-Correlation-Id: e53c8304-68f3-406b-31eb-08de7ba8d233 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|366016; X-Microsoft-Antispam-Message-Info-Original: SUZ0zhz/Z/ryOHcq8LO1zg9bJuI/BLzVGvXajS9wX+AED1GL60AtrYALibVHNKb9TqVeN8N47JRnJqlxOUO0oQ3gaQiJoCvDe8/f3RGBYt9BeryzPUgjuO4Us8lY1TWZ6aArpu5efTzfNkwY1QOL3R4IW87toPZmjP55Fa29U7cfEbG5mgxKjiA1QUDU+JF/zGFxx2bqxN/hWN3iKYM8hYn2k/rjualPFVsPOxDJJODABCSuq+OlGtgcPmkTnXlGpeSDVSHsShpNRuu6Km/1OtdxgnX8ZQ4eYjOnDzCeUgP4lK4RQ/UwWjh1jZFs8ERPn+ghYHCWZ07twQEhdOmkA5fS9rlxRRKC2BaAhEduj5lp+VL2btGw/ncUYnTM7NxhF+fdr0fq+qpoSJCKWyFsQU2UxOVI/PsHbI1827swFX+8VtrmOoCijhxjhesIW0VAmg63LoYCavORARPY4nzIwPKsQ5++ZY82kGOSAXatY0KKpRDKOmnV5mMxsOaIRSBxEn0CiVxWGK+piOrdhSi8rkwh+Ki/3JWsDoAccFY4KVSsyw+M1QnD4RYH/oYT5Au+yvVdeJPhQ1i0yuusRXCPwYLOlbTbnYM9GosDqAFsz3wjsSJy9jLO95SqYxmXokY7Ate/4kFPrySmKKQkRmzTEBPihTRHZaEG0L7qmRl5SdW8vu/bUXLYpiCgWmDlO6b9y5hxu9DVm3tAX8zOTkZ9CAe8K0oa0jOeKS0EhRbOVwc= X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB3PR08MB9010.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(376014)(1800799024)(366016); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB3PR08MB8940 X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM4PEPF00025F9B.EURPRD83.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5b750054-790f-4842-1c5d-08de7ba8ac83 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|376014|35042699022|14060799003|36860700016|1800799024; X-Microsoft-Antispam-Message-Info: FOM2CZiI3dhxEuViphZYtbIpiohlq5UroEdHiumU6WsFKZqWu7dBL0l6pawXttxOddMmkzuqBbghpQ6cDm8D0qpdjUEw+LCRLXhZ7WgR0zJLOAXyMN57RMJJJ/Lt4Vx1PaKbgVC64JW+ReMbsvACyBdtUd3+ayZnHZub0i29ayb78UMf3F+aO7AxrvYvxXZAVCV8Za5hK58KEGd9dncJDZtTRwmYMPw3xyiDX0PmB5h6smchslNu4N+ql+HO4OjoTp139P6wPKdcaVGB15yV19aNtyvLFhuUMhiz3ZTScWbEeFeuexTruEGrJR4S2/8pNCm6gm7i2gKj1HKBdsUxE8BstHnvIk6wlNDPBM0nLrYh8ZEI+RvkYzGmcudW7WaTryrpMdNIBh2eRqLe+bI6XGyXCT8U8gl3FY4t4+fJgU5kKUStGEuKIyiZa+ThIUtTFzqnZUyzM4AEaKr1KJ6/npZtcaUjVure4Df7aa1jFtd4MSLLjWId7Pf4tR+hmarnX4D/+tzx/m6BMZ8PZfKC8bFuZi9aju2U+Uu2NfZDs+13e3exxJmsnIp4GIHNR+PPqNqxT1nWHmG2Qj4gYEzzwqrG+1JCwWIpItbvos5m5ac2Plp6WexPlKmA0gaN1eg8lFT1R7cOFWvGi2Mz32F7Wkfb/CWZQS85Jpe4o5ihMaPWT+prEHHv/agXaHUHdzctGUPhv25WXNG9lWxNMAQPU4smWIBEPPOoOr7trHHnVWKrXFZZlvPhAX2lwEQXHovf8Yy3r+Yc5qFt1iwMEJVKHg== 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)(82310400026)(376014)(35042699022)(14060799003)(36860700016)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: owfTfpTnm/f7qIdK7Ut7n802vIyVHzudBBUEH7SfAukTwcGRp//Ze8YpwAULrLOkSn226a6LzamtAzVLiBxOMwWb3CC1dMeXv/kKKJBMAgZtdvbQ4qD8IcsoRoYfXh7SaT0pYgjpfeup0/YsPXJITMcY+I9HgJeu9ucFL7VuthLRNh6+nHhz3iuaXRNXwGEItxu2Ya8QYihGWEXoFgEx/GAWcwJ7v0SgCjDJK7/RwTTF7TllVkEVDluY7PBEkdE1WQwQtayWBBPyWibd8DgcD8kINLjiq88hJX2Af+Iz/Mgcx+RrTdu/UAAPC6jio5RKN7Z6JVDs3qr4MN58W7v2AexYwuZhvnCHMFphFlnvVKUG3dtWOfn9LH8tCCvpKDICVf4sAHqLXuniZusMXrGgSMfGG8vNSMLjloC8Ft/AAzcahXoLS/R0N9eB4//m7U5b X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Mar 2026 17:50:14.3967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e53c8304-68f3-406b-31eb-08de7ba8d233 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: AM4PEPF00025F9B.EURPRD83.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR08MB10827 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 On 03/03/2026 18:59, Tom Tromey wrote: >>>>>> Matthieu Longo writes: > >> +/* Return the type's fully qualified name from a PyTypeObject. */ >> +const char * >> +gdb_py_tp_name (PyTypeObject *py_type) noexcept >> +{ >> +#if PY_VERSION_HEX >= 0x030d0000 > ... >> +#elif ! defined (Py_LIMITED_API) > ... >> +#else >> + #error "The version of Python you are using does not expose " \ >> + "PyType_GetFullyQualifiedName() as a part of the limited C API." >> +#endif > > I think this case can't actually be hit... can it? > It currently can when you build GDB with python 3.11 for instance with --enable-py-limited-api=yes. Unfortunately, I haven't added the logic to error when someone requests to build GDB against the limited API, but does not have a suitable version of Python. This #error were a workaround to provide a meaningful message to the developer in this case. > My reasoning is that the very first case is taken if either the limited > API is in use (which requires 0x030e0000 as of this patch) or if Python > is new enough. > > So, all other cases fall into the non-limited case. > > It would be better IMO to remove it if it cannot ever happen. > I agree with you, all other cases should fall into the non-limited case. To do so, it requires me to fix the configure script to detect the issue before the build (see below). >> +#else >> + #error "The version of Python you are using does not expose Py_TYPE() "\ >> + "as a part of the limited C API." > > I'd prefer that #error not be indented here. > Removed in the patch below. >> +++ b/gdb/python/py-obj-type.h >> @@ -0,0 +1,31 @@ >> +/* Helpers related to Python object type >> + >> +/* Return the type's fully qualified name from a PyTypeObject. */ >> +extern const char * >> +gdb_py_tp_name (PyTypeObject *py_type) noexcept; >> + >> +/* Return the type's fully qualified name from a PyObject. */ >> +extern const char * >> +gdbpy_py_obj_tp_name (PyObject *self) noexcept; > > Declarations in gdb don't have a newline after the return type. > Fixed in the next revision. > thanks, > Tom Here is the fix to remove #error macros, and detect the issue at configure time. I will split the configure fix from the removal of the #error macros in the next revision. Matthieu diff --git a/gdb/configure.ac b/gdb/configure.ac index a3343dec118..b7ae2f3bb3c 100644 --- a/gdb/configure.ac +++ b/gdb/configure.ac @@ -933,6 +933,7 @@ else # do except assume that the compiler will be able to find those files. python_includes= python_libs= + python_prefix= have_python_config=no fi @@ -1062,6 +1063,13 @@ AC_SUBST(PYTHON_CPPFLAGS) AC_SUBST(PYTHON_LIBS) AM_CONDITIONAL(HAVE_PYTHON, test "${have_libpython}" != no) +dnl Use --enable-py-limited-api to enable the build of GDB against the Python +dnl limited API. +dnl +dnl no - Disable the Python limited API. +dnl yes - Use the Python limited API to build GDB, error if the selected +dnl version of Python is not compatible with the Python limited API. + # Check whether to build GDB against Python limited C API. AC_ARG_ENABLE([py-limited-api], [AS_HELP_STRING([--enable-py-limited-api], @@ -1072,10 +1080,14 @@ AC_ARG_ENABLE([py-limited-api], if test "$enable_py_limited_api" = yes; then # The minimal Python limited API version is currently set to 3.14 for the # support of Py_TYPE(). - # The choice of the minimal version for the Python limited API won't be frozen - # until the end of the migration. - AC_DEFINE(Py_LIMITED_API, 0x030e0000, - [Define if GDB should be built against the Python limited C API.]) + # The choice of the minimal version for the Python limited API won't be + # frozen until the end of the migration. + AM_PYTHON_CHECK_VERSION([$python_prog], [3.14], [ + AC_DEFINE(Py_LIMITED_API, 0x030e0000, + [Define if GDB should be built against the Python limited C API.]) + ],[ + AC_MSG_ERROR([Python limited API support requires at least Python version 3.14]) + ]) fi # -------------------- # diff --git a/gdb/python/py-obj-type.c b/gdb/python/py-obj-type.c index 034ebd26b8d..ea0b59a8447 100644 --- a/gdb/python/py-obj-type.c +++ b/gdb/python/py-obj-type.c @@ -33,7 +33,7 @@ gdb_py_tp_name (PyTypeObject *py_type) noexcept return PyUnicode_AsUTF8AndSize (fully_qualified_name, nullptr); -#elif ! defined (Py_LIMITED_API) +#else /* PY_VERSION_HEX < 0x030d0000 && ! defined (Py_LIMITED_API) */ /* For non-heap types, the fully qualified name corresponds to tp_name. */ if (! (PyType_GetFlags (py_type) & Py_TPFLAGS_HEAPTYPE)) return py_type->tp_name; @@ -62,10 +62,6 @@ gdb_py_tp_name (PyTypeObject *py_type) noexcept return PyUnicode_AsUTF8AndSize (ht->ht_qualname, nullptr); # endif - -#else - #error "The version of Python you are using does not expose " \ - "PyType_GetFullyQualifiedName() as a part of the limited C API." #endif } @@ -74,11 +70,5 @@ const char * gdbpy_py_obj_tp_name (PyObject *self) noexcept { /* Note: Py_TYPE () is part of the stable ABI since version 3.14. */ -#if ! defined (Py_LIMITED_API) \ - || Py_LIMITED_API >= 0x030e0000 return gdb_py_tp_name (Py_TYPE (self)); -#else - #error "The version of Python you are using does not expose Py_TYPE() "\ - "as a part of the limited C API." -#endif }