From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id XlmnOhmkd2rfFhUAWB0awg (envelope-from ) for ; Sat, 08 Aug 2026 17:48:09 -0400 Authentication-Results: simark.ca; dkim=fail reason="signature verification failed" (768-bit key; unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=ZJDYvoeI; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C7AD91E09B; Sat, 08 Aug 2026 17:48:09 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-5.1 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [IPv6:2620:52:6:3111::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 BD42E1E09B for ; Sat, 08 Aug 2026 17:48:08 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 11C614BA9031 for ; Sat, 8 Aug 2026 21:48:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 11C614BA9031 Authentication-Results: sourceware.org; dkim=fail reason="signature verification failed" (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=ZJDYvoeI Received: from omta038.useast.a.cloudfilter.net (omta038.useast.a.cloudfilter.net [44.202.169.37]) by sourceware.org (Postfix) with ESMTPS id 81A034BA79AC for ; Sat, 8 Aug 2026 21:47:30 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 81A034BA79AC Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=tromey.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tromey.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 81A034BA79AC Authentication-Results: sourceware.org; arc=none smtp.remote-ip=44.202.169.37 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786225650; cv=none; b=fJ3e6xb7eLXvOYLXSATho5TXdE8DETFTugySEZNIK8dF7Ypu6etBXhvoeH++kvvo0pHYZzDf5xZJWVLqneHVI1BRHmrvcSbfVUe36H/LdlQ+VRUBsJVkddVZFvceUG5WK0GFRNDCN0ZWGAMs+8zT4/YDh0+LNDKCtYk1D5AyXbI= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1786225650; c=relaxed/simple; bh=12R4P5DDy56VPJo6P3pXA13Y4WlWq9hJNU9u/nmsaok=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=BGxJSQiKzeS2kl162t49LZ2BsUaktDA+Nx9odcugPnXw6A0ewtP/RK9p5Y1luOZmVITPX2UQ4fi6q/X+3r1cGyE1ecpmObhfwluJV6p24a16YN3UVVPg7zvgEX8mC3B6fVXnrgpC3dmf24xvCapCxK6bJXIlnZcO1b+JVba4o9o= ARC-Authentication-Results: i=1; sourceware.org; dkim=policy (768-bit key, unprotected) header.d=tromey.com header.i=@tromey.com header.a=rsa-sha256 header.s=default header.b=ZJDYvoeI reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 81A034BA79AC Received: from eig-obgw-6002b.ext.cloudfilter.net ([10.0.30.203]) by cmsmtp with ESMTPS id sYE8woMG0JFmFsot7wsgOq; Sat, 08 Aug 2026 21:47:29 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id sot7wCxd8RY4Isot7wdDkp; Sat, 08 Aug 2026 21:47:29 +0000 X-Authority-Analysis: v=2.4 cv=WNl/XmsR c=1 sm=1 tr=0 ts=6a77a3f1 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=ItBw4LHWJt0A:10 a=JveOD6ruaTgE5aeRb9gA:9 a=QEXdDO2ut3YA:10 a=DCx65vhANUyCzuf5D8fC:22 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date:From:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7cwzavCoQ21dBtnTBCfYtPTha0YuY+Mmj1KfTwkJbRI=; b=ZJDYvoeIriAKf3rpa3H+zUs4Zo i2QeC7OmhnnSjdMK58cyKDaPYuf7qLEpbHaM9N9Xd5g9a/zOPuQ98TORMgQPHrFy0cFv3NHAsBKNy HXk3byniT0hAdgsnKSPzeaGQX; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:34168 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.5) (envelope-from ) id 1wsot6-00000001wX6-3A1u; Sat, 08 Aug 2026 15:47:28 -0600 From: Tom Tromey Date: Sat, 08 Aug 2026 15:47:27 -0600 Subject: [PATCH 3/4] Use gdbpy_borrowed_ref when creating events MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260808-python-safety-events-simple-v1-3-132aea40c801@tromey.com> References: <20260808-python-safety-events-simple-v1-0-132aea40c801@tromey.com> In-Reply-To: <20260808-python-safety-events-simple-v1-0-132aea40c801@tromey.com> To: gdb-patches@sourceware.org Cc: Tom Tromey X-Mailer: b4 0.14.3 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - box5379.bluehost.com X-AntiAbuse: Original Domain - sourceware.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - tromey.com X-BWhitelist: no X-Source-IP: 75.166.225.82 X-Source-L: No X-Exim-ID: 1wsot6-00000001wX6-3A1u X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: 75-166-225-82.hlrn.qwest.net ([192.168.122.1]) [75.166.225.82]:34168 X-Source-Auth: tom+tromey.com X-Email-Count: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKyfRtmI3qPE/WADBfezctaI39MVx7vZ8Tybn34pyRKEsr8XrMJnmkQSiu/8txj5h1ylLHbWl6tvyVnPUA4Bm6s3YyB2YbXL3Dc8D4gMx6/su05t1TY8 NuW5aDUDjsPSrWwvCkEo7knRG0JXMLPKw14vzbz8vphglt908+wUQYf7enlG+Wa0ZN7YnNdVUHxZ1MiBuZQHUfloWABfPXe2XU4= 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 changes create_thread_event_object and create_breakpoint_event_object to accept gdbpy_borrowed_ref. This allows the removal of some calls to "get". --- gdb/python/py-bpevent.c | 3 ++- gdb/python/py-continueevent.c | 2 +- gdb/python/py-event.h | 2 +- gdb/python/py-inferior.c | 3 +-- gdb/python/py-stopevent.c | 2 +- gdb/python/py-stopevent.h | 7 ++++--- gdb/python/py-threadevent.c | 4 ++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/gdb/python/py-bpevent.c b/gdb/python/py-bpevent.c index 20a7745e4cc..2fcaac76c4e 100644 --- a/gdb/python/py-bpevent.c +++ b/gdb/python/py-bpevent.c @@ -24,7 +24,8 @@ gdbpy_ref<> create_breakpoint_event_object (const gdbpy_ref<> &dict, - PyObject *breakpoint_list, PyObject *first_bp) + gdbpy_borrowed_ref<> breakpoint_list, + gdbpy_borrowed_ref<> first_bp) { gdbpy_ref<> breakpoint_event_obj = create_stop_event_object (&breakpoint_event_object_type, dict); diff --git a/gdb/python/py-continueevent.c b/gdb/python/py-continueevent.c index 06d4dabadd9..48c24cc710d 100644 --- a/gdb/python/py-continueevent.c +++ b/gdb/python/py-continueevent.c @@ -36,7 +36,7 @@ create_continue_event_object (ptid_t ptid) return nullptr; return create_thread_event_object (&continue_event_object_type, - py_thr.get ()); + py_thr); } /* Callback function which notifies observers when a continue event occurs. diff --git a/gdb/python/py-event.h b/gdb/python/py-event.h index 2c724c9a084..100840318a5 100644 --- a/gdb/python/py-event.h +++ b/gdb/python/py-event.h @@ -74,7 +74,7 @@ extern gdbpy_ref<> create_event_object (PyTypeObject *py_type); extern gdbpy_ref<> py_get_event_thread (ptid_t ptid); extern gdbpy_ref<> create_thread_event_object (PyTypeObject *py_type, - PyObject *thread); + gdbpy_borrowed_ref<> thread); extern int emit_new_objfile_event (struct objfile *objfile); extern int emit_free_objfile_event (struct objfile *objfile); diff --git a/gdb/python/py-inferior.c b/gdb/python/py-inferior.c index ab3a95da1bf..dd2a3a0da24 100644 --- a/gdb/python/py-inferior.c +++ b/gdb/python/py-inferior.c @@ -333,8 +333,7 @@ add_thread_object (struct thread_info *tp) return; gdbpy_ref<> event = create_thread_event_object - (&new_thread_event_object_type, - (PyObject *) ins_result.first->second.get ()); + (&new_thread_event_object_type, ins_result.first->second); if (event == NULL || evpy_emit_event (event, gdb_py_events.new_thread) < 0) diff --git a/gdb/python/py-stopevent.c b/gdb/python/py-stopevent.c index 3f07f8a29fb..cdb1ad3fc50 100644 --- a/gdb/python/py-stopevent.c +++ b/gdb/python/py-stopevent.c @@ -28,7 +28,7 @@ create_stop_event_object (PyTypeObject *py_type, const gdbpy_ref<> &dict) if (thread == nullptr) return nullptr; - gdbpy_ref<> result = create_thread_event_object (py_type, thread.get ()); + gdbpy_ref<> result = create_thread_event_object (py_type, thread); if (result == nullptr) return nullptr; diff --git a/gdb/python/py-stopevent.h b/gdb/python/py-stopevent.h index f9a14fe00c1..7b36825019c 100644 --- a/gdb/python/py-stopevent.h +++ b/gdb/python/py-stopevent.h @@ -28,9 +28,10 @@ extern gdbpy_ref<> create_stop_event_object (PyTypeObject *py_type, extern int emit_stop_event (struct bpstat *bs, enum gdb_signal stop_signal); -extern gdbpy_ref<> create_breakpoint_event_object (const gdbpy_ref<> &dict, - PyObject *breakpoint_list, - PyObject *first_bp); +extern gdbpy_ref<> create_breakpoint_event_object + (const gdbpy_ref<> &dict, + gdbpy_borrowed_ref<> breakpoint_list, + gdbpy_borrowed_ref<> first_bp); extern gdbpy_ref<> create_signal_event_object (const gdbpy_ref<> &dict, enum gdb_signal stop_signal); diff --git a/gdb/python/py-threadevent.c b/gdb/python/py-threadevent.c index 9b0a963d0ba..a4a0c16dffc 100644 --- a/gdb/python/py-threadevent.c +++ b/gdb/python/py-threadevent.c @@ -37,7 +37,7 @@ py_get_event_thread (ptid_t ptid) } gdbpy_ref<> -create_thread_event_object (PyTypeObject *py_type, PyObject *thread) +create_thread_event_object (PyTypeObject *py_type, gdbpy_borrowed_ref<> thread) { gdb_assert (thread != NULL); @@ -65,7 +65,7 @@ emit_thread_exit_event (thread_info * thread) return -1; auto inf_thr = create_thread_event_object (&thread_exited_event_object_type, - py_thr.get ()); + py_thr); if (inf_thr == nullptr) return -1; -- 2.49.0