From: Simon Marchi <simark@simark.ca>
To: Tom Tromey <tromey@adacore.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH] Fix Ada val_print removal regression
Date: Thu, 19 Mar 2020 16:19:26 -0400 [thread overview]
Message-ID: <c2bc69e6-20c6-7525-f132-ffb8a5cb1f6e@simark.ca> (raw)
In-Reply-To: <87a74cp1w4.fsf@tromey.com>
On 2020-03-19 3:42 p.m., Tom Tromey wrote:
> @@ -553,39 +551,34 @@ ada_printstr (struct ui_file *stream, struct type *type,
> }
>
> static int
> -print_variant_part (struct type *type, int field_num,
> - const gdb_byte *valaddr, int offset,
> +print_variant_part (struct value *value, int field_num,
> + struct value *outer_value,
> struct ui_file *stream, int recurse,
> - struct value *val,
> const struct value_print_options *options,
> int comma_needed,
> - struct type *outer_type, int outer_offset,
> const struct language_defn *language)
> {
> + struct type *type = value_type (value);
> struct type *var_type = TYPE_FIELD_TYPE (type, field_num);
> - int which = ada_which_variant_applies (var_type, outer_type,
> - valaddr + outer_offset);
> + int which = ada_which_variant_applies (var_type,
> + value_type (outer_value),
> + value_contents (outer_value));z
>
> if (which < 0)
> return 0;
> - else
> - return print_field_values
> - (TYPE_FIELD_TYPE (var_type, which),
> - valaddr,
> - offset + TYPE_FIELD_BITPOS (type, field_num) / HOST_CHAR_BIT
> - + TYPE_FIELD_BITPOS (var_type, which) / HOST_CHAR_BIT,
> - stream, recurse, val, options,
> - comma_needed, outer_type, outer_offset, language);
> +
> + struct value *variant = value_field (value, which);
A bit of a nit, but it's to make sure I understand what's happening. From what
I understand, the variant is the enclosing type, from which only one component
is active at a given time. This value variable represents the active component,
right? If so, I'd suggest naming it active_component or something like that.
> @@ -923,17 +907,16 @@ ada_val_print_enum (struct value *value, struct ui_file *stream, int recurse,
> print_longest (stream, 'd', 0, val);
> }
>
> -/* Implement Ada val_print'ing for the case where TYPE is
> - a TYPE_CODE_STRUCT or TYPE_CODE_UNION. */
> +/* Implement Ada val_print'ing for the case where the type is
> + TYPE_CODE_STRUCT or TYPE_CODE_UNION. */
>
> static void
> ada_val_print_struct_union
> - (struct type *type, const gdb_byte *valaddr, int offset,
> - int offset_aligned, CORE_ADDR address, struct ui_file *stream,
> + (struct value *value, struct ui_file *stream,
> int recurse, struct value *original_value,
> const struct value_print_options *options)
> {
The sole caller of this function passes the same `val` twice, so I suppose you could remove `original_value`.
Simon
next prev parent reply other threads:[~2020-03-19 20:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-17 18:00 Tom Tromey
2020-03-18 1:31 ` Simon Marchi
2020-03-19 13:54 ` Tom Tromey
2020-03-19 19:42 ` Tom Tromey
2020-03-19 20:19 ` Simon Marchi [this message]
2020-03-19 21:13 ` Tom Tromey
2020-03-19 21:24 ` Simon Marchi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c2bc69e6-20c6-7525-f132-ffb8a5cb1f6e@simark.ca \
--to=simark@simark.ca \
--cc=gdb-patches@sourceware.org \
--cc=tromey@adacore.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox