From: Tom Tromey <tom@tromey.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH 09/14] Add objfile member to DWARF batons
Date: Sat, 15 Feb 2020 16:55:00 -0000 [thread overview]
Message-ID: <20200215165444.32653-10-tom@tromey.com> (raw)
In-Reply-To: <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 <tom@tromey.com>
* dwarf2/loc.c (struct piece_closure) <objfile>: 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) <objfile>: New
member.
(struct dwarf2_loclist_baton) <objfile>: 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);
--
2.17.2
next prev parent reply other threads:[~2020-02-15 16:54 UTC|newest]
Thread overview: 59+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-15 16:54 [PATCH 00/14] Share DWARF partial symtabs between objfiles Tom Tromey
2020-02-15 16:55 ` [PATCH 07/14] Add dwarf2_per_cu_data::index Tom Tromey
2020-02-18 11:39 ` Luis Machado
2020-02-21 23:36 ` Tom Tromey
2020-02-19 4:36 ` Simon Marchi
2020-02-19 5:31 ` Simon Marchi
2020-02-21 23:41 ` Tom Tromey
2020-02-21 23:41 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 06/14] Add "objfile" parameter to two partial_symtab methods Tom Tromey
2020-02-18 11:26 ` Luis Machado
2020-02-15 16:55 ` [PATCH 10/14] Introduce dwarf2_enter_objfile and use it Tom Tromey
2020-02-18 11:58 ` Luis Machado
2020-02-21 22:54 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 14/14] Share DWARF partial symtabs Tom Tromey
2020-02-18 12:26 ` Luis Machado
2020-02-21 23:03 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 05/14] Introduce dwarf2_unshareable and move die_type_hash Tom Tromey
2020-02-18 11:23 ` Luis Machado
2020-02-19 4:20 ` Simon Marchi
2020-02-21 22:43 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 11/14] Split type_unit_group Tom Tromey
2020-02-18 12:08 ` Luis Machado
2020-02-22 0:40 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 03/14] Introduce dwarf2_per_objfile::obstack Tom Tromey
2020-02-19 4:13 ` Simon Marchi
2020-02-22 0:44 ` Tom Tromey
2020-02-15 16:55 ` [PATCH 12/14] Fix a memory leak and remove an unused member Tom Tromey
2020-02-15 16:55 ` [PATCH 02/14] Simplify setting of reading_partial_symbols Tom Tromey
2020-02-15 16:55 ` Tom Tromey [this message]
2020-02-15 16:55 ` [PATCH 01/14] Fix latent bug in dwarf2_find_containing_comp_unit Tom Tromey
2020-02-19 3:42 ` Simon Marchi
2020-02-19 14:08 ` Tom Tromey
2020-02-20 0:11 ` Tom Tromey
2020-02-20 0:12 ` Tom Tromey
[not found] ` <3a3f1f39-c715-58ba-06a8-2980afb82c53@simark.ca>
2020-02-20 16:50 ` Tom Tromey
2020-03-07 19:12 ` Christian Biesinger
2020-02-15 16:55 ` [PATCH 13/14] Move signatured_type::type to unshareable object Tom Tromey
2020-02-15 16:55 ` [PATCH 04/14] Convert IS_TYPE_UNIT_GROUP to method Tom Tromey
2020-02-15 16:55 ` [PATCH 08/14] Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data Tom Tromey
2020-02-18 11:50 ` Luis Machado
2020-02-19 4:47 ` Simon Marchi
2020-02-22 0:38 ` Tom Tromey
2020-02-22 0:36 ` Tom Tromey
2020-02-17 12:31 ` [PATCH 00/14] Share DWARF partial symtabs between objfiles Luis Machado
2020-02-17 16:59 ` Tom Tromey
2020-02-22 21:50 ` Tom de Vries
2020-02-22 22:01 ` Tom Tromey
2020-02-23 2:37 ` Simon Marchi
2020-02-23 23:58 ` Tom Tromey
2020-02-24 2:52 ` Simon Marchi
2020-02-24 3:07 ` Tom Tromey
2020-02-24 3:22 ` Tom Tromey
2020-02-24 13:42 ` Tom de Vries
2020-02-24 16:00 ` Tom de Vries
2020-02-24 17:29 ` Tom Tromey
2020-02-24 23:15 ` Tom Tromey
2020-02-24 19:18 ` Simon Marchi
2020-02-24 23:20 ` Tom Tromey
2020-02-24 22:48 ` Tom Tromey
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200215165444.32653-10-tom@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox