From: Simon Marchi <simon.marchi@efficios.com>
To: gdb-patches@sourceware.org
Cc: Simon Marchi <simon.marchi@efficios.com>
Subject: [PATCH v2 20/42] Pass dwarf2_cu objects to dwo-related functions, instead of dwarf2_per_cu_data
Date: Tue, 12 May 2020 17:12:28 -0400 [thread overview]
Message-ID: <20200512211250.6230-21-simon.marchi@efficios.com> (raw)
In-Reply-To: <20200512210913.5593-1-simon.marchi@efficios.com>
This allows removing references to the
dwarf2_per_cu_data::dwarf2_per_objfile field.
I am not too sure of the code flow here, but ultimately
open_and_init_dwo_file calls create_cus_hash_table, and passes it
per_cu->cu. create_cus_hash_table requires a dwarf2_cu to pass to
cutu_reader, as the "parent_cu".
The dwarf2_per_cu_data::cu link is only set when in a certain context.
It's not easy to convince myself in which situations it's safe to use
it. Instead, if a function is going to use a dwarf2_cu, I think it's
simpler if it takes that object directly. If it needs access to the
corresponding dwarf2_per_cu_data object, then it can used the
dwarf2_cu::per_cu field, which we know is always set.
This patch adds some references to dwarf2_per_cu_data::cu in the
cutu_reader context. In this context, we know this field will be set,
as it's cutu_reader that is responsible for instantiating the dwarf2_cu
and assigning the field.
gdb/ChangeLog:
* dwarf2/read.c (lookup_dwo_comp_unit): Change
dwarf2_per_cu_data parameter fo dwarf2_cu.
(lookup_dwo_type_unit): Likewise.
(read_cutu_die_from_dwo): Likewise.
(lookup_dwo_unit): Likewise.
(open_and_init_dwo_file): Likewise.
(lookup_dwo_cutu): Likewise.
(lookup_dwo_comp_unit): Likewise.
(lookup_dwo_type_unit): Likewise.
(cutu_reader::init_tu_and_read_dwo_dies): Update.
(cutu_reader::cutu_reader): Update.
---
gdb/dwarf2/read.c | 84 ++++++++++++++++++++++-------------------------
1 file changed, 39 insertions(+), 45 deletions(-)
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 906a0ade2ce..5dc8a350739 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1672,10 +1672,11 @@ static struct dwp_file *get_dwp_file
(struct dwarf2_per_objfile *dwarf2_per_objfile);
static struct dwo_unit *lookup_dwo_comp_unit
- (struct dwarf2_per_cu_data *, const char *, const char *, ULONGEST);
+ (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir,
+ ULONGEST signature);
static struct dwo_unit *lookup_dwo_type_unit
- (struct signatured_type *, const char *, const char *);
+ (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir);
static void queue_and_load_all_dwo_tus (struct dwarf2_per_cu_data *);
@@ -6650,7 +6651,7 @@ init_cu_die_reader (struct die_reader_specs *reader,
The result is non-zero if a valid (non-dummy) DIE was found. */
static int
-read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
+read_cutu_die_from_dwo (dwarf2_cu *cu,
struct dwo_unit *dwo_unit,
struct die_info *stub_comp_unit_die,
const char *stub_comp_dir,
@@ -6659,9 +6660,9 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
struct die_info **result_comp_unit_die,
abbrev_table_up *result_dwo_abbrev_table)
{
- struct dwarf2_per_objfile *dwarf2_per_objfile = this_cu->dwarf2_per_objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile;
+ dwarf2_per_cu_data *per_cu = cu->per_cu;
struct objfile *objfile = dwarf2_per_objfile->objfile;
- struct dwarf2_cu *cu = this_cu->cu;
bfd *abfd;
const gdb_byte *begin_info_ptr, *info_ptr;
struct attribute *comp_dir, *stmt_list, *low_pc, *high_pc, *ranges;
@@ -6690,7 +6691,7 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
{
/* For TUs in DWO files, the DW_AT_stmt_list attribute lives in the
DWO file. */
- if (! this_cu->is_debug_types)
+ if (!per_cu->is_debug_types)
stmt_list = dwarf2_attr (stub_comp_unit_die, DW_AT_stmt_list, cu);
low_pc = dwarf2_attr (stub_comp_unit_die, DW_AT_low_pc, cu);
high_pc = dwarf2_attr (stub_comp_unit_die, DW_AT_high_pc, cu);
@@ -6723,9 +6724,9 @@ read_cutu_die_from_dwo (struct dwarf2_per_cu_data *this_cu,
+ to_underlying (dwo_unit->sect_off));
dwo_abbrev_section = &dwo_unit->dwo_file->sections.abbrev;
- if (this_cu->is_debug_types)
+ if (per_cu->is_debug_types)
{
- struct signatured_type *sig_type = (struct signatured_type *) this_cu;
+ signatured_type *sig_type = (struct signatured_type *) per_cu;
info_ptr = read_and_check_comp_unit_head (dwarf2_per_objfile,
&cu->header, section,
@@ -6836,11 +6837,9 @@ lookup_dwo_id (struct dwarf2_cu *cu, struct die_info* comp_unit_die)
Returns NULL if the specified DWO unit cannot be found. */
static struct dwo_unit *
-lookup_dwo_unit (struct dwarf2_per_cu_data *this_cu,
- struct die_info *comp_unit_die,
- const char *dwo_name)
+lookup_dwo_unit (dwarf2_cu *cu, die_info *comp_unit_die, const char *dwo_name)
{
- struct dwarf2_cu *cu = this_cu->cu;
+ dwarf2_per_cu_data *per_cu = cu->per_cu;
struct dwo_unit *dwo_unit;
const char *comp_dir;
@@ -6850,24 +6849,18 @@ lookup_dwo_unit (struct dwarf2_per_cu_data *this_cu,
dwo_name = dwarf2_dwo_name (comp_unit_die, cu);
comp_dir = dwarf2_string_attr (comp_unit_die, DW_AT_comp_dir, cu);
- if (this_cu->is_debug_types)
- {
- struct signatured_type *sig_type;
-
- /* Since this_cu is the first member of struct signatured_type,
- we can go from a pointer to one to a pointer to the other. */
- sig_type = (struct signatured_type *) this_cu;
- dwo_unit = lookup_dwo_type_unit (sig_type, dwo_name, comp_dir);
- }
+ if (per_cu->is_debug_types)
+ dwo_unit = lookup_dwo_type_unit (cu, dwo_name, comp_dir);
else
{
gdb::optional<ULONGEST> signature = lookup_dwo_id (cu, comp_unit_die);
+
if (!signature.has_value ())
error (_("Dwarf Error: missing dwo_id for dwo_name %s"
" [in module %s]"),
- dwo_name, bfd_get_filename (this_cu->per_bfd->obfd));
- dwo_unit = lookup_dwo_comp_unit (this_cu, dwo_name, comp_dir,
- *signature);
+ dwo_name, bfd_get_filename (per_cu->per_bfd->obfd));
+
+ dwo_unit = lookup_dwo_comp_unit (cu, dwo_name, comp_dir, *signature);
}
return dwo_unit;
@@ -6907,7 +6900,7 @@ cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu_data *this_cu,
abbrev table. When reading DWOs with skeletonless TUs, all the TUs
could share abbrev tables. */
- if (read_cutu_die_from_dwo (this_cu, sig_type->dwo_unit,
+ if (read_cutu_die_from_dwo (this_cu->cu, sig_type->dwo_unit,
NULL /* stub_comp_unit_die */,
sig_type->dwo_unit->dwo_file->comp_dir,
this, &info_ptr,
@@ -7094,10 +7087,10 @@ cutu_reader::cutu_reader (dwarf2_per_cu_data *this_cu,
sect_offset_str (this_cu->sect_off),
bfd_get_filename (abfd));
}
- dwo_unit = lookup_dwo_unit (this_cu, comp_unit_die, dwo_name);
+ dwo_unit = lookup_dwo_unit (cu, comp_unit_die, dwo_name);
if (dwo_unit != NULL)
{
- if (read_cutu_die_from_dwo (this_cu, dwo_unit,
+ if (read_cutu_die_from_dwo (cu, dwo_unit,
comp_unit_die, NULL,
this, &info_ptr,
&dwo_comp_unit_die,
@@ -12325,10 +12318,10 @@ dwarf2_locate_dwo_sections (bfd *abfd, asection *sectp, void *dwo_sections_ptr)
The result is NULL if DWO_NAME can't be found. */
static struct dwo_file *
-open_and_init_dwo_file (struct dwarf2_per_cu_data *per_cu,
- const char *dwo_name, const char *comp_dir)
+open_and_init_dwo_file (dwarf2_cu *cu, const char *dwo_name,
+ const char *comp_dir)
{
- struct dwarf2_per_objfile *dwarf2_per_objfile = per_cu->dwarf2_per_objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile;
gdb_bfd_ref_ptr dbfd = open_dwo_file (dwarf2_per_objfile, dwo_name, comp_dir);
if (dbfd == NULL)
@@ -12346,7 +12339,7 @@ open_and_init_dwo_file (struct dwarf2_per_cu_data *per_cu,
bfd_map_over_sections (dwo_file->dbfd.get (), dwarf2_locate_dwo_sections,
&dwo_file->sections);
- create_cus_hash_table (dwarf2_per_objfile, per_cu->cu, *dwo_file,
+ create_cus_hash_table (dwarf2_per_objfile, cu, *dwo_file,
dwo_file->sections.info, dwo_file->cus);
create_debug_types_hash_table (dwarf2_per_objfile, dwo_file.get (),
@@ -12657,11 +12650,10 @@ get_dwp_file (struct dwarf2_per_objfile *dwarf2_per_objfile)
(dwo_id mismatch or couldn't find the DWO/DWP file). */
static struct dwo_unit *
-lookup_dwo_cutu (struct dwarf2_per_cu_data *this_unit,
- const char *dwo_name, const char *comp_dir,
+lookup_dwo_cutu (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir,
ULONGEST signature, int is_debug_types)
{
- struct dwarf2_per_objfile *dwarf2_per_objfile = this_unit->dwarf2_per_objfile;
+ struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile;
struct objfile *objfile = dwarf2_per_objfile->objfile;
const char *kind = is_debug_types ? "TU" : "CU";
void **dwo_file_slot;
@@ -12707,7 +12699,7 @@ lookup_dwo_cutu (struct dwarf2_per_cu_data *this_unit,
if (*dwo_file_slot == NULL)
{
/* Read in the file and build a table of the CUs/TUs it contains. */
- *dwo_file_slot = open_and_init_dwo_file (this_unit, dwo_name, comp_dir);
+ *dwo_file_slot = open_and_init_dwo_file (cu, dwo_name, comp_dir);
}
/* NOTE: This will be NULL if unable to open the file. */
dwo_file = (struct dwo_file *) *dwo_file_slot;
@@ -12772,10 +12764,8 @@ lookup_dwo_cutu (struct dwarf2_per_cu_data *this_unit,
warning (_("Could not find DWO %s %s(%s)%s referenced by %s at offset %s"
" [in module %s]"),
- kind, dwo_name, hex_string (signature),
- dwp_text.c_str (),
- this_unit->is_debug_types ? "TU" : "CU",
- sect_offset_str (this_unit->sect_off), objfile_name (objfile));
+ kind, dwo_name, hex_string (signature), dwp_text.c_str (), kind,
+ sect_offset_str (cu->per_cu->sect_off), objfile_name (objfile));
}
return NULL;
}
@@ -12784,21 +12774,25 @@ lookup_dwo_cutu (struct dwarf2_per_cu_data *this_unit,
See lookup_dwo_cutu_unit for details. */
static struct dwo_unit *
-lookup_dwo_comp_unit (struct dwarf2_per_cu_data *this_cu,
- const char *dwo_name, const char *comp_dir,
+lookup_dwo_comp_unit (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir,
ULONGEST signature)
{
- return lookup_dwo_cutu (this_cu, dwo_name, comp_dir, signature, 0);
+ gdb_assert (!cu->per_cu->is_debug_types);
+
+ return lookup_dwo_cutu (cu, dwo_name, comp_dir, signature, 0);
}
/* Lookup the DWO TU DWO_NAME/SIGNATURE referenced from THIS_TU.
See lookup_dwo_cutu_unit for details. */
static struct dwo_unit *
-lookup_dwo_type_unit (struct signatured_type *this_tu,
- const char *dwo_name, const char *comp_dir)
+lookup_dwo_type_unit (dwarf2_cu *cu, const char *dwo_name, const char *comp_dir)
{
- return lookup_dwo_cutu (&this_tu->per_cu, dwo_name, comp_dir, this_tu->signature, 1);
+ gdb_assert (cu->per_cu->is_debug_types);
+
+ signatured_type *sig_type = (signatured_type *) cu->per_cu;
+
+ return lookup_dwo_cutu (cu, dwo_name, comp_dir, sig_type->signature, 1);
}
/* Traversal function for queue_and_load_all_dwo_tus. */
--
2.26.2
next prev parent reply other threads:[~2020-05-12 21:15 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 ` [PATCH v2 04/42] Add dwarf2_per_objfile member to DWARF batons Simon Marchi
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 ` Simon Marchi [this message]
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=20200512211250.6230-21-simon.marchi@efficios.com \
--to=simon.marchi@efficios.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