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 BC886386F451 for ; Tue, 28 Apr 2020 15:10:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org BC886386F451 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 [10.0.0.193] (unknown [192.222.164.54]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 3537A1F068; Tue, 28 Apr 2020 11:10:28 -0400 (EDT) Subject: Re: [PATCH][PR gdb/18706] Calculate size of array of stubbed type To: Hannes Domani , gdb-patches@sourceware.org References: <20200427114154.2275-1-ssbssa.ref@yahoo.de> <20200427114154.2275-1-ssbssa@yahoo.de> From: Simon Marchi Message-ID: <82e2e5d4-f5e3-7a89-5bcb-bfe305c601e4@simark.ca> Date: Tue, 28 Apr 2020 11:10:27 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: <20200427114154.2275-1-ssbssa@yahoo.de> Content-Type: text/plain; charset=utf-8 Content-Language: tl Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-22.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_DMARC_STATUS, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP 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: Tue, 28 Apr 2020 15:10:39 -0000 On 2020-04-27 7:41 a.m., Hannes Domani via Gdb-patches wrote: > Sizes of stubbed types are calculated on demand in check_typedef, so the same > must also be done for arrays of stubbed types. For the uninitiated, can you please explain what's happening here, which types are involved, which ones are stubs, and what that means. That would help me understand what happens here and be confident that the patch is correct. > > gdb/ChangeLog: > > 2020-04-27 Hannes Domani > > PR gdb/18706 > * gdbtypes.c (check_typedef): Calculate size of array of stubbed type. > > gdb/testsuite/ChangeLog: > > 2020-04-27 Hannes Domani > > PR gdb/18706 > * gdb.cp/stub-array-size.cc: New test. > * gdb.cp/stub-array-size.exp: New file. > * gdb.cp/stub-array-size.h: New test. > * gdb.cp/stub-array-size2.cc: New test. > --- > gdb/gdbtypes.c | 16 ++++++++++++++ > gdb/testsuite/gdb.cp/stub-array-size.cc | 25 ++++++++++++++++++++++ > gdb/testsuite/gdb.cp/stub-array-size.exp | 27 ++++++++++++++++++++++++ > gdb/testsuite/gdb.cp/stub-array-size.h | 21 ++++++++++++++++++ > gdb/testsuite/gdb.cp/stub-array-size2.cc | 22 +++++++++++++++++++ > 5 files changed, 111 insertions(+) > create mode 100644 gdb/testsuite/gdb.cp/stub-array-size.cc > create mode 100644 gdb/testsuite/gdb.cp/stub-array-size.exp > create mode 100644 gdb/testsuite/gdb.cp/stub-array-size.h > create mode 100644 gdb/testsuite/gdb.cp/stub-array-size2.cc > > diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c > index 157b3c5e61..5e9de2ccb1 100644 > --- a/gdb/gdbtypes.c > +++ b/gdb/gdbtypes.c > @@ -2637,6 +2637,22 @@ check_typedef (struct type *type) > TYPE_LENGTH (type) = TYPE_LENGTH (target_type); > TYPE_TARGET_STUB (type) = 0; > } > + else if (TYPE_CODE (type) == TYPE_CODE_ARRAY > + && TYPE_NFIELDS (type) == 1) Why is the `TYPE_NFIELDS (type) == 1` check necessary here? > + { > + struct type *range_type = check_typedef (TYPE_INDEX_TYPE (type)); > + if (TYPE_CODE (range_type) == TYPE_CODE_RANGE > + && has_static_range (TYPE_RANGE_DATA (range_type))) Is it possible to have an array type where the index type is not TYPE_CODE_RANGE? If it is not, then we should assert `TYPE_CODE (range_type) == TYPE_CODE_RANGE`. If it can be of another type, what are the other possibilities? > diff --git a/gdb/testsuite/gdb.cp/stub-array-size.exp b/gdb/testsuite/gdb.cp/stub-array-size.exp > new file mode 100644 > index 0000000000..cb486cd459 > --- /dev/null > +++ b/gdb/testsuite/gdb.cp/stub-array-size.exp > @@ -0,0 +1,27 @@ > +# Copyright 2020 Free Software Foundation, Inc. > +# > +# This program is free software; you can redistribute it and/or modify > +# it under the terms of the GNU General Public License as published by > +# the Free Software Foundation; either version 3 of the License, or > +# (at your option) any later version. > +# > +# This program is distributed in the hope that it will be useful, > +# but WITHOUT ANY WARRANTY; without even the implied warranty of > +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the > +# GNU General Public License for more details. > +# > +# You should have received a copy of the GNU General Public License > +# along with this program. If not, see . > + > +# This file is part of the gdb testsuite. Please add a short introductory comment that explains what this intends to test. Simon