From patchwork Thu Nov 21 12:46:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Vrany X-Patchwork-Id: 101642 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D3CE93857356 for ; Thu, 21 Nov 2024 12:49:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D3CE93857356 X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from us-smtp-delivery-114.mimecast.com (us-smtp-delivery-114.mimecast.com [170.10.133.114]) by sourceware.org (Postfix) with ESMTP id 481FB3857830 for ; Thu, 21 Nov 2024 12:47:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 481FB3857830 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=labware.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=labware.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 481FB3857830 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.133.114 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732193265; cv=none; b=CoCO34G0ApX1KbqIvwyqgmdyBYAVKmFuPMHPlaUFTdELyOfoQmYK76/xw9bizU+wKrGuMh06Ftd1opjicp7QtGweTdPn22L0aaXCIsATdpPQrCSaLAfOBVI60vsdt0dQIwrgw6u9hJun8v6qqCMV1yMShVI6tXchmJmm+zmAg1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732193265; c=relaxed/simple; bh=3vzN9A+ei7zDYir+VzkSOo1TAnVMFZfM9YmVyoy09YQ=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=a6raSZrpRR1OYIq8p+8S3DfmAPFqOLLqIA8jNQlwgMbJ9+Oa7lX5KQKdlwhJ4cXOItll/82RXNvZH+nf4LjM+PEWw7jEx3vi+9HY0U6Be4kQr67sWZyp60R5P/OSq405aY4AUktOFbtV8tZd5eLzqkiwyo6r7nl+7nHwpGKjC/M= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 481FB3857830 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12lp2175.outbound.protection.outlook.com [104.47.59.175]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-452-sFYuMLlWPBqlLWLNSYWhzg-2; Thu, 21 Nov 2024 07:47:44 -0500 X-MC-Unique: sFYuMLlWPBqlLWLNSYWhzg-2 X-Mimecast-MFC-AGG-ID: sFYuMLlWPBqlLWLNSYWhzg Received: from SA0PR17MB4314.namprd17.prod.outlook.com (2603:10b6:806:e7::16) by SA1PR17MB6504.namprd17.prod.outlook.com (2603:10b6:806:337::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8158.22; Thu, 21 Nov 2024 12:47:42 +0000 Received: from SA0PR17MB4314.namprd17.prod.outlook.com ([fe80::38a7:a6f2:3b95:bc26]) by SA0PR17MB4314.namprd17.prod.outlook.com ([fe80::38a7:a6f2:3b95:bc26%5]) with mapi id 15.20.8158.023; Thu, 21 Nov 2024 12:47:42 +0000 From: Jan Vrany To: gdb-patches@sourceware.org CC: Jan Vrany , Eli Zaretskii Subject: [RFC v2 04/21] gdb/python: add void_type () method to gdb.Architecture object Date: Thu, 21 Nov 2024 12:46:57 +0000 Message-ID: <20241121124714.419946-5-jan.vrany@labware.com> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20241121124714.419946-1-jan.vrany@labware.com> References: <20241121124714.419946-1-jan.vrany@labware.com> X-ClientProxiedBy: LO0P265CA0007.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:355::18) To SA0PR17MB4314.namprd17.prod.outlook.com (2603:10b6:806:e7::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SA0PR17MB4314:EE_|SA1PR17MB6504:EE_ X-MS-Office365-Filtering-Correlation-Id: c4011e17-b2cf-41ad-4bc6-08dd0a2ab06f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|376014 X-Microsoft-Antispam-Message-Info: Z8ZcjzbHaWs8p7rCA9LeQs+chR/54FQinbTTu/HwWU9DhrBjvBmCspSp5Sq9gdHJzIyP93EY81NTDrfNHyzDTE8MsVXypicvNyc7TCeCiJBlPNpr/ZiCyXih/u6dY0+l3z5b1bj7H9ZzNOKAJZj0ILrP5CBvw7jhrR11fJ69RmYsQ5SskRU7rO9nLJ9q+QaiG3v0Z6qVExUzPA0obDW32YUFTSby+5oW2Lyz05KlEJq4PUqRne8e8NuidLARWS8fsix5vsIjQXkn7/YErmfXr2UsQdrJMb0p6yYrADrJQWeevIEOQINbOD/KNhJ31fu6NUiFPfPTEXNxN3EIv1S+DJuFEF2ubBK65ibo5kdBhIfTsRufHS1wisyTXqiub+5Lkm/4EgC2P0OGluDBGGS0iklkZf/DKUHi6jtmIWsMRbAi8BHc6BAwHi1QXlZtb1NiOKghG0tqZvUJMC+RkT1ttGurMzYVHrojetd2w6+M0N+/odpBdfiVo3XREOxDKC+50aNeu9rGxwIi87BA+Q8IEf1D5VTqHKf+3GPo0F5qgCoXUMPfh5Ny7nczEJOcyfNgdmC0WoHtZDFAbZXHeZRauE8QSzi+i+SnvJ1W+cGO+SE4RDfIo8hJQPP8BoItyeLCrTdgfaQukTuc/s/W+2yo+A8citKVp4p5EycZo7rZBEoJqJNEMCN6D28nDcWy3SttCFERLFHPEjF4M4vaExgvvs/pLDM7RyN3aaHk5d9T/s+eFDdi7KBnfA79hjCif8PkNASTjwQfw54s4VY2woQXLi9dmkRR+dk2Yxvxr+zL10rhLi0kO37UJoM3lG+kXl8HkNRYA0MJOxvtx/pnexrluaOVSIp3QZBO1JT7JyWMarCwD+77TGN1IUJ34ykReWJhh6K4VGmD7vhptvQkrnGJ0mhTuTqO9k20kGe6MIZy94tXOXeH/AaKmpROICue8SkLJE+zuWz65SlEd+KL+rpT5pXZ3qk3tNkNP5g0bcwGw+Dv4v3O4F90kkvLzHPlZT+5mYDumBkVJv6N9irYhOjmY8y7HIXm8ELG3+dvTmwyDK6MBSsnQAwlL2oQLW09D8d5HJSwY7tnBKJRdKyIKVqXnUDK/i+uRFvJVOvsWhvXg8Xj5fITUywRzNfZNnuR397ghcbObHnUSsBTHxBZPeQyyrX5HyB0qA1A+fsFvEuyXZQZDMq7JyBCpn6zACTwZKNbKq2pZL5K3FDw97fdOBUjPB/laUD9UsEQxcDJCYHwzMkgekJKz/h6KM4M5IvK3jQT7fP0vAqcBDZWPR6uhmbevni5V36IqtMMedaSMEOJ0bDk/9CyfFepfB689Y1ajngu X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SA0PR17MB4314.namprd17.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014); DIR:OUT; SFP:1102 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Cgxlr+/4lEBsx+/OB56C+4nptNM/ofCaBG+HrWJjARa71sS1DIJpG1AbQ07nR2l2QAXGKF7Sw6igt8bKBUktMCd4JnIHthL/Lco/NpQKqNPsYnmGgTrmzg2Ju3WZAd7nw/BjWA3U1ND3evlJ7GuV2CwiHwmsud/KncFxHzpng/k0Twe9QRx8tgzIYUEtdkLs5dQQVvglAWjAoLdDtuPxMy4wdAxltpiTdud+ABBGVV0JFr8ca10XWhRixbr9G0B+T2k+xvR+0EP8Vw/7sWPQv+xihgXoZImcwz4/MHoUG058Gc5dL2ITJEVlhDzSlevq/QPbZJUj1TxgZPm4QB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30qQYJsN/0FyJqv6Tecghjj4GMLJBFdc3fICRi5/+Sc/9rcW7G6hs6VRVodegBDYoscb1SFrsXJycM/FYoQVaj1XveV1UM2Y/70ZpdLMfGECNqr1RpEYESTOorCzRgVPQtHYT/uuVf8YDHoMr+J2pfesvObd3BVKu7XCY8 X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-Network-Message-Id: c4011e17-b2cf-41ad-4bc6-08dd0a2ab06f X-MS-Exchange-CrossTenant-AuthSource: SA0PR17MB4314.namprd17.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Nov 2024 12:47:42.2433 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b5db0322-1aa0-4c0a-859c-ad0f96966f4c X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 9tH5/j09faxzoQNuSn2LGcablnirjADP7B0rrA31B6Sh11waHE4XERkAEY+a+c2rpUKwiFMLt3CYEmAGb2lAUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR17MB6504 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: diRRzM21dPVz4d_wsvPcfKftSrT-uMo7vrmPzaqw8xM_1732193263 X-Mimecast-Originator: labware.com X-Spam-Status: No, score=-12.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org 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~patchwork=sourceware.org@sourceware.org This commit adds a new method to Python architecture objects that returns a void type for that architecture. This will be useful later to create types for function symbols created using Python extension code. Reviewed-By: Eli Zaretskii Reviewed-By: Eli Zaretskii --- gdb/NEWS | 3 +++ gdb/doc/python.texi | 4 ++++ gdb/python/py-arch.c | 16 ++++++++++++++++ gdb/testsuite/gdb.python/py-arch.exp | 4 ++++ 4 files changed, 27 insertions(+) diff --git a/gdb/NEWS b/gdb/NEWS index 1ea9fcc65b9..765d14a1ae4 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -88,6 +88,9 @@ ** Added gdb.Symbol.domain. Contains the domain of the symbol. + ** Added gdb.Architecture.void_type. Returns a gdb.Type representing "void" + type for that architecture. + * Debugger Adapter Protocol changes ** The "scopes" request will now return a scope holding global diff --git a/gdb/doc/python.texi b/gdb/doc/python.texi index 09e374700a4..dac5115a5f8 100644 --- a/gdb/doc/python.texi +++ b/gdb/doc/python.texi @@ -7090,6 +7090,10 @@ If the indicated type cannot be found, this function will throw a @code{ValueError} exception. @end defun +@defun Architecture.void_type () +This function returns a void type. +@end defun + @anchor{gdbpy_architecture_registers} @defun Architecture.registers (@r{[} reggroup @r{]}) Return a @code{gdb.RegisterDescriptorIterator} (@pxref{Registers In diff --git a/gdb/python/py-arch.c b/gdb/python/py-arch.c index f7e35a4aa2b..6aed133eedd 100644 --- a/gdb/python/py-arch.c +++ b/gdb/python/py-arch.c @@ -318,6 +318,18 @@ archpy_integer_type (PyObject *self, PyObject *args, PyObject *kw) return type_to_type_object (type); } +/* Implementation of gdb.void_type. */ +static PyObject * +archpy_void_type (PyObject *self, PyObject *args) +{ + struct gdbarch *gdbarch; + ARCHPY_REQUIRE_VALID (self, gdbarch); + + builtin_type (gdbarch); + + return type_to_type_object (builtin_type (gdbarch)->builtin_void); +} + /* __repr__ implementation for gdb.Architecture. */ static PyObject * @@ -383,6 +395,10 @@ END_PC." }, "integer_type (size [, signed]) -> type\n\ Return an integer Type corresponding to the given bitsize and signed-ness.\n\ If not specified, the type defaults to signed." }, + { "void_type", (PyCFunction) archpy_void_type, + METH_NOARGS, + "void_type () -> type\n\ +Return an void Type." }, { "registers", (PyCFunction) archpy_registers, METH_VARARGS | METH_KEYWORDS, "registers ([ group-name ]) -> Iterator.\n\ diff --git a/gdb/testsuite/gdb.python/py-arch.exp b/gdb/testsuite/gdb.python/py-arch.exp index 14802ec80a3..c76fc778117 100644 --- a/gdb/testsuite/gdb.python/py-arch.exp +++ b/gdb/testsuite/gdb.python/py-arch.exp @@ -104,6 +104,10 @@ foreach_with_prefix test_data { {None None} \ "check 'signed' argument can handle non-bool type $bad_type" } +gdb_test "python print(arch.void_type())" \ + "void" \ + "get void type" + # Test for gdb.architecture_names(). First we're going to grab the # complete list of architecture names using the 'complete' command. set arch_names []