aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-05-27 11:13:54 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-27 11:15:54 -0400
commit1859c670e9979c1e58ed4e9d83085f732e6936f5 (patch)
treee41af8237a87c90c2924b16e758981a863e3e6b6
parent5e22e966a02123478a3c5e067f911a3d180060af (diff)
downloadbinutils-1859c670e9979c1e58ed4e9d83085f732e6936f5.zip
binutils-1859c670e9979c1e58ed4e9d83085f732e6936f5.tar.gz
binutils-1859c670e9979c1e58ed4e9d83085f732e6936f5.tar.bz2
Add dwarf2_per_bfd field to dwarf2_per_cu_data
Some code using dwarf2_per_cu_data objects accesses the corresponding dwarf2_per_bfd using the following pattern: per_cu->dwarf2_per_objfile->per_bfd Since dwarf2_per_cu_data objects are going to become objfile-independent, the dwarf2_per_objfile link must go. To replace it, add a dwarf2_per_cu_data->per_bfd link. It makes sense to have it there because the dwarf2_per_cu_data objects belong to the dwarf2_per_bfd, so this is essentially just a backlink to their owner. gdb/ChangeLog: * dwarf2/read.h (struct dwarf2_per_cu_data) <per_bfd>: New member. * dwarf2/read.c (dwarf2_per_bfd::allocate_per_cu): Initialize dwarf2_per_cu_data::per_bfd. (dwarf2_per_bfd::allocate_signatured_type): Likewise. (create_type_unit_group): Likewise. (queue_comp_unit): Remove reference to per_cu->dwarf2_per_objfile. (maybe_queue_comp_unit): Likewise. (fill_in_sig_entry_from_dwo_entry): Assign new field. (create_cus_hash_table): Assign new field. Change-Id: I4ba0a393e64a14489ef061261a3dede1509d055b
-rw-r--r--gdb/ChangeLog14
-rw-r--r--gdb/dwarf2/read.c21
-rw-r--r--gdb/dwarf2/read.h3
3 files changed, 32 insertions, 6 deletions
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index e2a7a5f..799d1ed 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,17 @@
+2020-05-27 Simon Marchi <simon.marchi@polymtl.ca>
+
+ * dwarf2/read.h (struct dwarf2_per_cu_data) <per_bfd>: New
+ member.
+ * dwarf2/read.c (dwarf2_per_bfd::allocate_per_cu): Initialize
+ dwarf2_per_cu_data::per_bfd.
+ (dwarf2_per_bfd::allocate_signatured_type): Likewise.
+ (create_type_unit_group): Likewise.
+ (queue_comp_unit): Remove reference to
+ per_cu->dwarf2_per_objfile.
+ (maybe_queue_comp_unit): Likewise.
+ (fill_in_sig_entry_from_dwo_entry): Assign new field.
+ (create_cus_hash_table): Assign new field.
+
2020-05-27 Simon Marchi <simon.marchi@efficios.com>
* dwarf2/read.c: Replace
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index 294afc9..da1638d 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -2447,6 +2447,7 @@ dwarf2_per_cu_data *
dwarf2_per_bfd::allocate_per_cu ()
{
dwarf2_per_cu_data *result = OBSTACK_ZALLOC (&obstack, dwarf2_per_cu_data);
+ result->per_bfd = this;
result->index = m_num_psymtabs++;
return result;
}
@@ -2457,6 +2458,7 @@ signatured_type *
dwarf2_per_bfd::allocate_signatured_type ()
{
signatured_type *result = OBSTACK_ZALLOC (&obstack, signatured_type);
+ result->per_cu.per_bfd = this;
result->per_cu.index = m_num_psymtabs++;
return result;
}
@@ -6451,10 +6453,12 @@ fill_in_sig_entry_from_dwo_entry (struct dwarf2_per_objfile *dwarf2_per_objfile,
struct signatured_type *sig_entry,
struct dwo_unit *dwo_entry)
{
+ dwarf2_per_bfd *per_bfd = dwarf2_per_objfile->per_bfd;
+
/* Make sure we're not clobbering something we don't expect to. */
gdb_assert (! sig_entry->per_cu.queued);
gdb_assert (sig_entry->per_cu.cu == NULL);
- if (dwarf2_per_objfile->per_bfd->using_index)
+ if (per_bfd->using_index)
{
gdb_assert (sig_entry->per_cu.v.quick != NULL);
gdb_assert (!dwarf2_per_objfile->symtab_set_p (&sig_entry->per_cu));
@@ -6471,6 +6475,7 @@ fill_in_sig_entry_from_dwo_entry (struct dwarf2_per_objfile *dwarf2_per_objfile,
sig_entry->per_cu.length = dwo_entry->length;
sig_entry->per_cu.reading_dwo_directly = 1;
sig_entry->per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
+ sig_entry->per_cu.per_bfd = per_bfd;
sig_entry->type_offset_in_tu = dwo_entry->type_offset_in_tu;
sig_entry->dwo_unit = dwo_entry;
}
@@ -7283,6 +7288,7 @@ static struct type_unit_group *
create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
{
struct dwarf2_per_objfile *dwarf2_per_objfile = cu->per_objfile;
+ dwarf2_per_bfd *per_bfd = dwarf2_per_objfile->per_bfd;
struct dwarf2_per_cu_data *per_cu;
struct type_unit_group *tu_group;
@@ -7290,10 +7296,11 @@ create_type_unit_group (struct dwarf2_cu *cu, sect_offset line_offset_struct)
struct type_unit_group);
per_cu = &tu_group->per_cu;
per_cu->dwarf2_per_objfile = dwarf2_per_objfile;
+ per_cu->per_bfd = per_bfd;
- if (dwarf2_per_objfile->per_bfd->using_index)
+ if (per_bfd->using_index)
{
- per_cu->v.quick = OBSTACK_ZALLOC (&dwarf2_per_objfile->per_bfd->obstack,
+ per_cu->v.quick = OBSTACK_ZALLOC (&per_bfd->obstack,
struct dwarf2_per_cu_quick_data);
}
else
@@ -8906,7 +8913,7 @@ queue_comp_unit (struct dwarf2_per_cu_data *per_cu,
enum language pretend_language)
{
per_cu->queued = 1;
- per_cu->dwarf2_per_objfile->per_bfd->queue.emplace (per_cu, pretend_language);
+ per_cu->per_bfd->queue.emplace (per_cu, pretend_language);
}
/* If PER_CU is not yet queued, add it to the queue.
@@ -8926,7 +8933,7 @@ maybe_queue_comp_unit (struct dwarf2_cu *dependent_cu,
/* We may arrive here during partial symbol reading, if we need full
DIEs to process an unusual case (e.g. template arguments). Do
not queue PER_CU, just tell our caller to load its DIEs. */
- if (per_cu->dwarf2_per_objfile->per_bfd->reading_partial_symbols)
+ if (per_cu->per_bfd->reading_partial_symbols)
{
if (per_cu->cu == NULL || per_cu->cu->dies == NULL)
return 1;
@@ -11274,6 +11281,7 @@ create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
dwarf2_section_info &section, htab_up &cus_htab)
{
struct objfile *objfile = dwarf2_per_objfile->objfile;
+ dwarf2_per_bfd *per_bfd = dwarf2_per_objfile->per_bfd;
const gdb_byte *info_ptr, *end_ptr;
section.read (objfile);
@@ -11300,6 +11308,7 @@ create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
memset (&per_cu, 0, sizeof (per_cu));
per_cu.dwarf2_per_objfile = dwarf2_per_objfile;
+ per_cu.per_bfd = per_bfd;
per_cu.is_debug_types = 0;
per_cu.sect_off = sect_offset (info_ptr - section.buffer);
per_cu.section = &section;
@@ -11317,7 +11326,7 @@ create_cus_hash_table (struct dwarf2_per_objfile *dwarf2_per_objfile,
if (cus_htab == NULL)
cus_htab = allocate_dwo_unit_table ();
- dwo_unit = OBSTACK_ZALLOC (&dwarf2_per_objfile->per_bfd->obstack,
+ dwo_unit = OBSTACK_ZALLOC (&per_bfd->obstack,
struct dwo_unit);
*dwo_unit = read_unit;
slot = htab_find_slot (cus_htab.get (), dwo_unit, INSERT);
diff --git a/gdb/dwarf2/read.h b/gdb/dwarf2/read.h
index 2897ea6..02478d1 100644
--- a/gdb/dwarf2/read.h
+++ b/gdb/dwarf2/read.h
@@ -412,6 +412,9 @@ struct dwarf2_per_cu_data
/* The corresponding dwarf2_per_objfile. */
struct dwarf2_per_objfile *dwarf2_per_objfile;
+ /* Backlink to the owner of this. */
+ dwarf2_per_bfd *per_bfd;
+
/* When dwarf2_per_bfd::using_index is true, the 'quick' field
is active. Otherwise, the 'psymtab' field is active. */
union