From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 45935 invoked by alias); 29 Nov 2018 23:26:22 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 45914 invoked by uid 89); 29 Nov 2018 23:26:21 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-6.9 required=5.0 tests=BAYES_00,GIT_PATCH_1,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=H*UA:6.1 X-HELO: aserp2120.oracle.com Received: from aserp2120.oracle.com (HELO aserp2120.oracle.com) (141.146.126.78) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 29 Nov 2018 23:26:17 +0000 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wATNOQrb090654; Thu, 29 Nov 2018 23:26:14 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2018-07-02; bh=dxdkDuj3gIrefFjxXtSnMh9IrPUSTvmgQev+ti4JvtQ=; b=ir6wu5HChtwT2a5nMEj7wWhd3FlVhnSkscUeyQIZFS3PNcxYioLBSTZ2sgeC7Ui6Luhi p9tXwu3KgJviqlknDVL7TSPVmRFyR2w5Q2KKuHlvZX43rmaOthugjoPJQi0Ujl9mdwfw XVtJrC1/aZdVGKx6UV8SQB+YFP0CZ9VQqugKw8kL2rNMjbBdF+fWF/ON1L1B1YzN57A1 soXK8GxjXOzNqfBDaSXNhYCelYF3Pw5ANzhQRNwsR+mVcwxFOVbKvf+3FxU7vK69siVN Q3cO7KEBGijKkR/gPwI6BT/MQy8SZSdNzgWKedjZ+leyLTrLNWTYuw7i3mLEgov/gaXi 2w== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by aserp2120.oracle.com with ESMTP id 2nxxkqu5qn-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Nov 2018 23:26:14 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wATNQDK6010671 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Nov 2018 23:26:13 GMT Received: from abhmp0013.oracle.com (abhmp0013.oracle.com [141.146.116.19]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id wATNQC4h013855; Thu, 29 Nov 2018 23:26:12 GMT Received: from [10.159.237.89] (/10.159.237.89) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 29 Nov 2018 15:26:12 -0800 Subject: Re: [PATCH PR gdb/20057] Internal error on trying to set {char[]}$pc="string" To: Tom Tromey Cc: Joel Brobecker , gdb-patches@sourceware.org References: <1516844738-79996-1-git-send-email-weimin.pan@oracle.com> <20180125041431.tghhxefsgxnxh3l3@adacore.com> <1dfc87b0-353d-3388-a427-fee247dc79a5@oracle.com> <20180131074526.rqbsjxyxp3p26js5@adacore.com> <1d28e9c6-6377-0c46-6bce-1dc25a7fa2d5@oracle.com> <20180201075955.mnqxzmw4ktuy3f5d@adacore.com> <20181114235153.GB4336@adacore.com> <87tvjzae0u.fsf@tromey.com> <82a6d5fc-7152-88aa-115b-c767fd3f3569@oracle.com> <87lg5ba6vl.fsf@tromey.com> From: Wei-min Pan Message-ID: <4107cd46-1978-93a8-1f54-6e1622ffe191@oracle.com> Date: Thu, 29 Nov 2018 23:26:00 -0000 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <87lg5ba6vl.fsf@tromey.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2018-11/txt/msg00560.txt.bz2 On 11/29/2018 1:52 PM, Tom Tromey wrote: >>>>>> ">" == Wei-min Pan writes: >>> Looks like we have at least 2 options: >>> (1) Making sure the type is objfile-owned before calling copy_type in >>> resolve_dynamic_range and resolve_dynamic_array as you suggested, or >>> (2) Replacing the assert with an objfile-owned check in copy_type, similar >>> to what copy_type_recursive does. > Sorry, I still didn't read the whole thread... but I think what to do > depends on what is happening. > > Most callers of copy_type are probably copying it to modify the copy. > If this is the case, then maybe just removing the assert is ok. > Or, maybe it makes sense to understand why the modified type isn't > objfile-allocated in the first place. > > Could you recap? What is calling copy_type here and where did the type > come from? > > Tom Let's use an example: (gdb) p {char []}$pc if the element type "char" is defined in the program, i.e. it has an objfile, lookup_array_range_type sets the "index type" with that objfile's builtin_int. Otherwise, it sets it with gdbarch's built-in. The index type is then used to create the range type and the array type. Thus the array type is entirely either objfile-owned or gdbarch-owned. Both resolve_dynamic_array and resolve_dynamic_range call copy_type to allocate a type and yes modify it to represent a static version of the array type from lookup_array_range_type() above.