From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QS8TLbzf8GlZTgEAWB0awg (envelope-from ) for ; Tue, 28 Apr 2026 12:26:36 -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=ey7wupJI; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=ey7wupJI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id B1C131E0BA; Tue, 28 Apr 2026 12:26:36 -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 AFE4D1E067 for ; Tue, 28 Apr 2026 12:26:35 -0400 (EDT) Received: from vm01.sourceware.org (localhost [127.0.0.1]) by sourceware.org (Postfix) with ESMTP id 4C7C84BB8F6B for ; Tue, 28 Apr 2026 16:26:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4C7C84BB8F6B 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=ey7wupJI; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=ey7wupJI Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazlp170110003.outbound.protection.outlook.com [IPv6:2a01:111:f403:c201::3]) by sourceware.org (Postfix) with ESMTPS id 6AAE94BB8F5B for ; Tue, 28 Apr 2026 16:26:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6AAE94BB8F5B 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 6AAE94BB8F5B Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:c201::3 ARC-Seal: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1777393561; cv=pass; b=kPx6o5GO/pJASR8X3yIKymFD5OEBOjpshTqxqzvMXhO42GAvjzczBBbM73KG8ZLxcV8js5OkhijSithaw5D9mcs1frLsSbA53PBybDqf5PANn4binEleKTsZ28JzCSrLz7Lvo3LNJLsGlrosUZYkefdDSG2kpCR15zvzvCbfW2A= ARC-Message-Signature: i=3; a=rsa-sha256; d=sourceware.org; s=key; t=1777393561; c=relaxed/simple; bh=OQL1SpyuyIQJDgzbgyGpnAyZRu+4KeK009UBOUDgZ8M=; h=DKIM-Signature:DKIM-Signature:From:To:Subject:Date:Message-ID: MIME-Version; b=wMXx2r5MNO5Y8Q6btrE3aiVzmjIayfEBsGhDxz+mlBI52vw9eryxxTGMfPn1MDgFPd1hN+Vs1FKkNmWm0tULDI+L2VXjWTJEznPgFwcBDEfzkQUAocvBVHNxB7AZaUTlRmM9x7Vo2HPEWYDwGRs0wzKhq2lZpFLp84bsbO9g1Zc= ARC-Authentication-Results: i=3; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6AAE94BB8F5B ARC-Seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=Chn7MFYrbT8JFslkTksBGo6AZZx0Zs0mG0rb4eyi1WshYspsUesHCFGjLle94mqJv3w8ZRAe4T5oQyEu2d7wj0qAxKHV01rLb0NTjoHe8+0gmFYqPLY5iJ2dzqiuk4N6dT5DkMkA495YhH50VTjY6/rghV8GGyhbyNqW7hXm42FFWJ9lV3dQA8RyYHfk2KBJmYU2AzdjPylr88tmA+XHdV5qng6AeyebabIA/wUpiGnPs4Sa4bZVnYnGc7lrnMJSdM5EsnS6HwVzXSjadxMZuEHC1wnOPiKk83b/nO+QxrHlCdwxpLly9h7aNjFUp2dyRx7Un1Hd3L14dAyEv3xepA== 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=pao1xQAl6ucTC1/F/dS5+E3cHiwodzP/f5VJHY0T0ng=; b=TOUreYU5UURYvA2aWDsAqNwGWe7GTLBu9OPRXCv0ul2LCaEowmbDj+qNoD6UlOEeEg0Oiu+Jy3f3ZUo8hQITtyGFXexpyCvMFpaVlu6OR/yIgqWiyWvsHihOxQppIMXd/wYOfjkR3mFIIVFASaszXZAE5J9PeAApeBDfQfNHeEDQK/1bP67Tgd2ANAknSmRl9aSX4mTpOtLcUzT3RU0iPVEOxAf44kjoY3Db/EwGi5Lit2n8f0BD+SYeqrxp9TC9uuEvtFG/kTnbJ1vVw8qvPgnLZNwlAhyp8zwCk4LGYMCM9Aq8TunnYtpxk8O/QZI1oiI/oVdgqZnGJ0dyXGlB5A== 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=pao1xQAl6ucTC1/F/dS5+E3cHiwodzP/f5VJHY0T0ng=; b=ey7wupJIdQ0IAqhxXTWp/rAppcy8KtFp0jedYDCuEShkbeXx/rMBnwXD1EgWz8QMDWi8x9AvDNjXnaQGkxz6iRQrVoBPNT8uH7Qm0zCRx+/Vpnu7FBY53UyHpDXCbDejCE3M92DumfxyrjeAsEHGX/zD3i+b8HFDPOThH45XEh0= Received: from CWLP123CA0224.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:19f::12) by DB9PR08MB7819.eurprd08.prod.outlook.com (2603:10a6:10:39b::19) 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:51 +0000 Received: from DB1PEPF000509F7.eurprd02.prod.outlook.com (2603:10a6:400:19f:cafe::76) by CWLP123CA0224.outlook.office365.com (2603:10a6:400:19f::12) 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:51 +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 DB1PEPF000509F7.mail.protection.outlook.com (10.167.242.153) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.9846.18 via Frontend Transport; Tue, 28 Apr 2026 16:25:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=vVTDtYufQ02JvB5jMBrQf5A2Ia+jl+ZETaKYIeBFLQA7hgaJ6rwcNW0yRjqprEGDjCbobwcWwIeBegcpTIHTdREa2MbvOFxtQBLvWaddye4oKlZAaKDSid/xdn0f261c8fJPlK/PyKb2TFBvBqL22MJEUIkUzCZsRgmAVFb19iJEm0jkEHTVUm0DtvhHO6RguV6FqDGTO8MJc2Hjq57lylqC9Fra0Q5Q/uiWch7rd9OB1nQbsX7oIxab7Lt7txPUYSgeKIzn4Y1NCbjXG7coCEgSb5PgVah1JhrrcXflOt8pZb2DpoL2wDL46xRMKno8Xh7Ra9KDxKZU+ded5DKxeA== 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=pao1xQAl6ucTC1/F/dS5+E3cHiwodzP/f5VJHY0T0ng=; b=uCz0vCzZZEiqDmS3jMpQFe7uczRRqXgCbCa+idZKZqZBDBkp/oUehwdRnhfMThDwyOh1AvT7frksYOFxQTMSj/8maCQaeax9KwruAwN3ah1G1Qnnve/1lTZS0VBafFLFiQ9wUxe+GAWdnLwKkA5nvsCTEjkg56DF927/neLnrZAhs91IqoJ+9D8VSGBM8yJiuUIXl5jI4Uwe9riUbi9E400wMmyHRiobHgoFnqFavtE51BKhVXLxzm/m8NOSc3k/HfQ+NL5bfc0w5X07IxqEoEOUhgS6CEpma4pic87F6oxqCntDMmfFPu8lYsJwob/YPGrHC5r3VRKaF3iPwmxMXQ== 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=pao1xQAl6ucTC1/F/dS5+E3cHiwodzP/f5VJHY0T0ng=; b=ey7wupJIdQ0IAqhxXTWp/rAppcy8KtFp0jedYDCuEShkbeXx/rMBnwXD1EgWz8QMDWi8x9AvDNjXnaQGkxz6iRQrVoBPNT8uH7Qm0zCRx+/Vpnu7FBY53UyHpDXCbDejCE3M92DumfxyrjeAsEHGX/zD3i+b8HFDPOThH45XEh0= Received: from CW1P123CA0025.GBRP123.PROD.OUTLOOK.COM (2603:10a6:400:292::8) by PAWPR08MB10976.eurprd08.prod.outlook.com (2603:10a6:102:46f::17) 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:46 +0000 Received: from AM2PEPF0001C710.eurprd05.prod.outlook.com (2603:10a6:400:292:cafe::81) by CW1P123CA0025.outlook.office365.com (2603:10a6:400:292::8) 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:46 +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:46 +0000 Received: from AZ-NEU-EXJ02.Arm.com (10.240.25.139) 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:42 +0000 Received: from AZ-NEU-EX04.Arm.com (10.240.25.138) by AZ-NEU-EXJ02.Arm.com (10.240.25.139) 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:42 +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:42 +0000 From: Matthieu Longo To: , Tom Tromey CC: Matthieu Longo Subject: [PATCH v2 2/4] gdb/python: eval_python_command returns result of the evaluation Date: Tue, 28 Apr 2026 17:24:14 +0100 Message-ID: <20260428162416.511367-3-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_|PAWPR08MB10976:EE_|DB1PEPF000509F7:EE_|DB9PR08MB7819:EE_ X-MS-Office365-Filtering-Correlation-Id: fa53b959-fe2c-414f-c54c-08dea542d02b 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: ArofEcCnvj4xAdbTvdNrGuybV0PyhbYhCZJlujzqs0LP056BsJRRJ4UDsxzZEtg1fDwKsyp0pw0PTQmppQg6vNOz8HXNGONsruDlzZB9L97dqt/Km4YY15ubM0oqbtS0mfq3mrKvUwaYPKp7F/UAM0LkcvR0gOWgz2QEO2WxmaUPTa9Kj8U2vYLB/bn1L51Qatyif+ia26VIaiWiE/2VmsbiQ+e0J5Xl8OhXj9eAY+2jqYGkOyBLRa/XOa2JhcZjsb922oECvZXWNs9A0cuHlKUY2BtUFM6OjFG+j+By4C9I6rDVNf1j88udk2HPQ3+o8DFFsoDqMnUKdvb5XZK6+7uv2cuseyFdOod553HS1N7/q6y4f2K5+OEh1rwT8ND8Zc+XBU2yRi7cxCcIQJsLNs3GZBMn4FtfcoOoYYB8Bwv4h9SDIu1ympCeICSgIlpoT6gH7Ifq8Cm5AjWHjXtxa/TI1rxqo25v8YzHxYlLuCg8JTcyjm9YPWunHrPFZEfgYypBssHKZEi2e8umpblZeUWznK1n1GCrUiqvXzTOg28ZeehXyAy8YT8nuhjn95EM2G4WRB1Db4ACoxmSNXV92XVanLsRuCButELNLhAEJW1hxuziz9N3EoFJEngn21LTKi3xGSuqCXYnnq5KtIN+rFhqMr0xthnUJARSDbmPm5t8u6BQ+9LVzz8+URgNZmaWx0oV+XxJcmYEdrzc0+btdY0vHBxawy0gdlKnvU05zQs9jZ5Ltg4q/goG3XjxKJMf9ACIppmHryKQM6x/JR5/KA== 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: bEf+75Mgwo789ahMm+rKo1QFBRVFVcx8LX/VdS8ExLh4r04vz9SBoUxZFSqrAzEFq4CE5DE8l6CIiyXPfpe20oEYNauTQwAZWuUK17Dodxvt4YZQJfvMRTlFWW1LBbOWkC2uAWwLbo+nhJQSFu79qTF1KSjh6z0fCNpP0WvNXH6FrwKAVowJroBZVm4FLOrdKeSVIcM3T+TRkm3v26qz4zac2ZGOBYL3YZRer0osKoLr6L66HweR0OfNLU2HmlAdynrFneGhP2YK1sQABu6FgO2V1e7efnsAX4CNS5bJ8iP5npLWaSLv6qvR6uFZELVxOY4JjCpeySsg+/tMjQMYhQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR08MB10976 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB1PEPF000509F7.eurprd02.prod.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: a4bb2d33-27d9-40c5-7093-08dea542a9c0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700016|14060799003|1800799024|82310400026|35042699022|376014|56012099003|18002099003|22082099003|13003099007; X-Microsoft-Antispam-Message-Info: b+rsrvc45SUuvmjTS8Jqty7Aa8BlX4FUxgIfKqjCAM9bkdPqPvmV+VUg+Pn4uwbRv9OwFmDU/plyDvEL25RaP9TV2U1tBALIv9AOVS2QeN7adFCbnkb9MRUarxuWmh7xiL1aglQ6zGxfr2+VSXmEZaw6tpGLb5SLYCmtvUNKQ/WPjIK5d0mprhFQ97Kx5YD3f0W096I1OjT9vK44Stc4eKjbEMt1d4HN08yUaPr7c079cIfBSg4MTwnRBhcLl+Zzizngr7DHebW9x+OFbQMjOm1X5+y6alkhMokaEMal13HGVHCEP9972A5ja3simeYqjoMl1VUVB9DBFqjKu+skQENg+0GP1Y+DPPzXyoYZumt9O9V18XDl1iM3oIH0otSv9K2SX1W+Ah3STQgHpBZW5RdTXoLQOb35WP+JffgkyVZ4jyCoCkMXJ9xKd5knDC2Ph4IpHKBOym2B/tb7SVuEXf3OSdjhhNRZWCn4N/EGiJ4tAgeJFkJu0ADzW2nLkjqk6beHBLrMI272mo8q4TfQ5GiQqnZFSV4wNLrpXFR4xiMnD3KsmKb/N/plS6OwASYrTvv6cWBjcpp5rb8cv01+DRAlEmFgUp02yKybkPBoSnxbeoVgYOEUY+iaywHlkehnpJfw4/j4a9RGAZ5wcjvF0Oce8IpbRNWKCR9u73xJ3Wv5DoHtAkNISlmHxUI5tvKkrwdsjSR2EpDQteZBPfru2VxcKmbWEOgz7COdHrUPAWUmBEQeVTs0iOMIIGCf56Tfg8+jSZHt7aBWnukE1a3A3g== 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)(1800799024)(82310400026)(35042699022)(376014)(56012099003)(18002099003)(22082099003)(13003099007); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0g02KdSLIkmg2jHBsLzrexNhoTcPZtn03uHKdMwv9BDOWgCbLuW/CyHybzwqzIR2sqHwmQQra7FEIib5KJ5VFI+xYEGdz6H9WooR9664CYQ2Yd3hDvh+cVVzI+D/PS1yoEbzRl6ZIsNe2oMzeZ6Z/gT3rSR7/Fa5N4xtdZbCOSIwtbUMymlNW0W1kNVtrSuVs0FwT/ZuEw04unIiJIi11QxDIqa60rHnX07ZWK2IyCeRu4cS7BfV1TrOFYdR7NvlrGqhym+0TbGP2w21v816x+S9ASIoWo5Abt7bv7/VwgvAJyJ86EcMmZWwjvcvZbaV5qxnqtnMfPLFqz015X+HhVKIyl5Kar+PmDSrDM4/3IttrDTkhA0QwD6QlK3U4EogbSKYemJ29zrxCxkvDLQlmSn9VnCvoMDSaHbg9ihiub4NofU3nJm6ra57DtOZXwZD X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2026 16:25:51.1536 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fa53b959-fe2c-414f-c54c-08dea542d02b 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: DB1PEPF000509F7.eurprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB9PR08MB7819 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 A previous commit [1] centralized the Python code evaluation in the helper function eval_python_command(). However, a missed case in varobj_set_visualizer() requires not only the exit status but the result of the evaluation too. This patch updates eval_python_command() to return the result of the evaluation, or NULL if an error occurred. It also adjusts the existing callers accordingly. Finally, it replaces the use of PyRun_String() in varobj_set_visualizer() with a call to eval_python_command(). [1]: 264a8a2236e8aa64b333a69e42a55ff8c0844f6e Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=23830 --- gdb/python/py-gdb-readline.c | 2 +- gdb/python/python-internal.h | 4 +- gdb/python/python.c | 75 +++++++++++++++++------------------- gdb/varobj.c | 11 +----- gdbsupport/gdb_ref_ptr.h | 5 +++ 5 files changed, 45 insertions(+), 52 deletions(-) diff --git a/gdb/python/py-gdb-readline.c b/gdb/python/py-gdb-readline.c index e8e2c23547c..b7f8caeccd4 100644 --- a/gdb/python/py-gdb-readline.c +++ b/gdb/python/py-gdb-readline.c @@ -114,7 +114,7 @@ class GdbRemoveReadlineFinder(MetaPathFinder):\n\ \n\ sys.meta_path.insert(2, GdbRemoveReadlineFinder())\n\ "; - if (eval_python_command (code, Py_file_input) == 0) + if (eval_python_command (code, Py_file_input)) PyOS_ReadlineFunctionPointer = gdbpy_readline_wrapper; return 0; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 37bc37691fe..577260c4066 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -1337,7 +1337,7 @@ class gdbpy_memoizing_registry_storage gdb::unordered_map m_objects; }; -extern int eval_python_command (const char *command, int start_symbol, - const char *filename = nullptr); +extern gdbpy_ref<> eval_python_command + (const char *command, int start_symbol, const char *filename = nullptr); #endif /* GDB_PYTHON_PYTHON_INTERNAL_H */ diff --git a/gdb/python/python.c b/gdb/python/python.c index 502fe682b2c..546d1272007 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -297,44 +297,43 @@ gdbpy_check_quit_flag (const struct extension_language_defn *extlang) Python start symbol, and does not automatically print the stack on errors. FILENAME is used to set the file name in error messages; NULL means that this is evaluating a string, not the contents of a - file. */ + file. + Return the result of the evaluation on success, NULL on failure. */ -int +gdbpy_ref<> eval_python_command (const char *command, int start_symbol, const char *filename) { - PyObject *m, *d; - - m = PyImport_AddModule ("__main__"); - if (m == NULL) - return -1; + gdbpy_borrowed_ref<> mainmod = PyImport_AddModule ("__main__"); + if (mainmod == nullptr) + return nullptr; - d = PyModule_GetDict (m); - if (d == NULL) - return -1; + gdbpy_borrowed_ref<> globals = PyModule_GetDict (mainmod); + if (globals == nullptr) + return nullptr; bool file_set = false; if (filename != nullptr) { gdbpy_ref<> file = host_string_to_python_string ("__file__"); if (file == nullptr) - return -1; + return nullptr; /* PyDict_GetItemWithError returns a borrowed reference. */ - PyObject *found = PyDict_GetItemWithError (d, file.get ()); + PyObject *found = PyDict_GetItemWithError (globals, file.get ()); if (found == nullptr) { if (PyErr_Occurred ()) - return -1; + return nullptr; gdbpy_ref<> filename_obj = host_string_to_python_string (filename); if (filename_obj == nullptr) - return -1; + return nullptr; - if (PyDict_SetItem (d, file.get (), filename_obj.get ()) < 0) - return -1; - if (PyDict_SetItemString (d, "__cached__", Py_None) < 0) - return -1; + if (PyDict_SetItem (globals, file.get (), filename_obj.get ()) < 0) + return nullptr; + if (PyDict_SetItemString (globals, "__cached__", Py_None) < 0) + return nullptr; file_set = true; } @@ -347,12 +346,12 @@ eval_python_command (const char *command, int start_symbol, : filename, start_symbol)); - int result = -1; + gdbpy_ref<> eval_result; if (code != nullptr) { - gdbpy_ref<> eval_result (PyEval_EvalCode (code.get (), d, d)); - if (eval_result != nullptr) - result = 0; + eval_result.reset (PyEval_EvalCode (code.get (), globals, globals)); + if (eval_result == nullptr) + gdb_assert (PyErr_Occurred ()); } if (file_set) @@ -360,21 +359,21 @@ eval_python_command (const char *command, int start_symbol, /* If there's already an exception occurring, preserve it and restore it before returning from this function. */ std::optional save_error; - if (result < 0) + if (eval_result == nullptr) save_error.emplace (); /* CPython also just ignores errors here. These should be expected to be exceedingly rare anyway. */ - if (PyDict_DelItemString (d, "__file__") < 0) + if (PyDict_DelItemString (globals, "__file__") < 0) PyErr_Clear (); - if (PyDict_DelItemString (d, "__cached__") < 0) + if (PyDict_DelItemString (globals, "__cached__") < 0) PyErr_Clear (); if (save_error.has_value ()) save_error->restore (); } - return result; + return eval_result; } /* Implementation of the gdb "python-interactive" command. */ @@ -383,7 +382,7 @@ static void python_interactive_command (const char *arg, int from_tty) { struct ui *ui = current_ui; - int err; + bool err; scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0); @@ -395,11 +394,11 @@ python_interactive_command (const char *arg, int from_tty) { std::string script = std::string (arg) + "\n"; /* Py_single_input causes the result to be displayed. */ - err = eval_python_command (script.c_str (), Py_single_input); + err = ! eval_python_command (script.c_str (), Py_single_input); } else { - err = PyRun_InteractiveLoop (ui->instream, ""); + err = PyRun_InteractiveLoop (ui->instream, "") != 0; dont_repeat (); } @@ -410,6 +409,7 @@ python_interactive_command (const char *arg, int from_tty) /* Like PyRun_SimpleFile, but if there is an exception, it is not automatically displayed. FILE is the Python script to run named FILENAME. + Return true on success, false on failure. On Windows hosts few users would build Python themselves (this is no trivial task on this platform), and thus use binaries built by @@ -420,7 +420,7 @@ python_interactive_command (const char *arg, int from_tty) A FILE * from one runtime does not necessarily operate correctly in the other runtime. */ -static int +static bool python_run_simple_file (FILE *file, const char *filename) { std::string contents = read_remainder_of_file (file); @@ -458,8 +458,7 @@ gdbpy_eval_from_control_command (const struct extension_language_defn *extlang, gdbpy_enter enter_py; std::string script = compute_python_string (cmd->body_list_0.get ()); - int ret = eval_python_command (script.c_str (), Py_file_input); - if (ret != 0) + if (! eval_python_command (script.c_str (), Py_file_input)) gdbpy_handle_exception (); } @@ -475,8 +474,7 @@ python_command (const char *arg, int from_tty) arg = skip_spaces (arg); if (arg && *arg) { - int ret = eval_python_command (arg, Py_file_input); - if (ret != 0) + if (! eval_python_command (arg, Py_file_input)) gdbpy_handle_exception (); } else @@ -1119,8 +1117,7 @@ gdbpy_source_script (const struct extension_language_defn *extlang, FILE *file, const char *filename) { gdbpy_enter enter_py; - int result = python_run_simple_file (file, filename); - if (result != 0) + if (! python_run_simple_file (file, filename)) gdbpy_handle_exception (); } @@ -1826,8 +1823,7 @@ gdbpy_source_objfile_script (const struct extension_language_defn *extlang, scoped_restore restire_current_objfile = make_scoped_restore (&gdbpy_current_objfile, objfile); - int result = python_run_simple_file (file, filename); - if (result != 0) + if (! python_run_simple_file (file, filename)) gdbpy_print_stack (); } @@ -1849,8 +1845,7 @@ gdbpy_execute_objfile_script (const struct extension_language_defn *extlang, scoped_restore restire_current_objfile = make_scoped_restore (&gdbpy_current_objfile, objfile); - int ret = eval_python_command (script, Py_file_input); - if (ret != 0) + if (! eval_python_command (script, Py_file_input)) gdbpy_print_stack (); } diff --git a/gdb/varobj.c b/gdb/varobj.c index edd94ea4963..a8c991e50eb 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1365,20 +1365,13 @@ void varobj_set_visualizer (struct varobj *var, const char *visualizer) { #if HAVE_PYTHON - PyObject *mainmod; - if (!gdb_python_initialized) return; gdbpy_enter_varobj enter_py (var); - mainmod = PyImport_AddModule ("__main__"); - gdbpy_ref<> globals - = gdbpy_ref<>::new_reference (PyModule_GetDict (mainmod)); - gdbpy_ref<> constructor (PyRun_String (visualizer, Py_eval_input, - globals.get (), globals.get ())); - - if (constructor == NULL) + auto constructor = eval_python_command (visualizer, Py_eval_input); + if (constructor == nullptr) { gdbpy_print_stack (); error (_("Could not evaluate visualizer expression: %s"), visualizer); diff --git a/gdbsupport/gdb_ref_ptr.h b/gdbsupport/gdb_ref_ptr.h index 0eb654324c6..f7c7c0afac6 100644 --- a/gdbsupport/gdb_ref_ptr.h +++ b/gdbsupport/gdb_ref_ptr.h @@ -179,6 +179,11 @@ class ref_ptr return m_obj; } + operator bool () const noexcept + { + return m_obj != nullptr; + } + /* Return this instance's referent, and stop managing this reference. The caller is now responsible for the ownership of the reference. */ -- 2.54.0