From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2126) id 8A7F23858D3C; Sun, 6 Feb 2022 21:35:04 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8A7F23858D3C Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Tom Tromey To: gdb-cvs@sourceware.org Subject: [binutils-gdb] Merge do_val_print and common_val_print X-Act-Checkin: binutils-gdb X-Git-Author: Tom Tromey X-Git-Refname: refs/heads/master X-Git-Oldrev: 5d0027b9bab7cbf5eb41a8c8ad1b9e4650d5f87e X-Git-Newrev: 1a1bfce78f58cc934bf6ace4d03ddc87c9cbb860 Message-Id: <20220206213504.8A7F23858D3C@sourceware.org> Date: Sun, 6 Feb 2022 21:35:04 +0000 (GMT) X-BeenThere: gdb-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 06 Feb 2022 21:35:04 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D1a1bfce78f58= cc934bf6ace4d03ddc87c9cbb860 commit 1a1bfce78f58cc934bf6ace4d03ddc87c9cbb860 Author: Tom Tromey Date: Wed Jan 26 17:57:33 2022 -0700 Merge do_val_print and common_val_print =20 The only caller of do_val_print just does a small bit of work before the call. This patch merges the two functions, and removes an unnecessary local variable, making gdb a bit simpler. Diff: --- gdb/valprint.c | 56 +++++++++++++++++++++---------------------------------= -- 1 file changed, 21 insertions(+), 35 deletions(-) diff --git a/gdb/valprint.c b/gdb/valprint.c index 82abcb41734..25e4a8dc8e1 100644 --- a/gdb/valprint.c +++ b/gdb/valprint.c @@ -989,16 +989,27 @@ generic_value_print (struct value *val, struct ui_fil= e *stream, int recurse, } } =20 -/* Helper function for val_print and common_val_print that does the - work. Arguments are as to val_print, but FULL_VALUE, if given, is - the value to be printed. */ +/* Print using the given LANGUAGE the value VAL onto stream STREAM accordi= ng + to OPTIONS. =20 -static void -do_val_print (struct value *value, struct ui_file *stream, int recurse, - const struct value_print_options *options, - const struct language_defn *language) + This is a preferable interface to val_print, above, because it uses + GDB's value mechanism. */ + +void +common_val_print (struct value *value, struct ui_file *stream, int recurse, + const struct value_print_options *options, + const struct language_defn *language) { - int ret =3D 0; + if (language->la_language =3D=3D language_ada) + /* The value might have a dynamic type, which would cause trouble + below when trying to extract the value contents (since the value + size is determined from the type size which is unknown). So + get a fixed representation of our value. */ + value =3D ada_to_fixed_value (value); + + if (value_lazy (value)) + value_fetch_lazy (value); + struct value_print_options local_opts =3D *options; struct type *type =3D value_type (value); struct type *real_type =3D check_typedef (type); @@ -1024,9 +1035,8 @@ do_val_print (struct value *value, struct ui_file *st= ream, int recurse, =20 if (!options->raw) { - ret =3D apply_ext_lang_val_pretty_printer (value, stream, recurse, o= ptions, - language); - if (ret) + if (apply_ext_lang_val_pretty_printer (value, stream, recurse, optio= ns, + language)) return; } =20 @@ -1127,30 +1137,6 @@ value_check_printable (struct value *val, struct ui_= file *stream, return 1; } =20 -/* Print using the given LANGUAGE the value VAL onto stream STREAM accordi= ng - to OPTIONS. - - This is a preferable interface to val_print, above, because it uses - GDB's value mechanism. */ - -void -common_val_print (struct value *val, struct ui_file *stream, int recurse, - const struct value_print_options *options, - const struct language_defn *language) -{ - if (language->la_language =3D=3D language_ada) - /* The value might have a dynamic type, which would cause trouble - below when trying to extract the value contents (since the value - size is determined from the type size which is unknown). So - get a fixed representation of our value. */ - val =3D ada_to_fixed_value (val); - - if (value_lazy (val)) - value_fetch_lazy (val); - - do_val_print (val, stream, recurse, options, language); -} - /* See valprint.h. */ =20 void