Message ID | 20241121124714.419946-7-jan.vrany@labware.com |
---|---|
State | New |
Headers |
Return-Path: <gdb-patches-bounces~patchwork=sourceware.org@sourceware.org> 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 7D74D385734E for <patchwork@sourceware.org>; Thu, 21 Nov 2024 12:51:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D74D385734E 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 C437E3857713 for <gdb-patches@sourceware.org>; Thu, 21 Nov 2024 12:47:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org C437E3857713 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 C437E3857713 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=1732193272; cv=none; b=JhAUS60lvR0xn7Zz9C7ZyvVNVH1u1lvF8CxOvfBpRqIf9jrzy9L2DnUpCwoFVnIvW7teRCVxOGF4SmmOfGH0WBJ9tC4CEN6ZdHjH9JadsfezU6S+t4J65tVfgjg39GBO1DqexU4n7UFM7CtT4QGEPLGLYKTorr/+zxfVEivNVdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1732193272; c=relaxed/simple; bh=emloKBvQgQ+0qfhc6o7dxkYw2dVDctkwx7njUGMIS0c=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=S73OCV9jUPe8b2Y9jJQ1KGjmxyLMLxv/PYkcwgDjseo2q2Bvwu+Y4PyGRg86S5r+XcC+dDQMuCFgiHUGozL05v232IhMoGdst7FG7cNLusV96tpMaJ/3LEsqVRtWs0+bLq8PXP42YOGHN6BbjQz7YegZzqgKgoA/yTi/fCSQ4Bo= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C437E3857713 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-686-0NqepMh-NuWofKlzFwtCmA-2; Thu, 21 Nov 2024 07:47:51 -0500 X-MC-Unique: 0NqepMh-NuWofKlzFwtCmA-2 X-Mimecast-MFC-AGG-ID: 0NqepMh-NuWofKlzFwtCmA 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:50 +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:50 +0000 From: Jan Vrany <jan.vrany@labware.com> To: gdb-patches@sourceware.org CC: Jan Vrany <jan.vrany@labware.com> Subject: [RFC v2 06/21] gdb/python: add template function to implement equality comparison Date: Thu, 21 Nov 2024 12:46:59 +0000 Message-ID: <20241121124714.419946-7-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: LO4P123CA0022.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:151::9) 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: 61abcf20-aded-474c-e277-08dd0a2ab4fc 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: u4zX+mxKBdFueOnt4VOpK9LP8yV+XB4ZYEh6JHcPnV3SWiQUdczwtty7mXoL8eaMY5cpBijjCjNi2W/Gid1ZFYoqlllCI8U9OeJXURWhsUWX7CFY4rBL86tyVrb2of0fkHMn3DIGKbYtbWipCi3od9dBS0l9UVo60hr0LF7Gi99sUH5uOJ6gpvqmTCQCtKM4eytFSTfNiYbX/agBqNuxgDqMOJ3BOjJkekEVLGBteB9Yt64suv40oa13R3iJufTn0ylXy3tMzJHVg8LUpYFUcnwmz2OTucBu9BsSRVBOi6uO9fIqSONvxHOF81ErygDZH8k4sflUCgGN6A3JPxUswh2qLV3MygSZLZQvBuZdZxzS5LJ4Q+/unwgK2cGzS/VgqSrEU+9RUDel3x2rgdFYYqWayyKBgF0MSaB7z/nLlr+vKSpxwaZ1mpqACkN7b6nKp9ZW/3nY9P9+qOV9HbGQ73N17Geujjt4mLSPiS4yTNJiORiEOQzfadtNTJTbPcjrSX0M+GSRQUQXCzzCnpRh2Jle1/AEz6uKtJR4NEorPoHyMmP6h16peIEIADACHI0vQmP7L7MAtNddSuwFTGAaQm+c4p+4GWiq3ZdHFzMWJ7mbbYz7pZ1VXV1zJuXOWImmPZ0vrnI0AEmZLmd+4hGU9j71xl6a13h1v6yhpkRmLZOHzyakBeavAzosDTOlPzcmaJ3NqnsGY5OLSnfTnzgdDI5PpwHMF/3L1PXXKA7ORAOm/8a40lm4mk/51Co77fHQAXiuaJrpjdCAzjIvtVOqw7zYa40fc1cLOpzOmhbOB4aLlvzXpPlYfovQBdtKpiVaGBAy6VzFu/4G6PxRNIQI4CacFzLHN+Mx40l08RsIUy44JE4vfOKg3/EPsY23kg3c38Okow0bWXSuZzLpg9BO3C1Gbs4UlvANc0dkFx+9WVzzLO2xouzfhPGNdcGjXj8PMTXnEmjEcUQESvmRLKYbKs5HHzsM8SjHnMfcCp9jbTrufMESozE0yxO1e82LubZpMzToY3npNJ5m2zBZAGyetY+gvalwHVecxtC+leMLTBHyrax2Zu/q8Uzj4mEIWdzOvnDu/PF/rtIhVFz+anIEWIooEmy1zoU9Envc18hOtIxIyXRKFIM0La1LYgEz0tpk8N+9OQ1JAP8EHLlAYBSnxzd7OZxG4is1jweh9gZ0ADdo69SKUlEQ/9bbWBRxw9vN4DjAHrrfLrCxOVIhVznqutbn+v63bBlDmpycQGm7AwtTME1CRXewwbiLsQoXwoTfL9ZGyAQx1tkkGXPyeQ7PL4nwG/K60nsXDd1TLSr88avkjbAKHjZe/RJhS3d3TOhJ 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: 48z/x/ltT49pDbbbHr3MSUYQni9XGp/RivQMh79DgIw2R4j3qxYS6TM+aMzXDdgVGedcFCQ54lOzZWaeSi4iSxiBBDnn3BbPWagAfOHp7407jxIFeoUjIlxUV7r7SMoxOQD5hLsn9L2DwM4QaKh56lwdEorUNkz4LfOnHeqOOd7FkOlSQLX417YXINVDob8AwszaNnmJWFRhQkRZtwmxVRRLjmw6F54SpDSHUD4KQo2JebEylvGyvMxEztoqGMEjtLw4UiEUD/kAJafM9Xl+5mcDTJQ7zAdAqWP16mOrylFQF9aOwfd0Zdx9EJdScFkKXsVUKAv5VSi8LjHEt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JgW0Xwsuha+o6JjYBbov0+1QuJtA53WMwJsxSXgaKQun0AR7rVQJAEw6IKFpbyFBakpKyu09aUIHenu0VV9KvrlZwYavxyfGxS6OFVRQ3vm1ZlKx+sBDz32BUtNa4dYphk+j37Gp2kNpd/fWr3OeX2FSW5jA5b22p5h7dp83ceXaWRTt6RZbMKOq X-OriginatorOrg: labware.com X-MS-Exchange-CrossTenant-Network-Message-Id: 61abcf20-aded-474c-e277-08dd0a2ab4fc 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:49.9993 (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: kY6mVbBNFqnqX1Tn+m0C0XOjiPxHqgICZ2LJ5xwhD1YFTCiQHAwCzYOGkCM38fsTP3jDdqRqK4mc54k/ScjhIQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR17MB6504 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 6Ng5dRkBxOe-mpKtkqY-tH3Fw76_YlaG8K8mKtyySE8_1732193271 X-Mimecast-Originator: labware.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=WINDOWS-1252 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 <gdb-patches.sourceware.org> List-Unsubscribe: <https://sourceware.org/mailman/options/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=unsubscribe> List-Archive: <https://sourceware.org/pipermail/gdb-patches/> List-Post: <mailto:gdb-patches@sourceware.org> List-Help: <mailto:gdb-patches-request@sourceware.org?subject=help> List-Subscribe: <https://sourceware.org/mailman/listinfo/gdb-patches>, <mailto:gdb-patches-request@sourceware.org?subject=subscribe> Errors-To: gdb-patches-bounces~patchwork=sourceware.org@sourceware.org |
Series |
Add Python "JIT" API
|
|
Checks
Context | Check | Description |
---|---|---|
linaro-tcwg-bot/tcwg_gdb_build--master-arm | warning | Skipped upon request |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 | warning | Skipped upon request |
Commit Message
Jan Vraný
Nov. 21, 2024, 12:46 p.m. UTC
This commit adds gdbpy_richcompare template to implement "default" equality and non-equality comparison for GDB Python objects. The "default" behavior is to consider two GDB Python objects as equal if both refer to the same underlying GDB structure. --- gdb/python/python-internal.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)
diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index d723c4d577b..4d4810dc4cc 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -1145,4 +1145,37 @@ gdbpy_type_ready (PyTypeObject *type, PyObject *mod = nullptr) # define PyType_Ready POISONED_PyType_Ready #endif +/* Implements default equality and non-equality comparisons for GDB + Python objects. + + All other comparison operators will throw a TypeError Python exception. + + Two Python objects of type P are considered equal if both point to the + same underlying GBB structure of type D. The last template parameter + specifies the member of Python object holding reference to underlying + GBB structure. */ + +template <typename P, typename D, D* P::*data> +PyObject * +gdbpy_richcompare (PyObject *self, PyObject *other, int op) +{ + int result; + + if (!PyObject_TypeCheck (other, self->ob_type) + || (op != Py_EQ && op != Py_NE)) + { + Py_INCREF (Py_NotImplemented); + return Py_NotImplemented; + } + + if ( (P *)self->*data == (P *)other->*data) + result = Py_EQ; + else + result = Py_NE; + + if (op == result) + Py_RETURN_TRUE; + Py_RETURN_FALSE; +} + #endif /* PYTHON_PYTHON_INTERNAL_H */