aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/index-write.c
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2020-05-27 11:13:50 -0400
committerSimon Marchi <simon.marchi@efficios.com>2020-05-27 11:13:50 -0400
commit5989a64ed5ee7a7f9c0fc284f66ef4bd414ad6c2 (patch)
tree05eb62aa376ad62ee07e410364b8bfdc4caf96de /gdb/dwarf2/index-write.c
parenta50264baf57716993e701096fa6e466fb63e0301 (diff)
downloadgdb-5989a64ed5ee7a7f9c0fc284f66ef4bd414ad6c2.zip
gdb-5989a64ed5ee7a7f9c0fc284f66ef4bd414ad6c2.tar.gz
gdb-5989a64ed5ee7a7f9c0fc284f66ef4bd414ad6c2.tar.bz2
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
Diffstat (limited to 'gdb/dwarf2/index-write.c')
-rw-r--r--gdb/dwarf2/index-write.c48
1 files changed, 24 insertions, 24 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c
index eabfe5d..a9c6651 100644
--- a/gdb/dwarf2/index-write.c
+++ b/gdb/dwarf2/index-write.c
@@ -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