From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 0XUpBHUKp2m9pBIAWB0awg (envelope-from ) for ; Tue, 03 Mar 2026 11:21:09 -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=MTEX55cl; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=MTEX55cl; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 0AEFE1E089; Tue, 03 Mar 2026 11:21:09 -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 A7BB61E089 for ; Tue, 03 Mar 2026 11:21:07 -0500 (EST) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 6ACEF4BA23CE for ; Tue, 3 Mar 2026 16:21:06 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6ACEF4BA23CE 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=MTEX55cl; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=MTEX55cl Received: from GVXPR05CU001.outbound.protection.outlook.com (mail-swedencentralazlp170130007.outbound.protection.outlook.com [IPv6:2a01:111:f403:c202::7]) by sourceware.org (Postfix) with ESMTPS id A0D4B4BA2E0D for ; Tue, 3 Mar 2026 16:19:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A0D4B4BA2E0D 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 A0D4B4BA2E0D Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c202::7 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1772554765; cv=pass; b=vOU/2NPorFCjRQG2M5KzGHvkAlZhOdMflexFrkJI4CnIZJNnEkS4/gt11qZ4MOJjDZftRD5wpk4ZuPNY4qAWyKls0NpvnPkYVlUHvhpaJT7jEPTqBzGye8id+fjPaioiSM4+04IQk4qyseu0u8aTxV+K30E+upNB6gRXe6RqtB8= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1772554765; c=relaxed/simple; bh=7Rm0dY2lZXiM9ghM56aVSNQXbK66EYS5Gfk49KwGugQ=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=AuuZC0M/9ItxrCP6tqxd2yjZ9qFVUZZcZNX6UdhB4F3ZlUHtAnhiUNkjCdXrpaJZORImvA84CGUKUOCdW6M9KpIyuJE9VHI5kE2ztNzi1pnYYV6gjt9E56Jte91QcuCrHc6VU3IJL6Ybig6mo1YErJ3dKS8jgh8hKwoe/Kob6uU= ARC-Authentication-Results: i=3; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A0D4B4BA2E0D ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=o3G8swb2Fkvo7q4j56cOFlIGrbVYgeGDtVykdyotGytcvNCT8WISlbR7QR9eNqitas9rvfJH0KDzAgdya95gdZVIvECmoQo9hJbZ9kk9bNmeHGAGA2P44iESm7rMuYkB3TuYxtGvQzZnX8WpCNieNe8Rz2Ws1XbLB2540/HNQbILR1Y22TYRChR+jnGSN0qLhPi8ihGKvV6j/9kU+/cl4pTzNIe/fuhQM39fL/fBJYOM//AantffbygmOREnYsWNQHN1cNcpeHadwmd9I8XFRaKcXz1qQh7J0tZ1A11E3MXKQHWWHBfFQjDVqB/G+SeBybVOjk1ZDceenoNWh6MStg== 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=hykmQfODpGe0gu8l3QVMBRdo40yLwOWw+yh6QvDVHig=; b=GBlQCGVRRpx0O3U+7N8kYznP0kqC8aSIhWG3VxYNn14uAbiq0271IUSWqL+e4Y8c6m4IGyz0kDCQZf74j0SOCIjXBKLyJOq+1M+VgpcS1kzVusBhUJNrNvVkKmN/nouzxYpNAjh+onrrhN78+p7Ru3duYFQARGxMrY8AxLD1/O9QlisX+YRvlioe2TjKw/McJ2jragA1VeV9xZienrJ7+hn/H5OjWJxTgQFJSoIno5IxpcmSsXaCY3NdnDaGud8LTUvvB9Ewy6MTdMia5gw1/OQirYkSCqnVeeSfzfc7xQJ75r2w3swiAP0t3OrT/JQN2GVQds3TmNDz5k7giXihUQ== 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=hykmQfODpGe0gu8l3QVMBRdo40yLwOWw+yh6QvDVHig=; b=MTEX55cl+aHC5EneLyrXIUZwLZeIKRKveM53Ek6M5TXYQZxFLdyZHT8NyMeY5f2KJRsGJ4wmGwU8KwA3257nBhnSze3Lt0F3upOO1guNH2YFunSGIXcTUper09PJ+oGvGQVloBLN5LYKx3BM6fUJqoR97g4vgRqKgdeayfU1fCU= Received: from AM9P195CA0004.EURP195.PROD.OUTLOOK.COM (2603:10a6:20b:21f::9) by DU0PR08MB9003.eurprd08.prod.outlook.com (2603:10a6:10:471::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9654.22; Tue, 3 Mar 2026 16:19:19 +0000 Received: from AM3PEPF00009B9B.eurprd04.prod.outlook.com (2603:10a6:20b:21f:cafe::81) by AM9P195CA0004.outlook.office365.com (2603:10a6:20b:21f::9) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9654.21 via Frontend Transport; Tue, 3 Mar 2026 16:19:16 +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 AM3PEPF00009B9B.mail.protection.outlook.com (10.167.16.20) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9654.16 via Frontend Transport; Tue, 3 Mar 2026 16:19:17 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=sqr5z9eUpVPB3nTpagd5zHimPTq3rcfyY4LmcbzC4ou250S4v321OrT62gwGSIUURTiGm2V8ay29FgVtaAyqINuknjX9HDrd2hJcSWVgHuMDo4k8+urpO00cIgeuMbpT5uepps/HPeohQDhMgau3cIuuVTK6W0KhNVLowAla+pGbWLH/KolCvI8JiaR6XN5Nf6OFpfT45h7kHI6cNX/y6cL8ZKVdeK17cvkx61FI6gC8v5xhYQqW+NfHoFS/2ZXOFcf61GNigcvNc2GZmtijdC8w8Rleanx3BeZ89NhDm7+7OtF75g8dD0hFu8TukEtk5h78H8Vc6bnRFWL42h9D+Q== 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=hykmQfODpGe0gu8l3QVMBRdo40yLwOWw+yh6QvDVHig=; b=N5Z+l7roEq2+mvJlsTlfVOw3Z7EMOuXfoWxLCJfb+rI91rLAsdJ16O9uBAmFmi9otWw0ltqf4pSJL38o+lNh6PnArykvEYUdtmdTythOFDgmXgT0EDQEViZiaQIQ4vskrmdVZZpX5vbA189Cld/YNnJhXFTnJtkzuN1RvP7iPmEGI1osWgKvb3ZPTRW1c73HSzPYhgaXgX/CustIppaOv02kiP/w1GCBms+8N2pji7kVmTw5Dmo5+jPHP6PEDjQYoUaAhuJsZRiGKZJdNGHeHpoqm6tfYc+nVmRq5I7wzbqVoBvIdksBHm3M/ioD2rWdaBPaxU5RxoPapBQEr+vDDw== 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=hykmQfODpGe0gu8l3QVMBRdo40yLwOWw+yh6QvDVHig=; b=MTEX55cl+aHC5EneLyrXIUZwLZeIKRKveM53Ek6M5TXYQZxFLdyZHT8NyMeY5f2KJRsGJ4wmGwU8KwA3257nBhnSze3Lt0F3upOO1guNH2YFunSGIXcTUper09PJ+oGvGQVloBLN5LYKx3BM6fUJqoR97g4vgRqKgdeayfU1fCU= Received: from AS9PR04CA0035.eurprd04.prod.outlook.com (2603:10a6:20b:46a::18) by VI1PR08MB5453.eurprd08.prod.outlook.com (2603:10a6:803:132::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9654.22; Tue, 3 Mar 2026 16:18:13 +0000 Received: from AM4PEPF00025F98.EURPRD83.prod.outlook.com (2603:10a6:20b:46a:cafe::56) by AS9PR04CA0035.outlook.office365.com (2603:10a6:20b:46a::18) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9654.18 via Frontend Transport; Tue, 3 Mar 2026 16:17:52 +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 AM4PEPF00025F98.mail.protection.outlook.com (10.167.16.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.9700.0 via Frontend Transport; Tue, 3 Mar 2026 16:18:13 +0000 Received: from AZ-NEU-EX04.Arm.com (10.240.25.138) by AZ-NEU-EX04.Arm.com (10.240.25.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 3 Mar 2026 16:18:09 +0000 Received: from PF4S4363.arm.com (10.57.82.243) by mail.arm.com (10.240.25.138) with Microsoft SMTP Server id 15.2.2562.29 via Frontend Transport; Tue, 3 Mar 2026 16:18:08 +0000 From: Matthieu Longo To: , Tom Tromey CC: Matthieu Longo Subject: [PATCH v2 6/9] gdb/python: flatten functions calling PyObject_New and use gdbpy_ref Date: Tue, 3 Mar 2026 16:16:56 +0000 Message-ID: <20260303161659.397427-7-matthieu.longo@arm.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260303161659.397427-1-matthieu.longo@arm.com> References: <20260303161659.397427-1-matthieu.longo@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM4PEPF00025F98:EE_|VI1PR08MB5453:EE_|AM3PEPF00009B9B:EE_|DU0PR08MB9003:EE_ X-MS-Office365-Filtering-Correlation-Id: 8ece69e5-5735-4ba3-8edb-08de79409f14 x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; ARA:13230040|36860700013|1800799024|82310400026|376014; X-Microsoft-Antispam-Message-Info-Original: 7knGDIsHGaPL7B3iPOHuPE3/1a72pdr/RuxvFEqqMu3qCoySlAKxvBEkjanGDs4KJ+0kj2Ofd4fdn8aOhFKOWBDnbojZFSyklBkq8cZyFKevr4NyQRUCUjKmElb7we9i5XSWvYWbyG4Vg/N22P7Q+EoY4mM431v5YJPQMMkaKADkWtEguG6GQfuwcXV6i+NHcShAVMofSskSczJDv+YZc/qj9kERt8U8HMspw2b5hiz3dprdUgAEmNf35c2Hy/K1gH/j6HpXkmwM2heyM9luxL61dXHiKmm/lDi/FLe+AN/OZa/gx34WfimL3mNCtapoIEahKn1JIaUrQNkxTYUPtUB95y4+uXOT16x67Txnb75wXcrDIYxgtHONFrL3NBqng0xIRjyHwjua/cZtbPxXLsgRyU0j7y/MCnuV0lgcL2CXLoVKj85MANOW4SRd/uuyVflYt1bJq5xMa5FE4kMNnSV/sAv5zmv6YVlz/liV5e5J20Hm9elqH12hMKsA+oQ05T3Xdc3OFR+Jo8XhUDgzuZEpgPMQPoHS/iohCP/2oNsaiJyn6xRMJe12AEKlnyn5zfnNZljOSQ/5E0g2OBsk7s0h//ARKO6IEb1l8dekx2w1Z2i/ykmqJPpj4xvn6GnVGfkjSJfyCpvLwgU7PNVEpUg82G9iXWSgqQrfZR/hI4hebHTMdfsQmjW1P/GpxyZl1gHLevC649rsqQmzpPFXB23uSZO22HOkPC5VkfQhCrm5lbXJfVDlHAKYQXfI2fYzk01gqjZwRYEwSWf5nELZmI1qDwTMlkyGooQHl6qsK+zts30gEojJwf9kODFoyHoCCwFXTTMCnwOSPe/k63/cHw== 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)(36860700013)(1800799024)(82310400026)(376014); DIR:OUT; SFP:1101; X-Exchange-RoutingPolicyChecked: tlOV55bfbRpK9TwnTsKmcGaqXQpSoZLIo6HVgV1cbKFpjwu/s0HShEayLkaXDVFflroPKTQsFm1yw25F2Gx20nZKWV8fPzxbtECbxYBxIoxh2y/FPynlnR7/B5bvflOW3/xOcLlho3s7S0VnOQZi9OJriRc761hLW4PA2TBklNuDELjOduxLUI01iY45dznahAW8Uh09ylhXYiER9II9CMEMvKdGW/KdOKUTjnvak1EgktcHD7s8ICRKInvI/p/y357TdwojrcbjW+JJjByCwTXm5E2sAYRTXIug1CnlMTdqLWM52fplRwHXvC2TFL0k2FVb4BONWgQtGH++galhjA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB5453 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM3PEPF00009B9B.eurprd04.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 63a88008-554f-421e-2733-08de794077ff X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|14060799003|35042699022|376014|1800799024; X-Microsoft-Antispam-Message-Info: 24oS7b4QE3kfXxAfbS3od8TK5XVk4IgLuI2Ao8uWM/FH6zN4dvgzhSjclsX6Oc8PiWToBkrCOp/2Muv9YJw75kURk3mUnGZm6LaKemG8YV5LoglcbDy56724C0XVSwYSmf23518D3fQ6M+jlER3hGpQ3zGwxANllcI+1CGYHWpTXRqzhGd8F5wh2BC5yaKKSUoSSom6WSZF9WsC/Ow+2hJNojc27JjgxTTishbZlKLYk1w0SlZhUqNgJcCH38FA4EToA3mGD02osgTfMGbPFQdC2FzOmdAr+L+ze7h9Q610ISJo5+JiRQ+Jrs74sPWeuxFUO9F+IArv3s1nkduOk+KFtB/MKCq3CUtMc2OGyg/yakoof8yYPXIKaG1mhXLJI3kc8ZytbEkzAX5kiIujfPZ7VUpM9c4BhHbmVFIiC4rCxhPJ0UqeVxoO3/2Ihul0a/8NeLBn5RqJYAZKfXsOW+DhUVwmZbdOYuk+Sa+rQBu9RpXZwosN4/unLcc1V+Bby8ZRcTB34OzbBAV9osH0nrORAMLH0jjO5ggt4OPrzaK6RVfMRnB7WoArMp+ryXLzfjrHc0KD4qsy6qAylb5SGuy7uvoenJfc/AhYRbx3/vEzKzpwnU9AcsxXlAs17Kg6G17MnhwZ4j4eTIXer/ZJTZQQfGWeYugY+lAZwtOg7PsTMkEtA2sXMHj2y4raptNbTwR/frupzzoP7XyLIi+phNgg788yV52ciiI5FyrIzUPtKHNz0WYXLNhACS3kiKR6BnJ+dCto1EtupRrn1UuYrLCk4Qe3OOcIE/UZaexBwchV3kmuU3rXCabN8LVqm4KilduECj+K3dVq4Rrmi3A0/cQ== 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)(36860700013)(82310400026)(14060799003)(35042699022)(376014)(1800799024); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jb6VsFZ90sPlg1GwW1C4tcew9SDVE3XMU3Z7mDXVYxU6ZFhAjSpeV/5zj3AOnTfq1SWEK3wqgO2vEZZhalo4APuMu5TtzkbWVNfq1RlQya2q5sksjLDqq+T/4Yt9qphnVa4LY5hzjQ+upEAN77Jb/1uT7o2vbBJAmgQUjuYF0q6QCnQKYxwf+JlRATRi0Gemhhqyc0+veOhUb70LcYqoT0bWS096KCQubORAKDUMT35d9LS6mAfzSVI/P5B4uofuqp4/WNaHdMkm7rncFrwZoEX2Qn/g0oXYA4lxcMyd8EV2cZMABkeI/V/5orunMgoxsT7eHzAAGe8sQBWPmihzSvwm4AYVGK1TKeCutY2P05g2ZtaJ778dujS+Y0zyiswBDooz96XdsZ1i55FOJyl9hN5IqL+4EJTSjqFIiMWgGTwgCQHNuOV2oDd4x4axMh85 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Mar 2026 16:19:17.1490 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 8ece69e5-5735-4ba3-8edb-08de79409f14 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: AM3PEPF00009B9B.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9003 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 This patch aims at systematically using gdbpy_ref<> at all call sites of PyObject_New(). This prepares for future patches that expect gdbby_ref<> parameters and affect return handling. As part of this change, flattening the affected functions so that the return logic becomes clearer and more flexible to adjust. --- gdb/python/py-corefile.c | 48 +++++++++++++++++++-------------------- gdb/python/py-inferior.c | 35 +++++++++++++--------------- gdb/python/py-progspace.c | 31 +++++++++++++------------ 3 files changed, 57 insertions(+), 57 deletions(-) diff --git a/gdb/python/py-corefile.c b/gdb/python/py-corefile.c index 762348121a7..de88a964efb 100644 --- a/gdb/python/py-corefile.c +++ b/gdb/python/py-corefile.c @@ -119,33 +119,33 @@ gdbpy_core_file_from_inferior (inferior *inf) return gdbpy_ref<>::new_reference (Py_None); PyObject *result = (PyObject *) cfpy_inferior_corefile_data_key.get (inf); - if (result == nullptr) - { - gdbpy_ref object - (PyObject_New (corefile_object, &corefile_object_type)); - if (object == nullptr) - return nullptr; + if (result != nullptr) + return gdbpy_ref<>::new_reference (result); - /* Ensure the 'inferior' field is set to NULL. If the PyDict_New - call fails then the gdb.Corefile will be discarded and - cfpy_dealloc will be called, which requires that the 'inferior' be - set to NULL. */ - object->inferior = nullptr; - object->mapped_files = nullptr; - object->dict = PyDict_New (); - if (object->dict == nullptr) - return nullptr; + gdbpy_ref object + (PyObject_New (corefile_object, &corefile_object_type)); + if (object == nullptr) + return nullptr; - /* Now that the gdb.Corefile has been successfully initialised and we - know that it is going to be passed back to the user, move it out - of the invalid state by setting the 'inferior' field to a non NULL - value. */ - object->inferior = inf; - cfpy_inferior_corefile_data_key.set (inf, object.get ()); - result = (PyObject *) object.release (); - } + /* Ensure the 'inferior' field is set to NULL. If the PyDict_New call fails + then the gdb.Corefile will be discarded and cfpy_dealloc will be called, + which requires that the 'inferior' be set to NULL. */ + object->inferior = nullptr; + object->mapped_files = nullptr; + object->dict = PyDict_New (); + if (object->dict == nullptr) + return nullptr; + + /* Now that the gdb.Corefile has been successfully initialised and we know + that it is going to be passed back to the user, move it out of the invalid + state by setting the 'inferior' field to a non NULL value. */ + object->inferior = inf; + + /* PyObject_New initializes the new object with a refcount of 1. This counts + for the reference we are keeping in the inferior corefile data. */ + cfpy_inferior_corefile_data_key.set (inf, object.get ()); - return gdbpy_ref<>::new_reference (result); + return gdbpy_ref<>::new_reference (object.release ()); } /* Return true if OBJ is valid. */ diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index e959a107858..dbf3a536255 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -213,29 +213,26 @@ python_free_objfile (struct objfile *objfile) gdbpy_ref inferior_to_inferior_object (struct inferior *inferior) { - inferior_object *inf_obj; + inferior_object *result = infpy_inf_data_key.get (inferior); + if (result != nullptr) + return gdbpy_ref::new_reference (result); - inf_obj = infpy_inf_data_key.get (inferior); - if (!inf_obj) - { - inf_obj = PyObject_New (inferior_object, &inferior_object_type); - if (!inf_obj) - return NULL; + gdbpy_ref inf_obj + (PyObject_New (inferior_object, &inferior_object_type)); + if (inf_obj == nullptr) + return nullptr; - inf_obj->inferior = inferior; - inf_obj->threads = new thread_map_t (); - inf_obj->dict = PyDict_New (); - if (inf_obj->dict == nullptr) - return nullptr; + inf_obj->inferior = inferior; + inf_obj->threads = new thread_map_t (); + inf_obj->dict = PyDict_New (); + if (inf_obj->dict == nullptr) + return nullptr; - /* PyObject_New initializes the new object with a refcount of 1. This - counts for the reference we are keeping in the inferior data. */ - infpy_inf_data_key.set (inferior, inf_obj); - } + /* PyObject_New initializes the new object with a refcount of 1. This counts + for the reference we are keeping in the inferior data. */ + infpy_inf_data_key.set (inferior, inf_obj.get ()); - /* We are returning a new reference. */ - gdb_assert (inf_obj != nullptr); - return gdbpy_ref::new_reference (inf_obj); + return gdbpy_ref::new_reference (inf_obj.release ()); } /* Called when a new inferior is created. Notifies any Python event diff --git a/gdb/python/py-progspace.c b/gdb/python/py-progspace.c index baab3be5ee6..146360d890d 100644 --- a/gdb/python/py-progspace.c +++ b/gdb/python/py-progspace.c @@ -585,21 +585,24 @@ gdbpy_ref<> pspace_to_pspace_object (struct program_space *pspace) { PyObject *result = (PyObject *) pspy_pspace_data_key.get (pspace); - if (result == NULL) - { - gdbpy_ref object - ((pspace_object *) PyObject_New (pspace_object, &pspace_object_type)); - if (object == NULL) - return NULL; - if (!pspy_initialize (object.get ())) - return NULL; - - object->pspace = pspace; - pspy_pspace_data_key.set (pspace, object.get ()); - result = (PyObject *) object.release (); - } + if (result != nullptr) + return gdbpy_ref<>::new_reference (result); + + gdbpy_ref object + (PyObject_New (pspace_object, &pspace_object_type)); + if (object == nullptr) + return nullptr; + + if (! pspy_initialize (object.get ())) + return nullptr; + + object->pspace = pspace; + + /* PyObject_New initializes the new object with a refcount of 1. This counts + for the reference we are keeping in the pspace data. */ + pspy_pspace_data_key.set (pspace, object.get ()); - return gdbpy_ref<>::new_reference (result); + return gdbpy_ref<>::new_reference (object.release ()); } /* See python-internal.h. */ -- 2.53.0