From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca by simark.ca with LMTP id 4Y/mEkOESWpIASgAWB0awg (envelope-from ) for ; Sat, 04 Jul 2026 18:08:03 -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=uu65PHZm; dkim-atps=neutral Received: by simark.ca (Postfix, from userid 112) id 491411E024; Sat, 04 Jul 2026 18:08:03 -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 644651E024 for ; Sat, 04 Jul 2026 18:08:02 -0400 (EDT) Received: from vm01.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 23F844B9DB5E for ; Sat, 4 Jul 2026 22:08:01 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 23F844B9DB5E 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=uu65PHZm Received: from omta34.uswest2.a.cloudfilter.net (omta34.uswest2.a.cloudfilter.net [35.89.44.33]) by sourceware.org (Postfix) with ESMTPS id BC3534BA23DD for ; Sat, 4 Jul 2026 22:05:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BC3534BA23DD 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 BC3534BA23DD 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=1783202730; cv=none; b=vSj/cA7/VcWb29Gee9BV2MBiX7p5ImzxHc68p4R4LIAYkZE1M0rWLko2AtyigXTNwmiVVYvAncMPqQlCjBkv1g6knStY7wVBxYE8yi6nywiM9e01dctmtNO+XOqY9K/rSuey/VM/JK1SMxsFL8AIpl1fyPJ2U1xbKa0Cyt1cBQM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1783202730; c=relaxed/simple; bh=jh9YCN7enGqlwuvVgJdBPvMYsrQCYrTS8PQB9xkO3ss=; h=DKIM-Signature:From:Date:Subject:MIME-Version:Message-Id:To; b=HkBbM58MjDEicRI5FegLudueygGqWCNUuM0/OoADjAOhKgvZtccxbm+t9Tjc5CA+Be2ndUP4KEw4rouKkWklLl3BZLcHLvtejL94OCQfddXwDJLvLETJeJ/jJLFaUysp3lgNHpv5Jj3glR2VrIUYz0b4rNXuTUTrBLWGXCYxp80= 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=uu65PHZm reason="signing key too small" DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC3534BA23DD Received: from eig-obgw-6005b.ext.cloudfilter.net ([10.0.30.162]) by cmsmtp with ESMTPS id g3juwCDo5lPo5g8UEwX2sT; Sat, 04 Jul 2026 22:05:22 +0000 Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with ESMTPS id g8UDw0888OYlBg8UEwBMkq; Sat, 04 Jul 2026 22:05:22 +0000 X-Authority-Analysis: v=2.4 cv=FLYbx/os 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=_PgzAl3KKxtsESReVuAA: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=CgKqFsiaftER0PnLYXGXcQHHuNmGET35HRgS9hvQqs4=; b=uu65PHZmD9xEI3eNy2giAXWNt3 5mBGkE932+RiuI49lsze0uJT7i7Ft3apjx8e+npN2+z88fCDY/KZ51nejzCfoPXZU+F+xKcHp0j47 5W9YlBulEplyV/bfJBmVwgEYE; 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 1wg8UD-00000000OSH-2X9w; Sat, 04 Jul 2026 16:05:21 -0600 From: Tom Tromey Date: Sat, 04 Jul 2026 16:05:15 -0600 Subject: [PATCH 1/9] Return value_print_options from get_formatted_print_options MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260704-print-opts-cleanup-v1-1-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: 1wg8UD-00000000OSH-2X9w 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: 2 X-Org: HG=bhshared;ORG=bluehost; X-Source-Cap: ZWx5bnJvYmk7ZWx5bnJvYmk7Ym94NTM3OS5ibHVlaG9zdC5jb20= X-Local-Domain: yes X-CMAE-Envelope: MS4xfDujLW+yo/3RkzmLgzvgbOVTyRs0IUEAoajn3q01l9AF5ZyAZI9NLddCY9TqhA99yR08NQDF/AFfoyjGfnwg0aXrPUeRbLzUpFqvbWxntvTymCsF+SCH NU/poPfGfBvOvQZ9uokilN7YEhPDymffKUTxMA72pQ0Dq351/lFT8e9+Ua2w8EaTBeo0IpSOPJhOmRQuNTAavPMvcApl95Kox3o= 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_formatted_print_options to return the value_print_options object. --- gdb/dwarf2/read.c | 5 ++--- gdb/infcmd.c | 4 +--- gdb/mi/mi-main.c | 7 +++---- gdb/mips-tdep.c | 11 +++-------- gdb/printcmd.c | 10 +++------- gdb/riscv-tdep.c | 3 +-- gdb/valprint.c | 14 +++++++------- gdb/valprint.h | 7 +++---- gdb/varobj.c | 2 +- 9 files changed, 24 insertions(+), 39 deletions(-) diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 114c608fde3..6f34f187d47 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -5119,8 +5119,6 @@ dwarf2_compute_name (const char *name, cu->language_defn->printchar (value, type, &buf); else { - struct value_print_options opts; - if (baton != NULL) v = dwarf2_evaluate_loc_desc (type, NULL, baton->expr (), @@ -5137,7 +5135,8 @@ dwarf2_compute_name (const char *name, /* Specify decimal so that we do not depend on the radix. */ - get_formatted_print_options (&opts, 'd'); + value_print_options opts + = get_formatted_print_options ('d'); opts.raw = true; value_print (v, &buf, &opts); release_value (v); diff --git a/gdb/infcmd.c b/gdb/infcmd.c index bd5dbb02f48..eb7b4efa2a0 100644 --- a/gdb/infcmd.c +++ b/gdb/infcmd.c @@ -2439,10 +2439,8 @@ default_print_one_register_info (struct ui_file *file, } else { - struct value_print_options opts; - /* Print the register in hex. */ - get_formatted_print_options (&opts, 'x'); + value_print_options opts = get_formatted_print_options ('x'); opts.deref_ref = true; common_val_print (val, &format_stream, 0, &opts, current_language); /* If not a vector register, print it also according to its diff --git a/gdb/mi/mi-main.c b/gdb/mi/mi-main.c index 73c64b82186..200d29309ba 100644 --- a/gdb/mi/mi-main.c +++ b/gdb/mi/mi-main.c @@ -1059,7 +1059,6 @@ output_register (const frame_info_ptr &frame, int regnum, int format, struct ui_out *uiout = current_uiout; value *val = value_of_register (regnum, get_next_frame_sentinel_okay (frame)); - struct value_print_options opts; if (skip_unavailable && !val->entirely_available ()) return; @@ -1075,7 +1074,7 @@ output_register (const frame_info_ptr &frame, int regnum, int format, string_file stb; - get_formatted_print_options (&opts, format); + value_print_options opts = get_formatted_print_options (format); opts.deref_ref = true; common_val_print (val, &stb, 0, &opts, current_language); uiout->field_stream ("value", stb); @@ -1315,7 +1314,6 @@ mi_cmd_data_read_memory (const char *command, const char *const *argv, { int col; int col_byte; - struct value_print_options print_opts; ui_out_emit_tuple tuple_emitter (uiout, NULL); uiout->field_core_addr ("addr", gdbarch, addr + row_byte); @@ -1323,7 +1321,8 @@ mi_cmd_data_read_memory (const char *command, const char *const *argv, row_byte); */ { ui_out_emit_list list_data_emitter (uiout, "data"); - get_formatted_print_options (&print_opts, word_format); + value_print_options print_opts + = get_formatted_print_options (word_format); for (col = 0, col_byte = row_byte; col < nr_cols; col++, col_byte += word_size) diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c index fe0482fe5bf..6532884f69b 100644 --- a/gdb/mips-tdep.c +++ b/gdb/mips-tdep.c @@ -6340,15 +6340,13 @@ mips_print_fp_register (struct ui_file *file, const frame_info_ptr &frame, if (register_size (gdbarch, regnum) == 4 || mips2_fp_compat (frame)) { - struct value_print_options opts; - /* 4-byte registers: Print hex and floating. Also print even numbered registers as doubles. */ mips_read_fp_register_single (frame, regnum, raw_buffer); flt_str = target_float_to_string (raw_buffer.data (), flt_type, "%-17.9g"); - get_formatted_print_options (&opts, 'x'); + value_print_options opts = get_formatted_print_options ('x'); print_scalar_formatted (raw_buffer.data (), builtin_type (gdbarch)->builtin_uint32, &opts, 'w', file); @@ -6366,8 +6364,6 @@ mips_print_fp_register (struct ui_file *file, const frame_info_ptr &frame, } else { - struct value_print_options opts; - /* Eight byte registers: print each one as hex, float and double. */ mips_read_fp_register_single (frame, regnum, raw_buffer); flt_str = target_float_to_string (raw_buffer.data (), flt_type, @@ -6377,7 +6373,7 @@ mips_print_fp_register (struct ui_file *file, const frame_info_ptr &frame, dbl_str = target_float_to_string (raw_buffer.data (), dbl_type, "%-24.17g"); - get_formatted_print_options (&opts, 'x'); + value_print_options opts = get_formatted_print_options ('x'); print_scalar_formatted (raw_buffer.data (), builtin_type (gdbarch)->builtin_uint64, &opts, 'g', file); @@ -6392,7 +6388,6 @@ mips_print_register (struct ui_file *file, const frame_info_ptr &frame, int regnum) { struct gdbarch *gdbarch = get_frame_arch (frame); - struct value_print_options opts; struct value *val; if (mips_float_register_p (gdbarch, regnum)) @@ -6414,7 +6409,7 @@ mips_print_register (struct ui_file *file, const frame_info_ptr &frame, else gdb_printf (file, ": "); - get_formatted_print_options (&opts, 'x'); + value_print_options opts = get_formatted_print_options ('x'); value_print_scalar_formatted (val, &opts, 0, file); } diff --git a/gdb/printcmd.c b/gdb/printcmd.c index a337a6b7db9..4c964915a8b 100644 --- a/gdb/printcmd.c +++ b/gdb/printcmd.c @@ -1101,8 +1101,7 @@ do_examine_next_address (struct format_data fmt) if (format == 's' || format == 'i') maxelts = 1; - value_print_options opts; - get_formatted_print_options (&opts, format); + value_print_options opts = get_formatted_print_options (format); bool need_to_update_next_address = false; CORE_ADDR addr_rewound = 0; @@ -1458,7 +1457,6 @@ output_command (const char *exp, int from_tty) char format = 0; struct value *val; struct format_data fmt; - struct value_print_options opts; fmt.size = 0; fmt.raw = 0; @@ -1477,7 +1475,7 @@ output_command (const char *exp, int from_tty) annotate_value_begin (val->type ()); - get_formatted_print_options (&opts, format); + value_print_options opts = get_formatted_print_options (format); opts.raw = fmt.raw; /* This setting allows large arrays to be printed by limiting the @@ -2192,8 +2190,6 @@ do_one_display (struct display *d) } else { - struct value_print_options opts; - annotate_display_format (); if (d->format.format) @@ -2208,7 +2204,7 @@ do_one_display (struct display *d) annotate_display_expression (); - get_formatted_print_options (&opts, d->format.format); + value_print_options opts = get_formatted_print_options (d->format.format); opts.raw = d->format.raw; try diff --git a/gdb/riscv-tdep.c b/gdb/riscv-tdep.c index 1751d78a5f3..a21796db1f9 100644 --- a/gdb/riscv-tdep.c +++ b/gdb/riscv-tdep.c @@ -1199,11 +1199,10 @@ riscv_print_one_register_info (struct gdbarch *gdbarch, } else { - struct value_print_options opts; riscv_gdbarch_tdep *tdep = gdbarch_tdep (gdbarch); /* Print the register in hex. */ - get_formatted_print_options (&opts, 'x'); + value_print_options opts = get_formatted_print_options ('x'); opts.deref_ref = true; common_val_print (val, file, 0, &opts, current_language); diff --git a/gdb/valprint.c b/gdb/valprint.c index 50a4663ca3b..cf2bc8e135c 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -113,14 +113,14 @@ get_no_prettyformat_print_options (struct value_print_options *opts) opts->prettyformat = Val_no_prettyformat; } -/* Initialize *OPTS to be a copy of the user print options, but using - FORMAT as the formatting option. */ -void -get_formatted_print_options (struct value_print_options *opts, - char format) +/* See valprint.h. */ + +value_print_options +get_formatted_print_options (char format) { - *opts = user_print_options; - opts->format = format; + value_print_options opts = user_print_options; + opts.format = format; + return opts; } /* Implement 'show print elements'. */ diff --git a/gdb/valprint.h b/gdb/valprint.h index 15d0be2ac7a..775ff333646 100644 --- a/gdb/valprint.h +++ b/gdb/valprint.h @@ -151,10 +151,9 @@ extern void get_user_print_options (struct value_print_options *opts); pretty-formatting disabled. */ extern void get_no_prettyformat_print_options (struct value_print_options *); -/* Initialize *OPTS to be a copy of the user print options, but using - FORMAT as the formatting option. */ -extern void get_formatted_print_options (struct value_print_options *opts, - char format); +/* Return a copy of the user print options, but using FORMAT as the + formatting option. */ +extern value_print_options get_formatted_print_options (char format); extern void maybe_print_array_index (struct type *index_type, LONGEST index, struct ui_file *stream, diff --git a/gdb/varobj.c b/gdb/varobj.c index a55c2c6dd2b..a5caee56707 100644 --- a/gdb/varobj.c +++ b/gdb/varobj.c @@ -2106,7 +2106,7 @@ void varobj_formatted_print_options (struct value_print_options *opts, enum varobj_display_formats format) { - get_formatted_print_options (opts, format_code[(int) format]); + *opts = get_formatted_print_options (format_code[(int) format]); opts->deref_ref = false; opts->raw = !pretty_printing; } -- 2.49.0