Split dwarf2_per_objfile into dwarf2_per_objfile and dwarf2_per_bfd
This is the first step of splitting dwarf2_per_objfile in two, one structure for objfile-independent data (dwarf2_per_bfd) and one for objfile-dependent data (dwarf2_per_objfile). The existing dwarf2_per_objfile is renamed dwarf2_per_bfd, and a new dwarf2_per_objfile type is introduced, which sits "in between" the objfile and dwarf2_per_bfd. So where we had this before: objfile -> dwarf2_per_objfile (*) we now have this: objfile -> dwarf2_per_objfile -> dwarf2_per_bfd (*) (*) Note that the dwarf2_per_objfile in the former corresponds to the dwarf2_per_bfd in the latter. I've done the minimal amount of changes in this patch: following patches will incrementally move things that are not actually shareable between objfiles from dwarf2_per_bfd to dwarf2_per_objfile. Most references to dwarf2_per_objfile objects are changed to dwarf2_per_objfile->per_bfd. To avoid many of these replacements, which would have to be reverted later anyway, I've moved right away the objfile backlink to the new dwarf2_per_objfile structure in this patch. I've also moved the read_line_string method, since it references the objfile backlink, and it's actually not difficult to move. Once the moves are completed, multiple dwarf2_per_objfile sharing the same BFD will point to the same single instance of dwarf2_per_bfd (as long as they don't require relocation). dwarf2_has_info, where we create these objects, is updated to the new architecture. I've had to change the get_gdb_index_contents_ftype typedef and related functions. The parameter type was changed from dwarf2_per_objfile to dwarf2_per_bfd, otherwise the template wouldn't work. Please excuse the terse ChangeLog entry, I have not listed all the functions where dwarf2_per_objfile has been changed to dwarf2_per_objfile->per_bfd. It would take a considerable amount of time and would not really be useful in the end. gdb/ChangeLog: * dwarf2/read.h (dwarf2_per_objfile): Rename to dwarf2_per_bfd, then introduce a new dwarf2_per_objfile type. <read_line_string>: Move to the new dwarf2_per_objfile type. <objfile>: Likewise. (dwarf2_per_bfd): Rename dwarf2_per_objfile to this. * dwarf2/read.c: Replace references to dwarf2_per_objfile with dwarf2_per_objfile->per_bfd. (dwarf2_per_objfile::dwarf2_per_objfile): Rename to... (dwarf2_per_bfd::dwarf2_per_bfd): ... this. (dwarf2_per_objfile::free_cached_comp_units): Rename to... (dwarf2_per_bfd::free_cached_comp_units): ... this. (dwarf2_has_info): Allocate dwarf2_per_bfd. (dwarf2_per_objfile::locate_sections): Rename to... (dwarf2_per_bfd::locate_sections): ... this. (dwarf2_per_objfile::get_cutu): Rename to... (dwarf2_per_bfd::get_cutu): ... this. (dwarf2_per_objfile::get_cu): Rename to... (dwarf2_per_bfd::get_cu): ... this. (dwarf2_per_objfile::get_tu): Rename to... (dwarf2_per_bfd::get_tu): ... this. (dwarf2_per_objfile::allocate_per_cu): Rename to... (dwarf2_per_bfd::allocate_per_cu): ... this. (dwarf2_per_objfile::allocate_signatured_type): Rename to... (dwarf2_per_bfd::allocate_signatured_type): ... this. (get_gdb_index_contents_ftype): Change parameter from dwarf2_per_objfile to dwarf2_per_bfd. * dwarf2/macro.c, dwarf2/index-write.c: Replace references to dwarf2_per_objfile with dwarf2_per_objfile->per_bfd. Change-Id: I7de7b5d1ce7494aa73bfcf15f719d3c5c46e138c
This commit is contained in:
parent
a50264baf5
commit
5989a64ed5
5 changed files with 412 additions and 362 deletions
|
@ -1,3 +1,34 @@
|
|||
2020-05-27 Simon Marchi <simon.marchi@polymtl.ca>
|
||||
|
||||
* dwarf2/read.h (dwarf2_per_objfile): Rename to dwarf2_per_bfd,
|
||||
then introduce a new dwarf2_per_objfile type.
|
||||
<read_line_string>: Move to the new dwarf2_per_objfile type.
|
||||
<objfile>: Likewise.
|
||||
(dwarf2_per_bfd): Rename dwarf2_per_objfile to this.
|
||||
* dwarf2/read.c: Replace references to dwarf2_per_objfile with
|
||||
dwarf2_per_objfile->per_bfd.
|
||||
(dwarf2_per_objfile::dwarf2_per_objfile): Rename to...
|
||||
(dwarf2_per_bfd::dwarf2_per_bfd): ... this.
|
||||
(dwarf2_per_objfile::free_cached_comp_units): Rename to...
|
||||
(dwarf2_per_bfd::free_cached_comp_units): ... this.
|
||||
(dwarf2_has_info): Allocate dwarf2_per_bfd.
|
||||
(dwarf2_per_objfile::locate_sections): Rename to...
|
||||
(dwarf2_per_bfd::locate_sections): ... this.
|
||||
(dwarf2_per_objfile::get_cutu): Rename to...
|
||||
(dwarf2_per_bfd::get_cutu): ... this.
|
||||
(dwarf2_per_objfile::get_cu): Rename to...
|
||||
(dwarf2_per_bfd::get_cu): ... this.
|
||||
(dwarf2_per_objfile::get_tu): Rename to...
|
||||
(dwarf2_per_bfd::get_tu): ... this.
|
||||
(dwarf2_per_objfile::allocate_per_cu): Rename to...
|
||||
(dwarf2_per_bfd::allocate_per_cu): ... this.
|
||||
(dwarf2_per_objfile::allocate_signatured_type): Rename to...
|
||||
(dwarf2_per_bfd::allocate_signatured_type): ... this.
|
||||
(get_gdb_index_contents_ftype): Change parameter from
|
||||
dwarf2_per_objfile to dwarf2_per_bfd.
|
||||
* dwarf2/macro.c, dwarf2/index-write.c: Replace references to
|
||||
dwarf2_per_objfile with dwarf2_per_objfile->per_bfd.
|
||||
|
||||
2020-05-27 Tom Tromey <tom@tromey.com>
|
||||
Simon Marchi <simon.marchi@efficios.com>
|
||||
|
||||
|
|
|
@ -961,17 +961,17 @@ private:
|
|||
: m_abfd (dwarf2_per_objfile->objfile->obfd),
|
||||
m_dwarf2_per_objfile (dwarf2_per_objfile)
|
||||
{
|
||||
dwarf2_per_objfile->str.read (dwarf2_per_objfile->objfile);
|
||||
if (dwarf2_per_objfile->str.buffer == NULL)
|
||||
dwarf2_per_objfile->per_bfd->str.read (dwarf2_per_objfile->objfile);
|
||||
if (dwarf2_per_objfile->per_bfd->str.buffer == NULL)
|
||||
return;
|
||||
for (const gdb_byte *data = dwarf2_per_objfile->str.buffer;
|
||||
data < (dwarf2_per_objfile->str.buffer
|
||||
+ dwarf2_per_objfile->str.size);)
|
||||
for (const gdb_byte *data = dwarf2_per_objfile->per_bfd->str.buffer;
|
||||
data < (dwarf2_per_objfile->per_bfd->str.buffer
|
||||
+ dwarf2_per_objfile->per_bfd->str.size);)
|
||||
{
|
||||
const char *const s = reinterpret_cast<const char *> (data);
|
||||
const auto insertpair
|
||||
= m_str_table.emplace (c_str_view (s),
|
||||
data - dwarf2_per_objfile->str.buffer);
|
||||
data - dwarf2_per_objfile->per_bfd->str.buffer);
|
||||
if (!insertpair.second)
|
||||
complaint (_("Duplicate string \"%s\" in "
|
||||
".debug_str section [in module %s]"),
|
||||
|
@ -988,7 +988,7 @@ private:
|
|||
const auto it = m_str_table.find (c_str_view (s));
|
||||
if (it != m_str_table.end ())
|
||||
return it->second;
|
||||
const size_t offset = (m_dwarf2_per_objfile->str.size
|
||||
const size_t offset = (m_dwarf2_per_objfile->per_bfd->str.size
|
||||
+ m_str_add_buf.size ());
|
||||
m_str_table.emplace (c_str_view (s), offset);
|
||||
m_str_add_buf.append_cstr0 (s);
|
||||
|
@ -1296,12 +1296,12 @@ private:
|
|||
static bool
|
||||
check_dwarf64_offsets (struct dwarf2_per_objfile *dwarf2_per_objfile)
|
||||
{
|
||||
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
|
||||
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
|
||||
{
|
||||
if (to_underlying (per_cu->sect_off) >= (static_cast<uint64_t> (1) << 32))
|
||||
return true;
|
||||
}
|
||||
for (const signatured_type *sigtype : dwarf2_per_objfile->all_type_units)
|
||||
for (const signatured_type *sigtype : dwarf2_per_objfile->per_bfd->all_type_units)
|
||||
{
|
||||
const dwarf2_per_cu_data &per_cu = sigtype->per_cu;
|
||||
|
||||
|
@ -1321,7 +1321,7 @@ static size_t
|
|||
psyms_seen_size (struct dwarf2_per_objfile *dwarf2_per_objfile)
|
||||
{
|
||||
size_t psyms_count = 0;
|
||||
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units)
|
||||
for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->per_bfd->all_comp_units)
|
||||
{
|
||||
partial_symtab *psymtab = per_cu->v.psymtab;
|
||||
|
||||
|
@ -1414,7 +1414,7 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
|
|||
in the index file). This will later be needed to write the address
|
||||
table. */
|
||||
psym_index_map cu_index_htab;
|
||||
cu_index_htab.reserve (dwarf2_per_objfile->all_comp_units.size ());
|
||||
cu_index_htab.reserve (dwarf2_per_objfile->per_bfd->all_comp_units.size ());
|
||||
|
||||
/* The CU list is already sorted, so we don't need to do additional
|
||||
work here. Also, the debug_types entries do not appear in
|
||||
|
@ -1422,10 +1422,10 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
|
|||
|
||||
std::unordered_set<partial_symbol *> psyms_seen
|
||||
(psyms_seen_size (dwarf2_per_objfile));
|
||||
for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i)
|
||||
for (int i = 0; i < dwarf2_per_objfile->per_bfd->all_comp_units.size (); ++i)
|
||||
{
|
||||
struct dwarf2_per_cu_data *per_cu
|
||||
= dwarf2_per_objfile->all_comp_units[i];
|
||||
= dwarf2_per_objfile->per_bfd->all_comp_units[i];
|
||||
partial_symtab *psymtab = per_cu->v.psymtab;
|
||||
|
||||
if (psymtab != NULL)
|
||||
|
@ -1453,15 +1453,15 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file,
|
|||
|
||||
/* Write out the .debug_type entries, if any. */
|
||||
data_buf types_cu_list;
|
||||
if (dwarf2_per_objfile->signatured_types)
|
||||
if (dwarf2_per_objfile->per_bfd->signatured_types)
|
||||
{
|
||||
signatured_type_index_data sig_data (types_cu_list,
|
||||
psyms_seen);
|
||||
|
||||
sig_data.objfile = objfile;
|
||||
sig_data.symtab = &symtab;
|
||||
sig_data.cu_index = dwarf2_per_objfile->all_comp_units.size ();
|
||||
htab_traverse_noresize (dwarf2_per_objfile->signatured_types.get (),
|
||||
sig_data.cu_index = dwarf2_per_objfile->per_bfd->all_comp_units.size ();
|
||||
htab_traverse_noresize (dwarf2_per_objfile->per_bfd->signatured_types.get (),
|
||||
write_one_signatured_type, &sig_data);
|
||||
}
|
||||
|
||||
|
@ -1505,9 +1505,9 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
|
|||
dwarf5_byte_order);
|
||||
std::unordered_set<partial_symbol *>
|
||||
psyms_seen (psyms_seen_size (dwarf2_per_objfile));
|
||||
for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i)
|
||||
for (int i = 0; i < dwarf2_per_objfile->per_bfd->all_comp_units.size (); ++i)
|
||||
{
|
||||
const dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->all_comp_units[i];
|
||||
const dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->per_bfd->all_comp_units[i];
|
||||
partial_symtab *psymtab = per_cu->v.psymtab;
|
||||
|
||||
/* CU of a shared file from 'dwz -m' may be unused by this main
|
||||
|
@ -1525,7 +1525,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
|
|||
|
||||
/* Write out the .debug_type entries, if any. */
|
||||
data_buf types_cu_list;
|
||||
if (dwarf2_per_objfile->signatured_types)
|
||||
if (dwarf2_per_objfile->per_bfd->signatured_types)
|
||||
{
|
||||
debug_names::write_one_signatured_type_data sig_data (nametable,
|
||||
signatured_type_index_data (types_cu_list, psyms_seen));
|
||||
|
@ -1534,7 +1534,7 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
|
|||
/* It is used only for gdb_index. */
|
||||
sig_data.info.symtab = nullptr;
|
||||
sig_data.info.cu_index = 0;
|
||||
htab_traverse_noresize (dwarf2_per_objfile->signatured_types.get (),
|
||||
htab_traverse_noresize (dwarf2_per_objfile->per_bfd->signatured_types.get (),
|
||||
debug_names::write_one_signatured_type,
|
||||
&sig_data);
|
||||
}
|
||||
|
@ -1574,12 +1574,12 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile,
|
|||
|
||||
/* comp_unit_count - The number of CUs in the CU list. */
|
||||
header.append_uint (4, dwarf5_byte_order,
|
||||
dwarf2_per_objfile->all_comp_units.size ());
|
||||
dwarf2_per_objfile->per_bfd->all_comp_units.size ());
|
||||
|
||||
/* local_type_unit_count - The number of TUs in the local TU
|
||||
list. */
|
||||
header.append_uint (4, dwarf5_byte_order,
|
||||
dwarf2_per_objfile->all_type_units.size ());
|
||||
dwarf2_per_objfile->per_bfd->all_type_units.size ());
|
||||
|
||||
/* foreign_type_unit_count - The number of TUs in the foreign TU
|
||||
list. */
|
||||
|
@ -1676,10 +1676,10 @@ write_psymtabs_to_index (struct dwarf2_per_objfile *dwarf2_per_objfile,
|
|||
{
|
||||
struct objfile *objfile = dwarf2_per_objfile->objfile;
|
||||
|
||||
if (dwarf2_per_objfile->using_index)
|
||||
if (dwarf2_per_objfile->per_bfd->using_index)
|
||||
error (_("Cannot use an index to create the index"));
|
||||
|
||||
if (dwarf2_per_objfile->types.size () > 1)
|
||||
if (dwarf2_per_objfile->per_bfd->types.size () > 1)
|
||||
error (_("Cannot make an index when the file has multiple .debug_types sections"));
|
||||
|
||||
if (!objfile->partial_symtabs->psymtabs
|
||||
|
|
|
@ -512,9 +512,9 @@ dwarf_decode_macro_bytes (struct dwarf2_per_objfile *dwarf2_per_objfile,
|
|||
body = dwz->read_string (objfile, str_offset);
|
||||
}
|
||||
else
|
||||
body = dwarf2_per_objfile->str.read_string (objfile,
|
||||
str_offset,
|
||||
"DW_FORM_strp");
|
||||
body = dwarf2_per_objfile->per_bfd->str.read_string (objfile,
|
||||
str_offset,
|
||||
"DW_FORM_strp");
|
||||
}
|
||||
|
||||
is_define = (macinfo_type == DW_MACRO_define
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -66,32 +66,34 @@ struct dwarf2_queue_item
|
|||
enum language pretend_language;
|
||||
};
|
||||
|
||||
/* Collection of data recorded per objfile.
|
||||
This hangs off of dwarf2_objfile_data_key. */
|
||||
/* Some DWARF data can be shared across objfiles who share the same BFD,
|
||||
this data is stored in this object.
|
||||
|
||||
struct dwarf2_per_objfile
|
||||
Two dwarf2_per_objfile objects representing objfiles sharing the same BFD
|
||||
will point to the same instance of dwarf2_per_bfd, unless the BFD requires
|
||||
relocation. */
|
||||
|
||||
struct dwarf2_per_bfd
|
||||
{
|
||||
/* Construct a dwarf2_per_objfile for OBJFILE. NAMES points to the
|
||||
/* Construct a dwarf2_per_bfd for OBFD. NAMES points to the
|
||||
dwarf2 section names, or is NULL if the standard ELF names are
|
||||
used. CAN_COPY is true for formats where symbol
|
||||
interposition is possible and so symbol values must follow copy
|
||||
relocation rules. */
|
||||
dwarf2_per_objfile (struct objfile *objfile,
|
||||
const dwarf2_debug_sections *names,
|
||||
bool can_copy);
|
||||
dwarf2_per_bfd (bfd *obfd, const dwarf2_debug_sections *names, bool can_copy);
|
||||
|
||||
~dwarf2_per_objfile ();
|
||||
~dwarf2_per_bfd ();
|
||||
|
||||
DISABLE_COPY_AND_ASSIGN (dwarf2_per_objfile);
|
||||
DISABLE_COPY_AND_ASSIGN (dwarf2_per_bfd);
|
||||
|
||||
/* Return the CU/TU given its index.
|
||||
|
||||
This is intended for loops like:
|
||||
|
||||
for (i = 0; i < (dwarf2_per_objfile->n_comp_units
|
||||
+ dwarf2_per_objfile->n_type_units); ++i)
|
||||
for (i = 0; i < (dwarf2_per_bfd->n_comp_units
|
||||
+ dwarf2_per_bfd->n_type_units); ++i)
|
||||
{
|
||||
dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->get_cutu (i);
|
||||
dwarf2_per_cu_data *per_cu = dwarf2_per_bfd->get_cutu (i);
|
||||
|
||||
...;
|
||||
}
|
||||
|
@ -113,21 +115,14 @@ struct dwarf2_per_objfile
|
|||
|
||||
/* A convenience function to allocate a dwarf2_per_cu_data. The
|
||||
returned object has its "index" field set properly. The object
|
||||
is allocated on the dwarf2_per_objfile obstack. */
|
||||
is allocated on the dwarf2_per_bfd obstack. */
|
||||
dwarf2_per_cu_data *allocate_per_cu ();
|
||||
|
||||
/* A convenience function to allocate a signatured_type. The
|
||||
returned object has its "index" field set properly. The object
|
||||
is allocated on the dwarf2_per_objfile obstack. */
|
||||
is allocated on the dwarf2_per_bfd obstack. */
|
||||
signatured_type *allocate_signatured_type ();
|
||||
|
||||
/* Return pointer to string at .debug_line_str offset as read from BUF.
|
||||
BUF is assumed to be in a compilation unit described by CU_HEADER.
|
||||
Return *BYTES_READ_PTR count of bytes read from BUF. */
|
||||
const char *read_line_string (const gdb_byte *buf,
|
||||
const struct comp_unit_head *cu_header,
|
||||
unsigned int *bytes_read_ptr);
|
||||
|
||||
private:
|
||||
/* This function is mapped across the sections and remembers the
|
||||
offset and size of each of the debugging sections we are
|
||||
|
@ -162,9 +157,6 @@ public:
|
|||
|
||||
std::vector<dwarf2_section_info> types;
|
||||
|
||||
/* Back link. */
|
||||
struct objfile *objfile = NULL;
|
||||
|
||||
/* Table of all the compilation units. This is used to locate
|
||||
the target compilation unit of a particular reference. */
|
||||
std::vector<dwarf2_per_cu_data *> all_comp_units;
|
||||
|
@ -267,6 +259,33 @@ private:
|
|||
size_t m_num_psymtabs = 0;
|
||||
};
|
||||
|
||||
/* Collection of data recorded per objfile.
|
||||
This hangs off of dwarf2_objfile_data_key.
|
||||
|
||||
Some DWARF data cannot (currently) be shared across objfiles. Such
|
||||
data is stored in this object. */
|
||||
|
||||
struct dwarf2_per_objfile
|
||||
{
|
||||
dwarf2_per_objfile (struct objfile *objfile, dwarf2_per_bfd *per_bfd)
|
||||
: objfile (objfile), per_bfd (per_bfd)
|
||||
{}
|
||||
|
||||
/* Return pointer to string at .debug_line_str offset as read from BUF.
|
||||
BUF is assumed to be in a compilation unit described by CU_HEADER.
|
||||
Return *BYTES_READ_PTR count of bytes read from BUF. */
|
||||
const char *read_line_string (const gdb_byte *buf,
|
||||
const struct comp_unit_head *cu_header,
|
||||
unsigned int *bytes_read_ptr);
|
||||
|
||||
/* Back link. */
|
||||
struct objfile *objfile;
|
||||
|
||||
/* Pointer to the data that is (possibly) shared between this objfile and
|
||||
other objfiles backed by the same BFD. */
|
||||
struct dwarf2_per_bfd *per_bfd;
|
||||
};
|
||||
|
||||
/* Get the dwarf2_per_objfile associated to OBJFILE. */
|
||||
|
||||
dwarf2_per_objfile *get_dwarf2_per_objfile (struct objfile *objfile);
|
||||
|
@ -360,7 +379,7 @@ struct dwarf2_per_cu_data
|
|||
/* The corresponding dwarf2_per_objfile. */
|
||||
struct dwarf2_per_objfile *dwarf2_per_objfile;
|
||||
|
||||
/* When dwarf2_per_objfile->using_index is true, the 'quick' field
|
||||
/* When dwarf2_per_bfd::using_index is true, the 'quick' field
|
||||
is active. Otherwise, the 'psymtab' field is active. */
|
||||
union
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue