aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@efficios.com>2020-05-27 11:13:52 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-27 11:15:54 -0400
commit9e021579fa12f4546a53d031f1293753305eec4b (patch)
treeb8e8a1b8fbaa264f5d9a9d67520baf3303297ad8
parentae090bdbf8876d4f72f357cf78301b5e8ec13751 (diff)
downloadgdb-9e021579fa12f4546a53d031f1293753305eec4b.zip
gdb-9e021579fa12f4546a53d031f1293753305eec4b.tar.gz
gdb-9e021579fa12f4546a53d031f1293753305eec4b.tar.bz2
Add dwarf2_per_objfile field to dwarf2_cu
Subsequent patches will make dwarf2_per_cu_data objfile-independent. This means that the dwarf2_per_cu_data::dwarf2_per_objfile field must go. The code using a dwarf2_cu structure currently accesses the current dwarf2_per_objfile object through dwarf2_cu->per_cu->dwarf2_per_objfile. Since it's ok for the dwarf2_cu to know about the current objfile (a dwarf2_cu is always used in the context of a particular objfile), add a dwarf2_per_objfile field to dwarf2_cu. Upcoming patches will gradually remove uses of dwarf2_per_cu_data::dwarf2_per_objfile in favor of dwarf2_cu::dwarf2_per_objfile, until the former can be removed. gdb/ChangeLog: * dwarf2/read.c (struct dwarf2_cu) <dwarf2_cu>: Add parameter. <per_objfile>: New member. (class cutu_reader) <init_tu_and_read_dwo_dies>: Add parameter. (cutu_reader::init_tu_and_read_dwo_dies): Add parameter, update call to dwarf2_cu. (cutu_reader::cutu_reader): Update. (dwarf2_cu::dwarf2_cu): Add parameter, initialize per_objfile. Change-Id: I8fd0da7371f65baea1ea7787aad08e10453bc565
-rw-r--r--gdb/ChangeLog10
-rw-r--r--gdb/dwarf2/read.c28
2 files changed, 28 insertions, 10 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 76b8d7b..436da4d 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,5 +1,15 @@
2020-05-27 Simon Marchi <simon.marchi@efficios.com>
+ * dwarf2/read.c (struct dwarf2_cu) <dwarf2_cu>: Add parameter.
+ <per_objfile>: New member.
+ (class cutu_reader) <init_tu_and_read_dwo_dies>: Add parameter.
+ (cutu_reader::init_tu_and_read_dwo_dies): Add parameter, update
+ call to dwarf2_cu.
+ (cutu_reader::cutu_reader): Update.
+ (dwarf2_cu::dwarf2_cu): Add parameter, initialize per_objfile.
+
+2020-05-27 Simon Marchi <simon.marchi@efficios.com>
+
* dwarf2/read.h (struct dwarf2_per_bfd) <die_type_hash>: Move to
struct dwarf2_per_objfile.
(struct dwarf2_per_objfile) <die_type_hash>: Move from struct
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index aa39c88..ef64d13 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -399,7 +399,8 @@ struct delayed_method_info
/* Internal state when decoding a particular compilation unit. */
struct dwarf2_cu
{
- explicit dwarf2_cu (struct dwarf2_per_cu_data *per_cu);
+ explicit dwarf2_cu (dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile);
~dwarf2_cu ();
DISABLE_COPY_AND_ASSIGN (dwarf2_cu);
@@ -466,6 +467,9 @@ public:
/* Backlink to our per_cu entry. */
struct dwarf2_per_cu_data *per_cu;
+ /* The dwarf2_per_objfile that owns this. */
+ struct dwarf2_per_objfile *per_objfile;
+
/* How many compilation units ago was this CU last referenced? */
int last_used = 0;
@@ -928,7 +932,8 @@ public:
void keep ();
private:
- void init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
+ void init_tu_and_read_dwo_dies (dwarf2_per_cu_data *this_cu,
+ dwarf2_per_objfile *per_objfile,
int use_existing_cu);
struct dwarf2_per_cu_data *m_this_cu;
@@ -6888,7 +6893,8 @@ lookup_dwo_unit (struct dwarf2_per_cu_data *this_cu,
Read a TU directly from a DWO file, bypassing the stub. */
void
-cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
+cutu_reader::init_tu_and_read_dwo_dies (dwarf2_per_cu_data *this_cu,
+ dwarf2_per_objfile *per_objfile,
int use_existing_cu)
{
struct signatured_type *sig_type;
@@ -6909,7 +6915,7 @@ cutu_reader::init_tu_and_read_dwo_dies (struct dwarf2_per_cu_data *this_cu,
{
/* If !use_existing_cu, this_cu->cu must be NULL. */
gdb_assert (this_cu->cu == NULL);
- m_new_cu.reset (new dwarf2_cu (this_cu));
+ m_new_cu.reset (new dwarf2_cu (this_cu, per_objfile));
}
/* A future optimization, if needed, would be to use an existing
@@ -6970,7 +6976,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
/* Narrow down the scope of possibilities to have to understand. */
gdb_assert (this_cu->is_debug_types);
gdb_assert (abbrev_table == NULL);
- init_tu_and_read_dwo_dies (this_cu, use_existing_cu);
+ init_tu_and_read_dwo_dies (this_cu, dwarf2_per_objfile, use_existing_cu);
return;
}
@@ -6997,7 +7003,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
{
/* If !use_existing_cu, this_cu->cu must be NULL. */
gdb_assert (this_cu->cu == NULL);
- m_new_cu.reset (new dwarf2_cu (this_cu));
+ m_new_cu.reset (new dwarf2_cu (this_cu, dwarf2_per_objfile));
cu = m_new_cu.get ();
}
@@ -7189,7 +7195,7 @@ cutu_reader::cutu_reader (struct dwarf2_per_cu_data *this_cu,
/* This is cheap if the section is already read in. */
section->read (objfile);
- m_new_cu.reset (new dwarf2_cu (this_cu));
+ m_new_cu.reset (new dwarf2_cu (this_cu, dwarf2_per_objfile));
begin_info_ptr = info_ptr = section->buffer + to_underlying (this_cu->sect_off);
info_ptr = read_and_check_comp_unit_head (dwarf2_per_objfile,
@@ -23514,10 +23520,12 @@ run_test ()
#endif /* GDB_SELF_TEST */
-/* Initialize dwarf2_cu CU, owned by PER_CU. */
+/* Initialize dwarf2_cu to read PER_CU, in the context of PER_OBJFILE. */
-dwarf2_cu::dwarf2_cu (struct dwarf2_per_cu_data *per_cu_)
- : per_cu (per_cu_),
+dwarf2_cu::dwarf2_cu (dwarf2_per_cu_data *per_cu,
+ dwarf2_per_objfile *per_objfile)
+ : per_cu (per_cu),
+ per_objfile (per_objfile),
mark (false),
has_loclist (false),
checked_producer (false),