From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Tom Tromey <tom@tromey.com>
Subject: [PATCH v2 04/42] Add dwarf2_per_objfile member to DWARF batons
Date: Tue, 12 May 2020 17:08:35 -0400 [thread overview]
Message-ID: <20200512210913.5593-5-simon.marchi@efficios.com> (raw)
In-Reply-To: <20200512210913.5593-1-simon.marchi@efficios.com>
From: Tom Tromey <tom@tromey.com>
Various DWARF callbacks expect to be able to fetch the objfile and / or
dwarf2_per_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
dwarf2_per_objfile they need.
This patch adds a per_objfile member to the various "baton" structures
and arranges to set this value when constructing the baton.
YYYY-MM-DD Tom Tromey <tom@tromey.com>
YYYY-MM-DD Simon Marchi <simon.marchi@efficios.com>
* dwarf2/loc.c (struct piece_closure) <per_objfile>: New member.
(allocate_piece_closure): Set "per_objfile" member.
(dwarf2_find_location_expression, dwarf2_locexpr_baton_eval)
(locexpr_describe_location, loclist_describe_location): Use new
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
per_objfile member.
* dwarf2/loc.h (struct dwarf2_locexpr_baton) <per_objfile>: New
member.
(struct dwarf2_loclist_baton) <per_objfile>: New member.
---
gdb/dwarf2/loc.c | 16 ++++++++++++----
gdb/dwarf2/loc.h | 8 +++++++-
gdb/dwarf2/read.c | 24 +++++++++++++++++-------
3 files changed, 36 insertions(+), 12 deletions(-)
diff --git a/gdb/dwarf2/loc.c b/gdb/dwarf2/loc.c
index 5b690ca9276..e4a9ee90311 100644
--- a/gdb/dwarf2/loc.c
+++ b/gdb/dwarf2/loc.c
@@ -317,7 +317,8 @@ const gdb_byte *
dwarf2_find_location_expression (struct dwarf2_loclist_baton *baton,
size_t *locexpr_length, CORE_ADDR pc)
{
- struct objfile *objfile = baton->per_cu->objfile ();
+ dwarf2_per_objfile *per_objfile = baton->per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = baton->per_cu->addr_size ();
@@ -1552,6 +1553,9 @@ struct piece_closure
/* Reference count. */
int refc = 0;
+ /* The objfile from which this closure's expression came. */
+ dwarf2_per_objfile *per_objfile = nullptr;
+
/* The CU from which this closure's expression came. */
struct dwarf2_per_cu_data *per_cu = NULL;
@@ -1574,6 +1578,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->per_objfile = per_cu->dwarf2_per_objfile;
c->per_cu = per_cu;
c->pieces = std::move (pieces);
if (frame == NULL)
@@ -2454,7 +2460,7 @@ dwarf2_locexpr_baton_eval (const struct dwarf2_locexpr_baton *dlbaton,
ctx.data_view = addr_stack->valaddr;
}
- objfile = dlbaton->per_cu->objfile ();
+ objfile = dlbaton->per_objfile->objfile;
ctx.gdbarch = objfile->arch ();
ctx.addr_size = dlbaton->per_cu->addr_size ();
@@ -4348,7 +4354,8 @@ locexpr_describe_location (struct symbol *symbol, CORE_ADDR addr,
{
struct dwarf2_locexpr_baton *dlbaton
= (struct dwarf2_locexpr_baton *) SYMBOL_LOCATION_BATON (symbol);
- struct objfile *objfile = dlbaton->per_cu->objfile ();
+ dwarf2_per_objfile *per_objfile = dlbaton->per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
unsigned int addr_size = dlbaton->per_cu->addr_size ();
int offset_size = dlbaton->per_cu->offset_size ();
@@ -4485,7 +4492,8 @@ loclist_describe_location (struct symbol *symbol, CORE_ADDR addr,
struct dwarf2_loclist_baton *dlbaton
= (struct dwarf2_loclist_baton *) SYMBOL_LOCATION_BATON (symbol);
const gdb_byte *loc_ptr, *buf_end;
- struct objfile *objfile = dlbaton->per_cu->objfile ();
+ dwarf2_per_objfile *per_objfile = dlbaton->per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
unsigned int addr_size = dlbaton->per_cu->addr_size ();
diff --git a/gdb/dwarf2/loc.h b/gdb/dwarf2/loc.h
index 9815368d625..51f242ec431 100644
--- a/gdb/dwarf2/loc.h
+++ b/gdb/dwarf2/loc.h
@@ -23,7 +23,7 @@
#include "dwarf2/expr.h"
struct symbol_computed_ops;
-struct objfile;
+struct dwarf2_per_objfile;
struct dwarf2_per_cu_data;
struct dwarf2_loclist_baton;
struct agent_expr;
@@ -146,6 +146,9 @@ struct dwarf2_locexpr_baton
directly. */
bool is_reference;
+ /* The objfile that was used when creating this. */
+ dwarf2_per_objfile *per_objfile;
+
/* The compilation unit containing the symbol whose location
we're computing. */
struct dwarf2_per_cu_data *per_cu;
@@ -163,6 +166,9 @@ struct dwarf2_loclist_baton
/* Length of the location list. */
size_t size;
+ /* The objfile that was used when creating this. */
+ dwarf2_per_objfile *per_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 9217f784b38..4699645c6fc 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -13199,7 +13199,8 @@ read_lexical_block_scope (struct die_info *die, struct dwarf2_cu *cu)
static void
read_call_site_scope (struct die_info *die, struct dwarf2_cu *cu)
{
- struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
+ dwarf2_per_objfile *per_objfile = cu->per_cu->dwarf2_per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
struct gdbarch *gdbarch = objfile->arch ();
CORE_ADDR pc, baseaddr;
struct attribute *attr;
@@ -13339,6 +13340,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->per_objfile = per_objfile;
dlbaton->per_cu = cu->per_cu;
SET_FIELD_DWARF_BLOCK (call_site->target, dlbaton);
@@ -16274,9 +16276,8 @@ mark_common_block_symbol_computed (struct symbol *sym,
struct attribute *member_loc,
struct dwarf2_cu *cu)
{
- struct dwarf2_per_objfile *dwarf2_per_objfile
- = cu->per_cu->dwarf2_per_objfile;
- struct objfile *objfile = dwarf2_per_objfile->objfile;
+ dwarf2_per_objfile *per_objfile = cu->per_cu->dwarf2_per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
struct dwarf2_locexpr_baton *baton;
gdb_byte *ptr;
unsigned int cu_off;
@@ -16289,6 +16290,7 @@ mark_common_block_symbol_computed (struct symbol *sym,
|| member_loc->form_is_constant ());
baton = XOBNEW (&objfile->objfile_obstack, struct dwarf2_locexpr_baton);
+ baton->per_objfile = per_objfile;
baton->per_cu = cu->per_cu;
gdb_assert (baton->per_cu);
@@ -17412,8 +17414,9 @@ 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;
+ dwarf2_per_objfile *per_objfile = cu->per_cu->dwarf2_per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
+ struct obstack *obstack = &objfile->objfile_obstack;
gdb_assert (default_type != NULL);
@@ -17425,6 +17428,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.per_objfile = per_objfile;
baton->locexpr.size = DW_BLOCK (attr)->size;
baton->locexpr.data = DW_BLOCK (attr)->data;
switch (attr->name)
@@ -17471,6 +17475,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.per_objfile = per_objfile;
baton->locexpr.size = DW_BLOCK (target_attr)->size;
baton->locexpr.data = DW_BLOCK (target_attr)->data;
baton->locexpr.is_reference = true;
@@ -21028,7 +21033,8 @@ dwarf2_const_value_attr (const struct attribute *attr, struct type *type,
LONGEST *value, const gdb_byte **bytes,
struct dwarf2_locexpr_baton **baton)
{
- struct objfile *objfile = cu->per_cu->dwarf2_per_objfile->objfile;
+ dwarf2_per_objfile *per_objfile = cu->per_cu->dwarf2_per_objfile;
+ struct objfile *objfile = per_objfile->objfile;
struct comp_unit_head *cu_header = &cu->header;
struct dwarf_block *blk;
enum bfd_endian byte_order = (bfd_big_endian (objfile->obfd) ?
@@ -21054,6 +21060,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)->per_objfile = per_objfile;
(*baton)->per_cu = cu->per_cu;
gdb_assert ((*baton)->per_cu);
@@ -22291,6 +22298,7 @@ dwarf2_fetch_die_loc_sect_off (sect_offset sect_off,
retval.data = DW_BLOCK (attr)->data;
retval.size = DW_BLOCK (attr)->size;
}
+ retval.per_objfile = dwarf2_per_objfile;
retval.per_cu = cu->per_cu;
age_cached_comp_units (dwarf2_per_objfile);
@@ -23140,6 +23148,7 @@ fill_in_loclist_baton (struct dwarf2_cu *cu,
section->read (dwarf2_per_objfile->objfile);
+ baton->per_objfile = dwarf2_per_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
@@ -23188,6 +23197,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->per_objfile = dwarf2_per_objfile;
baton->per_cu = cu->per_cu;
gdb_assert (baton->per_cu);
--
2.26.2
next prev parent reply other threads:[~2020-05-12 21:09 UTC|newest]
Thread overview: 92+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-12 21:08 [PATCH v2 00/42] Share DWARF partial symtabs between objfiles Simon Marchi
2020-05-12 21:08 ` [PATCH v2 01/42] Introduce dwarf2_per_objfile::obstack Simon Marchi
2020-05-12 21:08 ` [PATCH v2 02/42] Add "objfile" parameter to two partial_symtab methods Simon Marchi
2020-05-12 21:08 ` [PATCH v2 03/42] Add dwarf2_per_cu_data::index Simon Marchi
2020-05-12 21:08 ` Simon Marchi [this message]
2020-05-12 21:08 ` [PATCH v2 05/42] Split dwarf2_per_objfile into dwarf2_per_objfile and dwarf2_per_bfd Simon Marchi
2020-05-12 21:08 ` [PATCH v2 06/42] Remove symtab links from dwarf2_psymtab and dwarf2_per_cu_quick_data Simon Marchi
2020-05-12 21:08 ` [PATCH v2 07/42] Move die_type_hash to dwarf2_per_objfile Simon Marchi
2020-05-12 21:08 ` [PATCH v2 08/42] Add dwarf2_per_objfile field to dwarf2_cu Simon Marchi
2020-05-12 21:08 ` [PATCH v2 09/42] Remove reference to dwarf2_per_cu_data::dwarf2_per_objfile in dw2_do_instantiate_symtab Simon Marchi
2020-05-12 21:11 ` [PATCH v2 10/42] Remove dwarf2_cu->per_cu->dwarf2_per_objfile references Simon Marchi
2020-05-12 21:11 ` [PATCH v2 11/42] Add dwarf2_per_bfd field to dwarf2_per_cu_data Simon Marchi
2020-05-12 21:11 ` [PATCH v2 12/42] Make dwarf2_get_dwz_file take a dwarf2_per_bfd Simon Marchi
2020-05-12 21:11 ` [PATCH v2 13/42] Use bfd_get_filename instead of objfile_name in lookup_dwo_unit Simon Marchi
2020-05-12 21:11 ` [PATCH v2 14/42] Add dwarf2_per_objfile parameter to cutu_reader's constructors Simon Marchi
2020-05-12 21:11 ` [PATCH v2 15/42] Make queue_and_load_dwo_tu receive a dwarf2_cu Simon Marchi
2020-05-22 20:45 ` Tom Tromey
2020-05-25 19:10 ` Simon Marchi
2020-05-12 21:11 ` [PATCH v2 16/42] Remove dwarf2_per_cu_data::dwarf2_per_objfile reference in cutu_reader::keep Simon Marchi
2020-05-12 21:11 ` [PATCH v2 17/42] Add dwarf2_per_objfile parameter to create_partial_symtab Simon Marchi
2020-05-12 21:11 ` [PATCH v2 18/42] Add dwarf2_per_objfile parameter to recursively_compute_inclusions Simon Marchi
2020-05-12 21:11 ` [PATCH v2 19/42] Add dwarf2_per_objfile parameter to process_full_{comp, type}_unit Simon Marchi
2020-05-12 21:12 ` [PATCH v2 20/42] Pass dwarf2_cu objects to dwo-related functions, instead of dwarf2_per_cu_data Simon Marchi
2020-05-12 21:12 ` [PATCH v2 21/42] Remove reference to dwarf2_per_cu_data::dwarf2_per_objfile in queue_and_load_all_dwo_tus Simon Marchi
2020-05-12 21:12 ` [PATCH v2 22/42] Move int type methods out of dwarf2_per_cu_data Simon Marchi
2020-05-12 21:12 ` [PATCH v2 23/42] Add dwarf2_per_objfile to dwarf_expr_context and dwarf2_frame_cache Simon Marchi
2020-05-22 21:04 ` Tom Tromey
2020-05-25 19:50 ` Simon Marchi
2020-05-28 1:44 ` Simon Marchi
2020-05-12 21:12 ` [PATCH v2 24/42] Remove dwarf2_per_cu_data::text_offset Simon Marchi
2020-05-12 21:12 ` [PATCH v2 25/42] Add dwarf2_per_objfile parameter to dwarf2_read_addr_index Simon Marchi
2020-05-12 21:12 ` [PATCH v2 26/42] Add dwarf2_per_objfile parameter to allocate_piece_closure Simon Marchi
2020-05-12 21:12 ` [PATCH v2 27/42] Add dwarf2_per_objfile parameters to dwarf2_fetch_* functions Simon Marchi
2020-05-12 21:12 ` [PATCH v2 28/42] Remove dwarf2_per_cu_data::objfile () Simon Marchi
2020-05-27 16:27 ` Tom de Vries
2020-05-27 16:52 ` Tom de Vries
2020-05-27 20:03 ` Simon Marchi
2020-05-27 21:08 ` Tom de Vries
2020-05-27 21:55 ` Simon Marchi
2020-05-27 22:16 ` Simon Marchi
2020-05-28 2:00 ` Simon Marchi
2020-05-28 13:05 ` Tom de Vries
2020-05-28 15:33 ` Simon Marchi
2020-05-28 16:24 ` Christian Biesinger
2020-05-28 16:52 ` Simon Marchi
2020-05-28 19:49 ` Simon Marchi
2020-05-12 21:12 ` [PATCH v2 29/42] Add dwarf2_per_objfile parameter to free_one_cached_comp_unit Simon Marchi
2020-05-12 21:17 ` [PATCH v2 30/42] Add dwarf2_per_objfile parameter to get_die_type_at_offset Simon Marchi
2020-05-12 21:17 ` [PATCH v2 31/42] Remove leftover references to dwarf2_per_cu_data::dwarf2_per_objfile Simon Marchi
2020-05-12 21:17 ` [PATCH v2 32/42] Remove dwarf2_per_cu_data::dwarf2_per_objfile Simon Marchi
2020-05-12 21:17 ` [PATCH v2 33/42] Split type_unit_group Simon Marchi
2020-05-13 9:54 ` Tom de Vries
2020-05-13 15:06 ` Simon Marchi
2020-05-12 21:17 ` [PATCH v2 34/42] Move signatured_type::type to unshareable object Simon Marchi
2020-05-12 21:17 ` [PATCH v2 35/42] Pass dwarf2_per_bfd instead of dwarf2_per_objfile to some index-related functions Simon Marchi
2020-05-12 21:17 ` [PATCH v2 36/42] Pass dwarf2_cu to process_full_{comp,type}_unit Simon Marchi
2020-05-12 21:17 ` [PATCH v2 37/42] Make load_cu return the loaded dwarf2_cu Simon Marchi
2020-05-12 21:17 ` [PATCH v2 38/42] Add comp_unit_head to dwarf2_per_cu_data Simon Marchi
2020-05-12 21:17 ` [PATCH v2 39/42] Pass existing_cu object to cutu_reader Simon Marchi
2020-05-22 20:57 ` Tom Tromey
2020-05-25 19:10 ` Simon Marchi
2020-05-12 21:18 ` [PATCH v2 40/42] Replace dwarf2_per_cu_data::cu backlink with per-objfile map Simon Marchi
2020-05-12 21:18 ` [PATCH v2 41/42] Make mapped_debug_names independent of objfile Simon Marchi
2020-05-22 21:01 ` Tom Tromey
2020-05-25 19:53 ` Simon Marchi
2020-05-12 21:18 ` [PATCH v2 42/42] Share DWARF partial symtabs Simon Marchi
2020-05-13 10:17 ` [PATCH v2 00/42] Share DWARF partial symtabs between objfiles Tom de Vries
2020-05-13 15:46 ` Simon Marchi
2020-05-22 21:02 ` Tom Tromey
2020-05-25 19:53 ` Simon Marchi
2020-05-13 14:52 ` Simon Marchi
2020-05-22 21:07 ` Tom Tromey
2020-05-23 12:24 ` Pedro Alves
2020-05-25 19:56 ` Simon Marchi
2020-05-26 11:17 ` Pedro Alves
2020-05-26 15:35 ` Simon Marchi
2020-05-26 21:34 ` Simon Marchi
2020-05-27 5:08 ` Simon Marchi
2020-05-27 14:53 ` Simon Marchi
2020-05-27 15:51 ` Simon Marchi
2020-05-29 10:23 ` Tom de Vries
2020-05-29 12:55 ` Tom de Vries
2020-05-31 4:16 ` Simon Marchi
2020-05-31 14:22 ` Tom de Vries
2020-06-02 21:27 ` Simon Marchi
2020-06-04 17:55 ` Tom de Vries
2020-06-04 18:04 ` Simon Marchi
2020-06-10 3:43 ` Simon Marchi
2020-06-12 3:25 ` Tom Tromey
2020-05-27 14:50 ` [PATCH v2 41.5/42] Move line_header_hash to dwarf2_per_objfile Simon Marchi
2020-05-27 15:07 ` Tom Tromey
2020-05-27 15:10 ` Simon Marchi
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=20200512210913.5593-5-simon.marchi@efficios.com \
--to=simon.marchi@efficios.com \
--cc=gdb-patches@sourceware.org \
--cc=tom@tromey.com \
/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