From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id QWP/IMtChmpFXTEAWB0awg (envelope-from ) for ; Wed, 19 Aug 2026 19:56:59 -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=OgM5dn98; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 83DF31E09B; Wed, 19 Aug 2026 19:56:59 -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 EEAC21E09B for ; Wed, 19 Aug 2026 19:56:58 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 034134B99F7C for ; Wed, 19 Aug 2026 23:56:58 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 034134B99F7C 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=OgM5dn98 Received: from omta036.useast.a.cloudfilter.net (omta036.useast.a.cloudfilter.net [44.202.169.35]) by sourceware.org (Postfix) with ESMTPS id 420354BAE7E9 for ; Wed, 19 Aug 2026 23:54:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 420354BAE7E9 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 420354BAE7E9 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=44.202.169.35 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787183684; cv=none; b=bSk8dUvmCD2kpRb7RDkFkDdtSvNrzguZEGeUXQXJxuwtPiuFlF6oXsxHAk9O7GBJyykyt/kxNO/jnd8XMQEbDroxc9pyp6+UhLokKx9MegC7qU9cujRALMEmUH5mRmOxuYFiQBknGL/y7Agmtax0XmLLW8jkAlBDq2qOdciPBfg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1787183684; c=relaxed/simple; bh=RuPWFR9RMmrk1toDClFvpNa/w2MALKqlPDL9AjOd8aA=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=GsjHMnuim8geM6uLHothEV8X9tBEjYvk0N/o6HU3YAk45cxSpQaVZZYihFqlfI0Z/NAOGtRjSYIPOBnRhwNLC+DvHauFRY8kZt5RYdvIl6F2T3EPFmjjUSU6nyS8PYgNdfuBWp9niZr3n/KeKE4RGT77mRn9UU3D/Wt6aucOqis= 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=OgM5dn98 reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 420354BAE7E9 Received: from eig-obgw-6001b.ext.cloudfilter.net ([10.0.30.143]) by cmsmtp with ESMTPS id wloswb52NLvgbwq7HwtSdm; Wed, 19 Aug 2026 23:54:43 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id wq7GwnbGeUsP9wq7Gwng3d; Wed, 19 Aug 2026 23:54:42 +0000 X-Authority-Analysis: v=2.4 cv=UPvdHDfy c=1 sm=1 tr=0 ts=6a864242 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=ItBw4LHWJt0A:10 a=nDBLIPPFZQZr3xxAARMA: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=KUkk1qTMKzed8KZKuVzJ4vGwxlbtX+X+GjYrjn1KIIk=; b=OgM5dn98JncueIwB7WM3giFHUk JXSYhe+ly/t2R+G7pm175BnZemEBjNw18N0Cumnhnrhiv4w733zxznRhAuOvLQoqqotVlPivp4/vv +6nGCV+ZsLQoIHtCfnZgPb0aq; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:36824 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 1wwq7G-000000020o1-12Hi; Wed, 19 Aug 2026 17:54:42 -0600 From: Tom Tromey Date: Wed, 19 Aug 2026 17:54:41 -0600 Subject: [PATCH 3/4] Convert gdbpy_frame_stop_reason_string to the safety API MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260819-python-safety-frame-v1-3-563cb6b9e7a6@tromey.com> References: <20260819-python-safety-frame-v1-0-563cb6b9e7a6@tromey.com> In-Reply-To: <20260819-python-safety-frame-v1-0-563cb6b9e7a6@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: 1wwq7G-000000020o1-12Hi 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]:36824 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: MS4xfOtWsa73QaHXa9uzs1uIGTFI9pnoM+7AaJPIkBIMCNWIQBRwKm80LfBrRffHbpxSqYs2LcqPSRdg6jem0yLEH6poTB6p3fRUQsiIXdH/7fnC1L6xJpUx HIjCGX8MDH+G9ycftH4qzlCOU6Lgj73xv9qCyH3Gp3kzvC+fv4SESV60fOY/1TJfZeFs+tnOJWYyYP6Qm26Fh+yU8xjTxakYFCQ= 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 converts gdbpy_frame_stop_reason_string to the Python safety API. This changes the function to accept keyword arguments as well, following the outcome of an earlier discussion. A new test is added for this. --- gdb/python/py-frame.c | 20 ++++++++------------ gdb/python/python-internal.h | 3 ++- gdb/python/python.c | 4 ++-- gdb/testsuite/gdb.python/py-frame.exp | 3 +++ 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gdb/python/py-frame.c b/gdb/python/py-frame.c index 3910f19ef83..4dd174cf5ae 100644 --- a/gdb/python/py-frame.c +++ b/gdb/python/py-frame.c @@ -466,24 +466,20 @@ gdbpy_selected_frame () /* Implementation of gdb.stop_reason_string (Integer) -> String. Return a string explaining the unwind stop reason. */ -PyObject * -gdbpy_frame_stop_reason_string (PyObject *self, PyObject *args) +const char * +gdbpy_frame_stop_reason_string (gdbpy_borrowed_ref<> args, + gdbpy_opt_borrowed_ref<> kw) { int reason; - const char *str; - if (!PyArg_ParseTuple (args, "i", &reason)) - return NULL; + static const char *keywords[] = { "reason", nullptr }; + gdbpy_arg_parse_tuple_and_keywords (args, kw, "i", keywords, &reason); if (reason < UNWIND_FIRST || reason > UNWIND_LAST) - { - PyErr_SetString (PyExc_ValueError, - _("Invalid frame stop reason.")); - return NULL; - } + gdbpy_err_set_string (PyExc_ValueError, + _("Invalid frame stop reason.")); - str = unwind_stop_reason_to_string ((enum unwind_stop_reason) reason); - return PyUnicode_Decode (str, strlen (str), host_charset (), NULL); + return unwind_stop_reason_to_string ((enum unwind_stop_reason) reason); } /* Implements the equality comparison for Frame objects. diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 76ccdc6b0c6..5796b80037a 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -465,7 +465,8 @@ extern PyObject *gdbpy_history_count (PyObject *self, PyObject *args); PyObject *gdbpy_convenience_variable (PyObject *self, PyObject *args); PyObject *gdbpy_set_convenience_variable (PyObject *self, PyObject *args); PyObject *gdbpy_breakpoints (PyObject *, PyObject *); -PyObject *gdbpy_frame_stop_reason_string (PyObject *, PyObject *); +const char *gdbpy_frame_stop_reason_string (gdbpy_borrowed_ref<> args, + gdbpy_opt_borrowed_ref<> kw); gdbpy_ref<> gdbpy_lookup_symbol (gdbpy_borrowed_ref<> args, gdbpy_opt_borrowed_ref<> kw); gdbpy_ref<> gdbpy_lookup_global_symbol (gdbpy_borrowed_ref<> args, diff --git a/gdb/python/python.c b/gdb/python/python.c index 72c2d7bb10d..84e7c21377a 100644 --- a/gdb/python/python.c +++ b/gdb/python/python.c @@ -3165,9 +3165,9 @@ Return the newest frame object."), noargs_function ("selected_frame", "selected_frame () -> gdb.Frame.\n\ Return the selected frame object."), - { "frame_stop_reason_string", gdbpy_frame_stop_reason_string, METH_VARARGS, + varargs_function ("frame_stop_reason_string", "stop_reason_string (Integer) -> String.\n\ -Return a string explaining unwind stop reason." }, +Return a string explaining unwind stop reason."), { "start_recording", gdbpy_start_recording, METH_VARARGS, "start_recording ([method] [, format]) -> gdb.Record.\n\ diff --git a/gdb/testsuite/gdb.python/py-frame.exp b/gdb/testsuite/gdb.python/py-frame.exp index aebec651964..30692ed6dd8 100644 --- a/gdb/testsuite/gdb.python/py-frame.exp +++ b/gdb/testsuite/gdb.python/py-frame.exp @@ -137,6 +137,9 @@ gdb_test "python print ('result = %s' % (f0.type () == gdb.NORMAL_FRAME))" " = T gdb_test "python print ('result = %s' % (f0.unwind_stop_reason () == gdb.FRAME_UNWIND_NO_REASON))" \ " = True" "test Frame.unwind_stop_reason" gdb_test "python print ('result = %s' % gdb.frame_stop_reason_string (gdb.FRAME_UNWIND_INNER_ID))" " = previous frame inner to this frame \\(corrupt stack\\?\\)" "test gdb.frame_stop_reason_string" +gdb_test "python print ('result = %s' % gdb.frame_stop_reason_string (reason=gdb.FRAME_UNWIND_INNER_ID))" \ + " = previous frame inner to this frame \\(corrupt stack\\?\\)" \ + "test gdb.frame_stop_reason_string with keyword" gdb_test "python print ('result = %s' % f0.pc ())" " = ${::decimal}" "test Frame.pc" gdb_test "python print ('result = %s' % (f0.older () == f1))" " = True" "test Frame.older" gdb_test "python print ('result = %s' % (f1.newer () == f0))" " = True" "test Frame.newer" -- 2.49.0