From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 108169 invoked by alias); 19 Feb 2020 04:13:24 -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 108161 invoked by uid 89); 19 Feb 2020 04:13:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-5.2 required=5.0 tests=AWL,BAYES_00,SPF_HELO_PASS,SPF_PASS autolearn=ham version=3.3.1 spammy=stood, doublechecking, double-checking X-HELO: simark.ca Received: from simark.ca (HELO simark.ca) (158.69.221.121) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 19 Feb 2020 04:13:23 +0000 Received: from [10.0.0.11] (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)) (No client certificate requested) by simark.ca (Postfix) with ESMTPSA id 7836E1E47D; Tue, 18 Feb 2020 23:13:21 -0500 (EST) Subject: Re: [PATCH 03/14] Introduce dwarf2_per_objfile::obstack To: Tom Tromey , gdb-patches@sourceware.org References: <20200215165444.32653-1-tom@tromey.com> <20200215165444.32653-4-tom@tromey.com> From: Simon Marchi Message-ID: Date: Wed, 19 Feb 2020 04:13:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200215165444.32653-4-tom@tromey.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-SW-Source: 2020-02/txt/msg00758.txt.bz2 On 2020-02-15 11:54 a.m., Tom Tromey wrote: > Currently much of the DWARF-related data is stored on the obfile > obstack. This prevents sharing this data across objfiles, so this > patch adds a new obstack to dwarf2_per_objfile. > > One way to check whether this is correct is to look at the remaining > uses of objfile_obstack in the DWARF code and note that they all > appear in the "full CU" code paths. > > The converse -- storing per-objfile data on the shared obstack -- is > not good, but it is just a memory leak, not a potential > use-after-free. Double-checking this would also be useful, though. I looked and nothing wrong stood out, but there are a lot of uses and they are not all trivial, so I might have very well missed some mistakes. Kind of unrelated, but while reviewing this, I noticed: - allocate_dwo_file_hash_table - allocate_type_unit_groups_table - allocate_signatured_type_table - allocate_dwp_loaded_cutus_table - allocate_dwo_unit_table All have objfile parameters which are unused and could probably be removed. In at least one instance, it would allow removing ann objfile local variable. > @@ -3202,8 +3200,12 @@ dw2_get_real_path (struct objfile *objfile, > struct quick_file_names *qfn, int index) > { > if (qfn->real_names == NULL) > - qfn->real_names = OBSTACK_CALLOC (&objfile->objfile_obstack, > - qfn->num_file_names, const char *); > + { > + struct dwarf2_per_objfile *dwarf2_per_objfile > + = get_dwarf2_per_objfile (objfile); > + qfn->real_names = OBSTACK_CALLOC (&dwarf2_per_objfile->obstack, > + qfn->num_file_names, const char *); > + } The callers of dw2_get_real_path should be able to pass the dwarf2_per_objfile directly, instead of the objfile, simplifying this. Simon