From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 2WJxIe6DSWpIASgAWB0awg (envelope-from ) for ; Sat, 04 Jul 2026 18:06:38 -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=NtlbaI+x; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 845731E098; Sat, 04 Jul 2026 18:06:38 -0400 (EDT) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on simark.ca X-Spam-Level: X-Spam-Status: No, score=-3.8 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_00, DKIM_INVALID,DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=4.0.1 Received: from vm01.sourceware.org (vm01.sourceware.org [38.145.34.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 11FBB1E024 for ; Sat, 04 Jul 2026 18:06:37 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9BDFE4BA903A for ; Sat, 4 Jul 2026 22:06:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 9BDFE4BA903A 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=NtlbaI+x Received: from omta40.uswest2.a.cloudfilter.net (omta40.uswest2.a.cloudfilter.net [35.89.44.39]) by sourceware.org (Postfix) with ESMTPS id 077714BA23E3 for ; Sat, 4 Jul 2026 22:05:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 077714BA23E3 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 077714BA23E3 Authentication-Results: sourceware.org; arc=none smtp.remote-ip=35.89.44.39 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783202724; cv=none; b=ldDzVl3+yWh6lTMnTE8prGZL+t9GWxKoCWQcmJqbvr4D8UKKFt+Y8ySEzanVm63mK4Y+wJw2P2CS/g3YQ0OVik/AUi3pZrRZa7fwI2xyEnd9hhAu/wagjWeGaOfkFJcsCu5PX6bwif+SY8NerWUpC08UuIl+08qcNiluKC+owqc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783202724; c=relaxed/simple; bh=X2mmbEwH4gbYMczzPLyJ8ITY4FkVpYzgllSKCVnlDak=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=mxX1UKxtnEmScTHd+QW2bPMS721m8DpLieP3t6v9reVq8S6U0IvmA8C52Ij5sEASuP39oo9j+XKYYA4T80aymLOHm0ewheNCJG9y+qlc0bP+VRRS+MGNQx8xkpUtqD/ud25LOw61aCx0F1RjE0NbvEpWRaeWxm4q5Nk26JCDRhg= 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=NtlbaI+x reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 077714BA23E3 Received: from eig-obgw-6003b.ext.cloudfilter.net ([10.0.30.175]) by cmsmtp with ESMTPS id g1qWwhtcajgweg8UFwe6vC; Sat, 04 Jul 2026 22:05:23 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id g8UEwCt10wn18g8UEwa2Id; Sat, 04 Jul 2026 22:05:22 +0000 X-Authority-Analysis: v=2.4 cv=ZbYdNtVA c=1 sm=1 tr=0 ts=6a4983a2 a=ApxJNpeYhEAb1aAlGBBbmA==:117 a=ApxJNpeYhEAb1aAlGBBbmA==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=ItBw4LHWJt0A:10 a=hC8eLcvWJCXpj1SUnswA: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=c2g3Ehe2MORtT6xoXxa7IjgNKEGJ41llsPHlmFk1gqI=; b=NtlbaI+xkavshcMYpetSak698E yIOswAXAdJvrm0/FCU9x3iQGts+Y5b0FiZY2ZdUErshAHNvDT7KSkWS+PzkhFl2B/SJDuFQ2RV3GU HgGFRw7jA7++axYt9b8ziFb4q; 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-0vPs; Sat, 04 Jul 2026 16:05:22 -0600 From: Tom Tromey Date: Sat, 04 Jul 2026 16:05:17 -0600 Subject: [PATCH 3/9] Convert get_user_print_options MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260704-print-opts-cleanup-v1-3-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-0vPs 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: 4 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfNM5kdgd5cTl2NFsv5gcs0nGSlxv4XvkJm6CQxdCtqxhSDerpVCeb+F4siIBxPwdC46UeMeXFPMYEo0D87HrLnC4WDAZ7P6dxypYcIB+/2bnAcMywBs+ O4njsSpVgXCdA6C0tv4dazRQ4E/cIVimZG5h1IxZuux1yKYiwZheuMq7uutIxiJJcxX3alsLdEJD+lvjRvhwEMXRv3mVmL6iuFA= 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 get_user_print_options to return a const reference to the global user print options. This is maybe slightly more efficient in some cases, though probably not anywhere that matters. --- gdb/ada-lang.c | 3 +-- gdb/auxv.c | 4 +--- gdb/break-catch-exec.c | 4 +--- gdb/break-catch-fork.c | 3 +-- gdb/break-catch-load.c | 3 +-- gdb/break-catch-sig.c | 4 +--- gdb/break-catch-syscall.c | 3 +-- gdb/break-catch-throw.c | 3 +-- gdb/breakpoint.c | 18 +++++------------- gdb/c-varobj.c | 6 ++---- gdb/compile/compile.c | 3 +-- gdb/eval.c | 3 +-- gdb/f-valprint.c | 4 +--- gdb/gnu-v3-abi.c | 9 +++------ gdb/guile/scm-value.c | 6 ++---- gdb/infcmd.c | 9 +++------ gdb/linux-thread-db.c | 4 +--- gdb/mi/mi-main.c | 3 +-- gdb/printcmd.c | 8 +++----- gdb/python/py-framefilter.c | 14 ++++---------- gdb/python/py-lazy-string.c | 3 +-- gdb/python/py-prettyprint.c | 2 +- gdb/python/py-unwind.c | 3 +-- gdb/record-full.c | 3 +-- gdb/riscv-tdep.c | 5 ++--- gdb/skip.c | 3 --- gdb/stack.c | 7 ++----- gdb/tracepoint.c | 4 +--- gdb/typeprint.c | 3 +-- gdb/valprint.c | 7 ------- gdb/valprint.h | 10 ++++++++-- gdb/value.c | 11 +++-------- gdb/varobj.c | 4 +--- 33 files changed, 57 insertions(+), 122 deletions(-) diff --git a/gdb/ada-lang.c b/gdb/ada-lang.c index 35ebd924021..74a35332bee 100644 --- a/gdb/ada-lang.c +++ b/gdb/ada-lang.c @@ -12410,9 +12410,8 @@ bool ada_catchpoint::print_one (const bp_location **last_loc) const { struct ui_out *uiout = current_uiout; - struct value_print_options opts; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (opts.addressprint) uiout->field_skip ("addr"); diff --git a/gdb/auxv.c b/gdb/auxv.c index 1a58fd8c844..206406f8175 100644 --- a/gdb/auxv.c +++ b/gdb/auxv.c @@ -442,9 +442,7 @@ fprint_auxv_entry (struct ui_file *file, const char *name, break; case AUXV_FORMAT_STR: { - struct value_print_options opts; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (opts.addressprint) gdb_printf (file, ("%s "), paddress (arch, val)); val_print_string (builtin_type (arch)->builtin_char, diff --git a/gdb/break-catch-exec.c b/gdb/break-catch-exec.c index 4fbe5e4f067..4e37bca585b 100644 --- a/gdb/break-catch-exec.c +++ b/gdb/break-catch-exec.c @@ -111,10 +111,8 @@ exec_catchpoint::print_it (const bpstat *bs) const bool exec_catchpoint::print_one (const bp_location **last_loc) const { - struct value_print_options opts; struct ui_out *uiout = current_uiout; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* Field 4, the address, is omitted (which makes the columns not line up too nicely with the headers, but the effect diff --git a/gdb/break-catch-fork.c b/gdb/break-catch-fork.c index be00c15adeb..7af329ff7e3 100644 --- a/gdb/break-catch-fork.c +++ b/gdb/break-catch-fork.c @@ -137,10 +137,9 @@ fork_catchpoint::print_it (const bpstat *bs) const bool fork_catchpoint::print_one (const bp_location **last_loc) const { - struct value_print_options opts; struct ui_out *uiout = current_uiout; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* Field 4, the address, is omitted (which makes the columns not line up too nicely with the headers, but the effect is relatively diff --git a/gdb/break-catch-load.c b/gdb/break-catch-load.c index 30bdd0604a7..5492a56b423 100644 --- a/gdb/break-catch-load.c +++ b/gdb/break-catch-load.c @@ -158,10 +158,9 @@ solib_catchpoint::print_it (const bpstat *bs) const bool solib_catchpoint::print_one (const bp_location **locs) const { - struct value_print_options opts; struct ui_out *uiout = current_uiout; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* Field 4, the address, is omitted (which makes the columns not line up too nicely with the headers, but the effect is relatively readable). */ diff --git a/gdb/break-catch-sig.c b/gdb/break-catch-sig.c index ea85083b6f8..15ff2c5c8ac 100644 --- a/gdb/break-catch-sig.c +++ b/gdb/break-catch-sig.c @@ -214,10 +214,8 @@ signal_catchpoint::print_it (const bpstat *bs) const bool signal_catchpoint::print_one (const bp_location **last_loc) const { - struct value_print_options opts; struct ui_out *uiout = current_uiout; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* Field 4, the address, is omitted (which makes the columns not line up too nicely with the headers, but the effect diff --git a/gdb/break-catch-syscall.c b/gdb/break-catch-syscall.c index 1a0bb931080..a2a68b22d0c 100644 --- a/gdb/break-catch-syscall.c +++ b/gdb/break-catch-syscall.c @@ -229,10 +229,9 @@ syscall_catchpoint::print_it (const bpstat *bs) const bool syscall_catchpoint::print_one (const bp_location **last_loc) const { - struct value_print_options opts; struct ui_out *uiout = current_uiout; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* Field 4, the address, is omitted (which makes the columns not line up too nicely with the headers, but the effect is relatively readable). */ diff --git a/gdb/break-catch-throw.c b/gdb/break-catch-throw.c index 03d8c5f772d..be4ff2a43a0 100644 --- a/gdb/break-catch-throw.c +++ b/gdb/break-catch-throw.c @@ -255,10 +255,9 @@ exception_catchpoint::print_it (const bpstat *bs) const bool exception_catchpoint::print_one (const bp_location **last_loc) const { - struct value_print_options opts; struct ui_out *uiout = current_uiout; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (opts.addressprint) uiout->field_skip ("addr"); diff --git a/gdb/breakpoint.c b/gdb/breakpoint.c index e4df4df04a7..68811ed57da 100644 --- a/gdb/breakpoint.c +++ b/gdb/breakpoint.c @@ -5038,8 +5038,7 @@ watchpoint_value_print (struct value *val, struct ui_file *stream) fprintf_styled (stream, metadata_style.style (), _("")); else { - struct value_print_options opts; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); value_print (val, stream, &opts); } } @@ -6591,9 +6590,7 @@ print_one_breakpoint_location (struct breakpoint *b, struct ui_out *uiout = current_uiout; bool header_of_multiple = false; bool part_of_multiple = (loc != NULL); - struct value_print_options opts; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); gdb_assert (!loc || loc_number != 0); /* See comment in print_one_breakpoint concerning treatment of @@ -7081,13 +7078,11 @@ breakpoint_1 (const char *bp_num_list, bool show_internal, { const bp_location *last_loc = nullptr; int nr_printable_breakpoints; - struct value_print_options opts; int print_address_bits = 0; int print_type_col_width = 14; struct ui_out *uiout = current_uiout; bool has_disabled_by_cond_location = false; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* Compute the number of rows in the table, as well as the size required for address fields. */ @@ -9653,13 +9648,12 @@ ranged_breakpoint::print_it (const bpstat *bs) const bool ranged_breakpoint::print_one (const bp_location **last_loc) const { - struct value_print_options opts; struct ui_out *uiout = current_uiout; /* Ranged breakpoints have only one location. */ gdb_assert (this->has_single_location ()); - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (opts.addressprint) /* We don't print the address range here, it will be printed later @@ -11840,9 +11834,7 @@ bpstat_remove_bp_location (bpstat *bps, struct breakpoint *bpt) void code_breakpoint::say_where () const { - struct value_print_options opts; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* i18n: cagney/2005-02-11: Below needs to be merged into a single string. */ diff --git a/gdb/c-varobj.c b/gdb/c-varobj.c index 9428ce08ae2..5312eccdaca 100644 --- a/gdb/c-varobj.c +++ b/gdb/c-varobj.c @@ -558,12 +558,11 @@ cplus_number_of_children (const struct varobj *var) struct type *type; int children, dont_know; int lookup_actual_type = 0; - struct value_print_options opts; dont_know = 1; children = 0; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (!CPLUS_FAKE_CHILD (var)) { @@ -681,7 +680,6 @@ cplus_describe_child (const struct varobj *parent, int index, int lookup_actual_type = 0; const char *parent_expression = NULL; const struct varobj *var; - struct value_print_options opts; if (cname) *cname = std::string (); @@ -692,7 +690,7 @@ cplus_describe_child (const struct varobj *parent, int index, if (cfull_expression) *cfull_expression = std::string (); - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); var = (CPLUS_FAKE_CHILD (parent)) ? parent->parent : parent; if (opts.objectprint) diff --git a/gdb/compile/compile.c b/gdb/compile/compile.c index 4a027de2625..7a60bd33a64 100644 --- a/gdb/compile/compile.c +++ b/gdb/compile/compile.c @@ -271,11 +271,10 @@ static void compile_print_command (const char *arg, int from_tty) { enum compile_i_scope_types scope = COMPILE_I_PRINT_ADDRESS_SCOPE; - value_print_options print_opts; scoped_restore save_async = make_scoped_restore (¤t_ui->async, 0); - get_user_print_options (&print_opts); + value_print_options print_opts = get_user_print_options (); /* Override global settings with explicit options, if any. */ auto group = make_value_print_options_def_group (&print_opts); gdb::option::process_options diff --git a/gdb/eval.c b/gdb/eval.c index 7e07765c9e6..d5d4963e374 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1250,9 +1250,8 @@ eval_op_structop_ptr (struct type *expect_type, struct expression *exp, struct type *real_type; int full, using_enc; LONGEST top; - struct value_print_options opts; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (opts.objectprint && arg_type->target_type () && (arg_type->target_type ()->code () == TYPE_CODE_STRUCT)) { diff --git a/gdb/f-valprint.c b/gdb/f-valprint.c index 8a383281a6c..f91c585fc0b 100644 --- a/gdb/f-valprint.c +++ b/gdb/f-valprint.c @@ -622,9 +622,7 @@ static void info_common_command_for_block (const struct block *block, const char *comname, int *any_printed) { - struct value_print_options opts; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); for (struct symbol *sym : block_iterator_range (block)) if (sym->domain () == COMMON_BLOCK_DOMAIN) diff --git a/gdb/gnu-v3-abi.c b/gdb/gnu-v3-abi.c index 35910be0f06..2ca29ef77d3 100644 --- a/gdb/gnu-v3-abi.c +++ b/gdb/gnu-v3-abi.c @@ -683,9 +683,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents, } else { - struct value_print_options opts; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); print_address_demangle (&opts, gdbarch, ptr_value, stream, demangle); } @@ -872,7 +870,7 @@ compute_vtable_size (vtable_hash_t &offset_hash, struct value *value) static void print_one_vtable (struct gdbarch *gdbarch, struct value *value, int max_voffset, - struct value_print_options *opts) + const value_print_options *opts) { int i; struct type *type = check_typedef (value->type ()); @@ -930,7 +928,6 @@ gnuv3_print_vtable (struct value *value) struct gdbarch *gdbarch; struct type *type; struct value *vtable; - struct value_print_options opts; int count; value = coerce_ref (value); @@ -941,7 +938,7 @@ gnuv3_print_vtable (struct value *value) type = check_typedef (value->type ()); } - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* Respect 'set print object'. */ if (opts.objectprint) diff --git a/gdb/guile/scm-value.c b/gdb/guile/scm-value.c index 6eaf486af07..fb739c370ef 100644 --- a/gdb/guile/scm-value.c +++ b/gdb/guile/scm-value.c @@ -143,12 +143,11 @@ static int vlscm_print_value_smob (SCM self, SCM port, scm_print_state *pstate) { value_smob *v_smob = (value_smob *) SCM_SMOB_DATA (self); - struct value_print_options opts; if (pstate->writingp) gdbscm_printf (port, "#<%s ", value_smob_name); - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.deref_ref = false; /* pstate->writingp = zero if invoked by display/~A, and nonzero if @@ -1266,9 +1265,8 @@ gdbscm_value_print (SCM self) value_smob *v_smob = vlscm_get_value_smob_arg_unsafe (self, SCM_ARG1, FUNC_NAME); struct value *value = v_smob->value; - struct value_print_options opts; - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.deref_ref = false; string_file stb; diff --git a/gdb/infcmd.c b/gdb/infcmd.c index eb7b4efa2a0..90a49eff8be 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -1650,9 +1650,7 @@ print_return_value_1 (struct ui_out *uiout, struct return_value_info *rv) if (finish_print) { - struct value_print_options opts; - get_user_print_options (&opts); - + const value_print_options opts = get_user_print_options (); string_file stb; value_print (rv->value, &stb, &opts); uiout->field_stream ("return-value", stb); @@ -2419,11 +2417,10 @@ default_print_one_register_info (struct ui_file *file, if (regtype->code () == TYPE_CODE_FLT || regtype->code () == TYPE_CODE_DECFLOAT) { - struct value_print_options opts; const gdb_byte *valaddr = val->contents_for_printing ().data (); enum bfd_endian byte_order = type_byte_order (regtype); - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.deref_ref = true; common_val_print (val, &format_stream, 0, &opts, current_language); @@ -2448,7 +2445,7 @@ default_print_one_register_info (struct ui_file *file, if (print_raw_format && regtype->is_vector () == 0) { pad_to_column (format_stream, value_column_2); - get_user_print_options (&opts); + opts = get_user_print_options (); opts.deref_ref = true; common_val_print (val, &format_stream, 0, &opts, current_language); } diff --git a/gdb/linux-thread-db.c b/gdb/linux-thread-db.c index 5e506c4f497..bbeed776f70 100644 --- a/gdb/linux-thread-db.c +++ b/gdb/linux-thread-db.c @@ -698,9 +698,7 @@ check_thread_db_callback (const td_thrhandle_t *th, void *arg) if (tdb_testinfo->log_progress) { - struct value_print_options opts; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); LOG (" = "); value_print (val, gdb_stdlog, &opts); } diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index b1c42ddfd24..5e5244619af 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1145,7 +1145,6 @@ mi_cmd_data_evaluate_expression (const char *command, const char *const *argv, int argc) { struct value *val; - struct value_print_options opts; struct ui_out *uiout = current_uiout; if (argc != 1) @@ -1159,7 +1158,7 @@ mi_cmd_data_evaluate_expression (const char *command, const char *const *argv, string_file stb; /* Print the result of the expression evaluation. */ - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.deref_ref = false; common_val_print (val, &stb, 0, &opts, current_language); diff --git a/gdb/printcmd.c b/gdb/printcmd.c index 4c964915a8b..9ebe563fed3 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1334,7 +1334,7 @@ static struct value * process_print_command_args (const char *args, value_print_options *print_opts, bool voidprint) { - get_user_print_options (print_opts); + *print_opts = get_user_print_options (); /* Override global settings with explicit options, if any. */ auto group = make_value_print_options_def_group (print_opts); gdb::option::process_options @@ -2378,14 +2378,13 @@ print_variable_value (symbol *var, const frame_info_ptr &frame, try { struct value *val; - struct value_print_options opts; /* READ_VAR_VALUE needs a block in order to deal with non-local references (i.e. to handle nested functions). In this context, we print variables that are local to this frame, so we can avoid passing a block to it. */ val = read_var_value (var, NULL, frame); - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.deref_ref = true; common_val_print_checked (val, stream, indent, &opts, language); } @@ -2888,8 +2887,7 @@ ui_printf (const char *arg, struct ui_file *stream) break; case value_arg: { - value_print_options print_opts; - get_user_print_options (&print_opts); + value_print_options print_opts = get_user_print_options (); if (current_substring[2] == '[') { diff --git a/gdb/python/py-framefilter.c b/gdb/python/py-framefilter.c index f256a26807c..6e3012a3331 100644 --- a/gdb/python/py-framefilter.c +++ b/gdb/python/py-framefilter.c @@ -417,9 +417,7 @@ enumerate_args (PyObject *iter, int print_args_field, const frame_info_ptr &frame) { - struct value_print_options opts; - - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.raw = raw_frame_args; if (args_type == CLI_SCALAR_VALUES) @@ -549,9 +547,7 @@ enumerate_locals (PyObject *iter, int print_args_field, const frame_info_ptr &frame) { - struct value_print_options opts; - - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.deref_ref = true; while (true) @@ -633,7 +629,6 @@ enumerate_locals (PyObject *iter, static enum ext_lang_bt_status py_mi_print_variables (PyObject *filter, struct ui_out *out, - struct value_print_options *opts, enum ext_lang_frame_args args_type, const frame_info_ptr &frame, bool raw_frame_args_p) @@ -767,7 +762,6 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, CORE_ADDR address = 0; struct gdbarch *gdbarch = NULL; frame_info_ptr frame = NULL; - struct value_print_options opts; int print_level, print_frame_info, print_args, print_locals; /* Note that the below default in non-mi mode is the same as the @@ -786,7 +780,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, print_args = (flags & PRINT_ARGS) ? 1 : 0; print_locals = (flags & PRINT_LOCALS) ? 1 : 0; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (print_frame_info) { std::optional user_frame_info_print_what; @@ -818,7 +812,7 @@ py_print_frame (PyObject *filter, frame_filter_flags flags, if (print_locals && print_args && ! print_frame_info) { bool raw_frame_args = (flags & PRINT_RAW_FRAME_ARGUMENTS) != 0; - if (py_mi_print_variables (filter, out, &opts, args_type, frame, + if (py_mi_print_variables (filter, out, args_type, frame, raw_frame_args) == EXT_LANG_BT_ERROR) return EXT_LANG_BT_ERROR; return EXT_LANG_BT_OK; diff --git a/gdb/python/py-lazy-string.c b/gdb/python/py-lazy-string.c index c9d06338b0a..e095bc3fb69 100644 --- a/gdb/python/py-lazy-string.c +++ b/gdb/python/py-lazy-string.c @@ -305,8 +305,7 @@ stpy_str (PyObject *self) { lazy_string_object *str = (lazy_string_object *) self; - struct value_print_options opts; - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.addressprint = false; string_file stream; diff --git a/gdb/python/py-prettyprint.c b/gdb/python/py-prettyprint.c index d3faf861fcf..1326aaae476 100644 --- a/gdb/python/py-prettyprint.c +++ b/gdb/python/py-prettyprint.c @@ -776,7 +776,7 @@ gdbpy_get_print_options (value_print_options *opts) if (gdbpy_current_print_options != nullptr) *opts = *gdbpy_current_print_options; else - get_user_print_options (opts); + *opts = get_user_print_options (); } /* A ValuePrinter is just a "tag", so it has no state other than that diff --git a/gdb/python/py-unwind.c b/gdb/python/py-unwind.c index 13eced4cecb..ec682c34ebc 100644 --- a/gdb/python/py-unwind.c +++ b/gdb/python/py-unwind.c @@ -210,9 +210,8 @@ unwind_infopy_str (PyObject *self) stb.printf ("Frame ID: %s", unwind_info->frame_id.to_string ().c_str ()); { const char *sep = ""; - struct value_print_options opts; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); stb.printf ("\nSaved registers: ("); for (const saved_reg ® : *unwind_info->saved_regs) { diff --git a/gdb/record-full.c b/gdb/record-full.c index 695d9d1622c..c843236e5fe 100644 --- a/gdb/record-full.c +++ b/gdb/record-full.c @@ -2806,8 +2806,7 @@ maintenance_print_record_instruction (const char *args, int from_tty) auto to_print = record_full_log.begin () + offset; gdbarch *arch = current_inferior ()->arch (); - struct value_print_options opts; - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.raw = true; for (auto &entry : to_print->effects) diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index a21796db1f9..d98d3f33fed 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1180,11 +1180,10 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, if (riscv_is_fp_regno_p (regnum)) { - struct value_print_options opts; const gdb_byte *valaddr = val->contents_for_printing ().data (); enum bfd_endian byte_order = type_byte_order (regtype); - get_user_print_options (&opts); + value_print_options opts = get_user_print_options (); opts.deref_ref = true; common_val_print (val, file, 0, &opts, current_language); @@ -1337,7 +1336,7 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, natural format. */ if (regtype->is_vector () == 0) { - get_user_print_options (&opts); + opts = get_user_print_options (); opts.deref_ref = true; gdb_printf (file, "\t"); common_val_print (val, file, 0, &opts, current_language); diff --git a/gdb/skip.c b/gdb/skip.c index 917b084860d..795a573412b 100644 --- a/gdb/skip.c +++ b/gdb/skip.c @@ -1035,9 +1035,6 @@ static void info_skip_command (const char *arg, int from_tty) { int num_printable_entries = 0; - struct value_print_options opts; - - get_user_print_options (&opts); /* Count the number of rows in the table and see if we need space for a 64-bit address anywhere. */ diff --git a/gdb/stack.c b/gdb/stack.c index 5d725803c1e..4ebecfc36c3 100644 --- a/gdb/stack.c +++ b/gdb/stack.c @@ -1081,9 +1081,7 @@ do_print_frame_info (struct ui_out *uiout, const frame_print_options &fp_opts, sal.line + 1, 0); else { - struct value_print_options opts; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); /* We used to do this earlier, but that is clearly wrong. This function is used by many different parts of gdb, including normal_stop in infrun.c, @@ -1267,7 +1265,6 @@ print_frame (struct ui_out *uiout, { struct gdbarch *gdbarch = get_frame_arch (frame); enum language funlang = language_unknown; - struct value_print_options opts; struct symbol *func; std::optional pc; @@ -1288,7 +1285,7 @@ print_frame (struct ui_out *uiout, uiout->field_fmt_signed (2, ui_left, "level", frame_relative_level (frame)); } - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (opts.addressprint) if (!sal.symtab || frame_show_address (frame, sal) diff --git a/gdb/tracepoint.c b/gdb/tracepoint.c index 798bb9a552d..18b678afd52 100644 --- a/gdb/tracepoint.c +++ b/gdb/tracepoint.c @@ -523,8 +523,6 @@ teval_pseudocommand (const char *args, int from_tty) const char * decode_agent_options (const char *exp, int *trace_string) { - struct value_print_options opts; - *trace_string = 0; if (*exp != '/') @@ -532,7 +530,7 @@ decode_agent_options (const char *exp, int *trace_string) /* Call this to borrow the print elements default for collection size. */ - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); exp++; if (*exp == 's') diff --git a/gdb/typeprint.c b/gdb/typeprint.c index 31a9c1814a3..46dd01199e5 100644 --- a/gdb/typeprint.c +++ b/gdb/typeprint.c @@ -357,7 +357,6 @@ whatis_exp (const char *exp, int show) int full = 0; LONGEST top = -1; int using_enc = 0; - struct value_print_options opts; struct type_print_options flags = default_ptype_flags; if (exp) @@ -457,7 +456,7 @@ whatis_exp (const char *exp, int show) flags.print_offsets = 0; } - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (val != NULL && opts.objectprint) { if (type->is_pointer_or_reference () diff --git a/gdb/valprint.c b/gdb/valprint.c index 0c385f6ad52..4ef50707bef 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -97,13 +97,6 @@ struct value_print_options user_print_options = PRINT_MAX_DEPTH_DEFAULT, /* max_depth */ }; -/* Initialize *OPTS to be a copy of the user print options. */ -void -get_user_print_options (struct value_print_options *opts) -{ - *opts = user_print_options; -} - /* See valprint.h. */ value_print_options diff --git a/gdb/valprint.h b/gdb/valprint.h index b38af46f344..e743c39dca5 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -144,8 +144,14 @@ extern gdb::option::option_def_group make_value_print_options_def_group code should call get_user_print_options instead. */ extern struct value_print_options user_print_options; -/* Initialize *OPTS to be a copy of the user print options. */ -extern void get_user_print_options (struct value_print_options *opts); +/* Accessor for the user print options. */ + +static inline +const value_print_options & +get_user_print_options () +{ + return user_print_options; +} /* Return a copy of the user print options, but with pretty-formatting disabled. */ diff --git a/gdb/value.c b/gdb/value.c index 1f6d7949d4d..e9c22cbc9da 100644 --- a/gdb/value.c +++ b/gdb/value.c @@ -1083,10 +1083,8 @@ struct type * value_actual_type (struct value *value, int resolve_simple_types, int *real_type_found) { - struct value_print_options opts; struct type *result; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (real_type_found) *real_type_found = 0; @@ -1786,11 +1784,9 @@ show_values (const char *num_exp, int from_tty) for (i = num; i < num + 10 && i <= value_history.size (); i++) { - struct value_print_options opts; - val = access_value_history (i); gdb_printf (("$%d = "), i); - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); value_print (val, gdb_stdout, &opts); gdb_printf (("\n")); } @@ -2564,9 +2560,8 @@ show_convenience (const char *ignore, int from_tty) { struct gdbarch *gdbarch = get_current_arch (); int varseen = 0; - struct value_print_options opts; - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); for (auto &pair : internalvars) { internalvar &var = pair.second; diff --git a/gdb/varobj.c b/gdb/varobj.c index a5caee56707..92a1f5ae578 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -1129,9 +1129,7 @@ update_type_if_necessary (struct varobj *var, struct value *new_value) { if (new_value) { - struct value_print_options opts; - - get_user_print_options (&opts); + const value_print_options &opts = get_user_print_options (); if (opts.objectprint) { struct type *new_type = value_actual_type (new_value, 0, 0); -- 2.49.0