From patchwork Sat Feb 15 16:54:39 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Tromey X-Patchwork-Id: 38104 Received: (qmail 85946 invoked by alias); 15 Feb 2020 16:54:56 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 85573 invoked by uid 89); 15 Feb 2020 16:54:53 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-20.6 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS autolearn=ham version=3.3.1 spammy=closures, baton X-HELO: gateway24.websitewelcome.com Received: from gateway24.websitewelcome.com (HELO gateway24.websitewelcome.com) (192.185.50.252) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 15 Feb 2020 16:54:50 +0000 Received: from cm10.websitewelcome.com (cm10.websitewelcome.com [100.42.49.4]) by gateway24.websitewelcome.com (Postfix) with ESMTP id D97F420F70 for ; Sat, 15 Feb 2020 10:54:48 -0600 (CST) Received: from box5379.bluehost.com ([162.241.216.53]) by cmsmtp with SMTP id 30iOjdBZnEfyq30iOjm6cg; Sat, 15 Feb 2020 10:54:48 -0600 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tromey.com; s=default; h=References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Sender:Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=NahsOOiPZGK+I5wkrtNVN97CYWJ/QTyMHzsMM5gqpso=; b=xTQRsAzoiAyCt+euNmFdw+TuVK CVzcw0EXdUqIRWVHZLW+VkccFhzGFBrIIFsbKWpx3er0T34QATTQEXxW1b4Btv1RtUKwV46i++KMx nmA+jp7HaORVApBgClKO0xPWW; Received: from 75-166-123-50.hlrn.qwest.net ([75.166.123.50]:45240 helo=bapiya.Home) by box5379.bluehost.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92) (envelope-from ) id 1j30iO-000xcC-K8; Sat, 15 Feb 2020 09:54:48 -0700 From: Tom Tromey To: gdb-patches@sourceware.org Cc: Tom Tromey Subject: [PATCH 09/14] Add objfile member to DWARF batons Date: Sat, 15 Feb 2020 09:54:39 -0700 Message-Id: <20200215165444.32653-10-tom@tromey.com> In-Reply-To: <20200215165444.32653-1-tom@tromey.com> References: <20200215165444.32653-1-tom@tromey.com> Various DWARF callbacks expect to be able to fetch the objfile from the DWARF CU object. However, this won't be possible once sharing is implemented. Because these objects are related to full symbols (e.g., they are used to implement location expressions), they can simply store the objfile they need. This patch adds an objfile member to the various "baton" structures and arranges to set this value when constructing the baton. gdb/ChangeLog 2020-02-15 Tom Tromey * dwarf2/loc.c (struct piece_closure) : New member. (allocate_piece_closure): Set "objfile" member. * dwarf2/read.c (read_call_site_scope) (mark_common_block_symbol_computed, attr_to_dynamic_prop) (dwarf2_const_value_attr, dwarf2_fetch_die_loc_sect_off) (fill_in_loclist_baton, dwarf2_symbol_mark_computed): Set objfile member. * dwarf2/loc.h (struct dwarf2_locexpr_baton) : New member. (struct dwarf2_loclist_baton) : New member. --- gdb/ChangeLog | 13 +++++++++++++ gdb/dwarf2/loc.c | 5 +++++ gdb/dwarf2/loc.h | 6 ++++++ gdb/dwarf2/read.c | 12 ++++++++++-- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c index a9523e9f7ee..4a148c26722 100644 --- a/gdb/dwarf2/loc.c +++ b/gdb/dwarf2/loc.c @@ -1544,6 +1544,9 @@ struct piece_closure /* Reference count. */ int refc = 0; + /* The objfile from which this closure's expression came. */ + struct objfile *objfile = nullptr; + /* The CU from which this closure's expression came. */ struct dwarf2_per_cu_data *per_cu = NULL; @@ -1566,6 +1569,8 @@ allocate_piece_closure (struct dwarf2_per_cu_data *per_cu, struct piece_closure *c = new piece_closure; c->refc = 1; + /* We must capture this here due to sharing of DWARF state. */ + c->objfile = per_cu->objfile (); c->per_cu = per_cu; c->pieces = std::move (pieces); if (frame == NULL) diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h index 8fff663ebf9..51bcf6158a8 100644 --- a/gdb/dwarf2/loc.h +++ b/gdb/dwarf2/loc.h @@ -166,6 +166,9 @@ struct dwarf2_locexpr_baton directly. */ bool is_reference; + /* The objfile that was used when creating this. */ + struct objfile *objfile; + /* The compilation unit containing the symbol whose location we're computing. */ struct dwarf2_per_cu_data *per_cu; @@ -183,6 +186,9 @@ struct dwarf2_loclist_baton /* Length of the location list. */ size_t size; + /* The objfile that was used when creating this. */ + struct objfile *objfile; + /* The compilation unit containing the symbol whose location we're computing. */ struct dwarf2_per_cu_data *per_cu; diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 44fdb070e49..7b493f5a227 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -13298,6 +13298,7 @@ read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu) dlbaton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); dlbaton->data = DW_BLOCK (attr)->data; dlbaton->size = DW_BLOCK (attr)->size; + dlbaton->objfile = objfile; dlbaton->per_cu = cu->per_cu; SET_FIELD_DWARF_BLOCK (call_site->target, dlbaton); @@ -16018,6 +16019,7 @@ mark_common_block_symbol_computed (struct symbol *sym, || member_loc->form_is_constant ()); baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); + baton->objfile = objfile; baton->per_cu = cu->per_cu; gdb_assert (baton->per_cu); @@ -17119,8 +17121,8 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, struct type *default_type) { struct dwarf2_property_baton *baton; - struct obstack *obstack - = &cu->per_cu->dwarf2_per_objfile->objfile->objfile_obstack; + struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile; + struct obstack *obstack = &objfile->objfile_obstack; gdb_assert (default_type != NULL); @@ -17132,6 +17134,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, baton = XOBNEW (obstack, struct dwarf2_property_baton); baton->property_type = default_type; baton->locexpr.per_cu = cu->per_cu; + baton->locexpr.objfile = objfile; baton->locexpr.size = DW_BLOCK (attr)->size; baton->locexpr.data = DW_BLOCK (attr)->data; switch (attr->name) @@ -17178,6 +17181,7 @@ attr_to_dynamic_prop (const struct attribute *attr, struct die_info *die, baton = XOBNEW (obstack, struct dwarf2_property_baton); baton->property_type = die_type (target_die, target_cu); baton->locexpr.per_cu = cu->per_cu; + baton->locexpr.objfile = objfile; baton->locexpr.size = DW_BLOCK (target_attr)->size; baton->locexpr.data = DW_BLOCK (target_attr)->data; baton->locexpr.is_reference = true; @@ -21037,6 +21041,7 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type, piggyback on the existing location code rather than writing a new implementation of symbol_computed_ops. */ *baton = XOBNEW (obstack, struct dwarf2_locexpr_baton); + (*baton)->objfile = objfile; (*baton)->per_cu = cu->per_cu; gdb_assert ((*baton)->per_cu); @@ -22411,6 +22416,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off, retval.data = DW_BLOCK (attr)->data; retval.size = DW_BLOCK (attr)->size; } + retval.objfile = objfile; retval.per_cu = cu->per_cu; age_cached_comp_units (dwarf2_per_objfile); @@ -24051,6 +24057,7 @@ fill_in_loclist_baton (struct dwarf2_cu *cu, section->read (dwarf2_per_objfile->objfile); + baton->objfile = dwarf2_per_objfile->objfile; baton->per_cu = cu->per_cu; gdb_assert (baton->per_cu); /* We don't know how long the location list is, but make sure we @@ -24096,6 +24103,7 @@ dwarf2_symbol_mark_computed (const struct attribute *attr, struct symbol *sym, struct dwarf2_locexpr_baton *baton; baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton); + baton->objfile = objfile; baton->per_cu = cu->per_cu; gdb_assert (baton->per_cu);