From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from simark.ca (simark.ca [158.69.221.121]) by sourceware.org (Postfix) with ESMTPS id EF8BA385C017 for ; Thu, 19 Mar 2020 20:19:26 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org EF8BA385C017 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=simark.ca Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=simark@simark.ca Received: from [172.16.0.95] (192-222-181-218.qc.cable.ebox.net [192.222.181.218]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 804481E5F9; Thu, 19 Mar 2020 16:19:26 -0400 (EDT) Subject: Re: [PATCH] Fix Ada val_print removal regression To: Tom Tromey Cc: gdb-patches@sourceware.org References: <20200317180034.26934-1-tromey@adacore.com> <6a432b2a-4ae9-101d-32c3-efee7da031d1@simark.ca> <874kuksb4q.fsf@tromey.com> <87a74cp1w4.fsf@tromey.com> From: Simon Marchi Message-ID: Date: Thu, 19 Mar 2020 16:19:26 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <87a74cp1w4.fsf@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=0.0 required=5.0 tests=KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 19 Mar 2020 20:19:27 -0000 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