* [PATCH] Merge do_val_print and common_val_print
@ 2022-02-05 17:39 Tom Tromey
2022-02-06 12:45 ` Andrew Burgess
0 siblings, 1 reply; 2+ messages in thread
From: Tom Tromey @ 2022-02-05 17:39 UTC (permalink / raw)
To: gdb-patches; +Cc: Tom Tromey
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.
---
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_file *stream, int recurse,
}
}
-/* 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 according
+ to OPTIONS.
-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 = 0;
+ if (language->la_language == 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 = ada_to_fixed_value (value);
+
+ if (value_lazy (value))
+ value_fetch_lazy (value);
+
struct value_print_options local_opts = *options;
struct type *type = value_type (value);
struct type *real_type = check_typedef (type);
@@ -1024,9 +1035,8 @@ do_val_print (struct value *value, struct ui_file *stream, int recurse,
if (!options->raw)
{
- ret = apply_ext_lang_val_pretty_printer (value, stream, recurse, options,
- language);
- if (ret)
+ if (apply_ext_lang_val_pretty_printer (value, stream, recurse, options,
+ language))
return;
}
@@ -1127,30 +1137,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
return 1;
}
-/* Print using the given LANGUAGE the value VAL onto stream STREAM according
- 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 == 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 = ada_to_fixed_value (val);
-
- if (value_lazy (val))
- value_fetch_lazy (val);
-
- do_val_print (val, stream, recurse, options, language);
-}
-
/* See valprint.h. */
void
--
2.31.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Merge do_val_print and common_val_print
2022-02-05 17:39 [PATCH] Merge do_val_print and common_val_print Tom Tromey
@ 2022-02-06 12:45 ` Andrew Burgess
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Burgess @ 2022-02-06 12:45 UTC (permalink / raw)
To: Tom Tromey; +Cc: gdb-patches
* Tom Tromey <tom@tromey.com> [2022-02-05 10:39:06 -0700]:
> 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.
LGTM.
Thanks,
Andrew
> ---
> 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_file *stream, int recurse,
> }
> }
>
> -/* 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 according
> + to OPTIONS.
>
> -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 = 0;
> + if (language->la_language == 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 = ada_to_fixed_value (value);
> +
> + if (value_lazy (value))
> + value_fetch_lazy (value);
> +
> struct value_print_options local_opts = *options;
> struct type *type = value_type (value);
> struct type *real_type = check_typedef (type);
> @@ -1024,9 +1035,8 @@ do_val_print (struct value *value, struct ui_file *stream, int recurse,
>
> if (!options->raw)
> {
> - ret = apply_ext_lang_val_pretty_printer (value, stream, recurse, options,
> - language);
> - if (ret)
> + if (apply_ext_lang_val_pretty_printer (value, stream, recurse, options,
> + language))
> return;
> }
>
> @@ -1127,30 +1137,6 @@ value_check_printable (struct value *val, struct ui_file *stream,
> return 1;
> }
>
> -/* Print using the given LANGUAGE the value VAL onto stream STREAM according
> - 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 == 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 = ada_to_fixed_value (val);
> -
> - if (value_lazy (val))
> - value_fetch_lazy (val);
> -
> - do_val_print (val, stream, recurse, options, language);
> -}
> -
> /* See valprint.h. */
>
> void
> --
> 2.31.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-02-06 12:45 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-05 17:39 [PATCH] Merge do_val_print and common_val_print Tom Tromey
2022-02-06 12:45 ` Andrew Burgess
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).