From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id qZoJMfKDSWqIASgAWB0awg (envelope-from ) for ; Sat, 04 Jul 2026 18:06:42 -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=SMHEgYti; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id C4CC21E098; Sat, 04 Jul 2026 18:06:42 -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 575BA1E024 for ; Sat, 04 Jul 2026 18:06:42 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D75614BA5434 for ; Sat, 4 Jul 2026 22:06:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D75614BA5434 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=SMHEgYti Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id 12A644BA7983 for ; Sat, 4 Jul 2026 22:05:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 12A644BA7983 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 12A644BA7983 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.33 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783202725; cv=none; b=otP70ZbsgDpxB/yao8hHBpi7CjZ12lZ8FazHf3gkOLm88l7nN+NOOrNok0+gBfLaSYzfxGerirUoIAI5dB3zLPJ6+b9ChfbFuPgBpmu2nzkWN/MEBgfgam8eS3T15CBHQ5vYys8clVJm1vCdHVIyJR9uiBlnzvL6E1HC5ycooqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783202725; c=relaxed/simple; bh=AJO73mOsmVepAzMfxlgAe8mcFiCSywa67oMqiF1jNno=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=EpDQq4TwDdV7CiiHDVwGTllV6XUXYYlivyu3ykiZpvzq/X58DjG9gwhWT1qcIckNeAZcFwbq3Fx4ydFyEaTrKEn97ZVloKk/8bgSVAAiYcunH0v7bPgFYBGRPeeAqVsHuc9sP89DBRsdWr/0wb4XWR9XxdzMPPSkSRq/67606oU= 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=SMHEgYti reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 12A644BA7983 Received: from eig-obgw-5005b.ext.cloudfilter.net ([10.0.29.189]) by cmsmtp with ESMTPS id fuM8wAvyVlPo5g8UFwX2st; Sat, 04 Jul 2026 22:05:24 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id g8UEwaAzeFb3lg8UFwWeHo; Sat, 04 Jul 2026 22:05:23 +0000 X-Authority-Analysis: v=2.4 cv=Xo36OUF9 c=1 sm=1 tr=0 ts=6a4983a3 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=ItBw4LHWJt0A:10 a=lt16q1Y-uoR62ZU8mgwA: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=aJA1D0JbPp9PYZjllsbqbDcX0wooBSyGQ8jmo0fjheg=; b=SMHEgYti4ltN9fQhcFqdEw5Lp2 M1eya/jYa6r0pODE+tnMwo+ox0Piwbfi18F80mLhSW7GfnnqqdDAz5LvLzjfTUSi2MtkIwWzLY4zn l+sONZRMHXeCNeiUEmHwZHTyp; Received: from 75-166-225-82.hlrn.qwest.net ([75.166.225.82]:38412 helo=[192.168.122.1]) by box5379.bluehost.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.99.2) (envelope-from ) id 1wg8UE-00000000OSH-2K1d; Sat, 04 Jul 2026 16:05:22 -0600 From: Tom Tromey Date: Sat, 04 Jul 2026 16:05:18 -0600 Subject: [PATCH 4/9] Return a const reference from gdbpy_get_print_options MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260704-print-opts-cleanup-v1-4-fb54a5112a8d@tromey.com> References: <20260704-print-opts-cleanup-v1-0-fb54a5112a8d@tromey.com> In-Reply-To: <20260704-print-opts-cleanup-v1-0-fb54a5112a8d@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: 1wg8UE-00000000OSH-2K1d 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]:38412 X-Source-Auth: tom+tromey.com X-Email-Count: 5 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfKKTid4L16vFusf/zB2SPNBTEziY4a9ZVHattX+fL3hC4S146OVm/6UdCbYxZoJIR1H1/Aps5BMIugzLKyTImFnn77PgkKKcglVmNkB8iAt62fByY3uN Cf52q7dtprtDJ+VniI9vJicA/MZGxx2BJlH6Mrtk/ajSK18cQbtY1DaMa40JYlfg/MswbDbjCAJJ6jxoqR/VEbPb2DFV6D9uMWk= 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 gdbpy_get_print_options to return a const reference to the relevant value_print_options. --- gdb/python/py-prettyprint.c | 11 +++++------ gdb/python/py-value.c | 7 ++----- gdb/python/python-internal.h | 2 +- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index 1326aaae476..a89bf073215 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -718,8 +718,7 @@ gdbpy_print_options (PyObject *unused1, PyObject *unused2) if (result == nullptr) return nullptr; - value_print_options opts; - gdbpy_get_print_options (&opts); + const value_print_options &opts = gdbpy_get_print_options (); if (set_boolean (result.get (), "raw", opts.raw) < 0 @@ -770,13 +769,13 @@ gdbpy_print_options (PyObject *unused1, PyObject *unused2) /* Helper function that either finds the prevailing print options, or calls get_user_print_options. */ -void -gdbpy_get_print_options (value_print_options *opts) +const value_print_options & +gdbpy_get_print_options () { if (gdbpy_current_print_options != nullptr) - *opts = *gdbpy_current_print_options; + return *gdbpy_current_print_options; else - *opts = get_user_print_options (); + return get_user_print_options (); } /* A ValuePrinter is just a "tag", so it has no state other than that diff --git a/gdb/python/py-value.c b/gdb/python/py-value.c index 5b38110396e..a63af395e2c 100644 --- a/gdb/python/py-value.c +++ b/gdb/python/py-value.c @@ -690,8 +690,7 @@ valpy_format_string (PyObject *self, PyObject *args, PyObject *kw) return NULL; } - struct value_print_options opts; - gdbpy_get_print_options (&opts); + value_print_options opts = gdbpy_get_print_options (); opts.deref_ref = false; /* We need objects for booleans as the "p" flag for bools is new in @@ -1248,9 +1247,7 @@ valpy_call (PyObject *self, PyObject *args, PyObject *keywords) static PyObject * valpy_str (PyObject *self) { - struct value_print_options opts; - - gdbpy_get_print_options (&opts); + value_print_options opts = gdbpy_get_print_options (); opts.deref_ref = false; string_file stb; diff --git a/gdb/python/python-internal.h b/gdb/python/python-internal.h index 4ca28bb6957..f9899740a5f 100644 --- a/gdb/python/python-internal.h +++ b/gdb/python/python-internal.h @@ -974,7 +974,7 @@ gdb::unique_xmalloc_ptr gdbpy_get_display_hint (PyObject *printer); PyObject *gdbpy_default_visualizer (PyObject *self, PyObject *args); PyObject *gdbpy_print_options (PyObject *self, PyObject *args); -void gdbpy_get_print_options (value_print_options *opts); +const value_print_options &gdbpy_get_print_options (); extern const struct value_print_options *gdbpy_current_print_options; void bpfinishpy_pre_stop_hook (struct gdbpy_breakpoint_object *bp_obj); -- 2.49.0