From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30485 invoked by alias); 26 Jun 2009 17:36:47 -0000 Received: (qmail 30333 invoked by uid 22791); 26 Jun 2009 17:36:09 -0000 X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mtagate1.de.ibm.com (HELO mtagate1.de.ibm.com) (195.212.17.161) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 26 Jun 2009 17:36:04 +0000 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate1.de.ibm.com (8.13.1/8.13.1) with ESMTP id n5QHa1R1000750 for ; Fri, 26 Jun 2009 17:36:01 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v9.2) with ESMTP id n5QHa1EB3727452 for ; Fri, 26 Jun 2009 19:36:01 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n5QHa10l008067 for ; Fri, 26 Jun 2009 19:36:01 +0200 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with SMTP id n5QHa0s3008047; Fri, 26 Jun 2009 19:36:00 +0200 Message-Id: <200906261736.n5QHa0s3008047@d12av02.megacenter.de.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Fri, 26 Jun 2009 19:36:00 +0200 Subject: Re: [patch] [3/5] Types reference counting [make_function_type-objfile] To: tromey@redhat.com Date: Fri, 26 Jun 2009 17:36:00 -0000 From: "Ulrich Weigand" Cc: jan.kratochvil@redhat.com (Jan Kratochvil), gdb-patches@sourceware.org In-Reply-To: from "Tom Tromey" at Jun 26, 2009 11:24:04 AM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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 X-SW-Source: 2009-06/txt/msg00749.txt.bz2 Tom Tromey wrote: > >>>>> "Ulrich" == Ulrich Weigand writes: > > Ulrich> Mostly. We still can have the case were TYPE_OBJFILE(A) is NULL but > Ulrich> TYPE_OBJFILE(B) is non-NULL, for example where A is a temporary array > Ulrich> and B the element type. > > Ulrich> The way I see the invariant is > Ulrich> If Type A references Type B *and* A is objfile-associated > Ulrich> *then* B must be associated to the same objfile > > Suppose we have A as an array type with a NULL objfile, and with > element type B, which has an objfile. > > If we have a convenience variable of type A, and the objfile is > deleted, I don't think preserve_values will copy type B. That is > because we only check the value's immediate objfile to decide whether > we need to do a type copy. Hmm, good point. > Therefore it seems to me that the invariant must be TYPE_OBJFILE(A) == > TYPE_OBJFILE(B), for all related types A and B. I'm not sure how to best implement this invariant -- we *need* to support the case of a temporary array of pre-existing element types (e.g. for value_slice etc.) ... We don't want to allocate the temporary array types per-objfile, because then they will not be subject to garbage collection (and if the user does something that causes a lot of those arrays to be generated before the objfile is unloaded, this could cause a significant leak). I guess we could force the element type to be copied at the time the array type is allocated. In the alternative, we could change preserve_values to do the recursive check even if the main type is not objfile-associated. Bye, Ulrich -- Dr. Ulrich Weigand GNU Toolchain for Linux on System z and Cell BE Ulrich.Weigand@de.ibm.com