diff options
author | Simon Marchi <simon.marchi@polymtl.ca> | 2018-04-07 13:53:43 -0400 |
---|---|---|
committer | Simon Marchi <simon.marchi@polymtl.ca> | 2018-04-07 13:53:43 -0400 |
commit | b76e467de35d6b107edff1d4b9de15fb7ebacbbd (patch) | |
tree | 494b19a1e3a644d8eeea7fceac9e94e3883e54ee /gdb/dwarf-index-write.c | |
parent | 12359b5e8f2a4034e1e4cd7f0b454fb03151df4c (diff) | |
download | fsf-binutils-gdb-b76e467de35d6b107edff1d4b9de15fb7ebacbbd.zip fsf-binutils-gdb-b76e467de35d6b107edff1d4b9de15fb7ebacbbd.tar.gz fsf-binutils-gdb-b76e467de35d6b107edff1d4b9de15fb7ebacbbd.tar.bz2 |
Make dwarf2_per_objfile::all_comp_units an std::vector
Make all_comp_units an std::vector, remove n_comp_units and some manual
memory management.
gdb/ChangeLog:
* dwarf2read.h (struct dwarf2_per_objfile) <all_comp_units>: Likewise.
Make an std::vector.
<n_comp_units>: Remove.
* dwarf2read.c (dwarf2_per_objfile::~dwarf2_per_objfile): Adjust
to std::vector change.
(dwarf2_per_objfile::get_cutu): Likewise.
(dwarf2_per_objfile::get_cu): Likewise.
(create_cus_from_index): Likewise.
(create_addrmap_from_index): Likewise.
(create_addrmap_from_aranges): Likewise.
(dwarf2_read_index): Likewise.
(dw2_find_last_source_symtab): Likewise.
(dw2_map_symtabs_matching_filename): Likewise.
(dw2_symtab_iter_next): Likewise.
(dw2_print_stats): Likewise.
(dw2_expand_all_symtabs): Likewise.
(dw2_expand_symtabs_with_fullname): Likewise.
(dw2_expand_marked_cus): Likewise.
(dw2_map_symbol_filenames): Likewise.
(create_cus_from_debug_names): Likewise.
(dwarf2_read_debug_names): Likewise.
(dw2_debug_names_iterator::next): Likewise.
(dwarf2_initialize_objfile): Likewise.
(set_partial_user): Likewise.
(dwarf2_build_psymtabs_hard): Likewise.
(read_comp_units_from_section): Remove arguments, adjust to
std::vector change.
(create_all_comp_units): Adjust to std::vector and
read_comp_units_from_section changes.
(dwarf2_find_containing_comp_unit): Adjust to std::vector
change.
* dwarf-index-write.c (check_dwarf64_offsets): Likewise.
(psyms_seen_size): Likewise.
(write_gdbindex): Likewise.
(write_debug_names): Likewise.
Diffstat (limited to 'gdb/dwarf-index-write.c')
-rw-r--r-- | gdb/dwarf-index-write.c | 21 |
1 files changed, 9 insertions, 12 deletions
diff --git a/gdb/dwarf-index-write.c b/gdb/dwarf-index-write.c index 058712d..c49f084 100644 --- a/gdb/dwarf-index-write.c +++ b/gdb/dwarf-index-write.c @@ -1251,11 +1251,9 @@ private: static bool check_dwarf64_offsets (struct dwarf2_per_objfile *dwarf2_per_objfile) { - for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) + for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units) { - const dwarf2_per_cu_data &per_cu = *dwarf2_per_objfile->all_comp_units[i]; - - if (to_underlying (per_cu.sect_off) >= (static_cast<uint64_t> (1) << 32)) + if (to_underlying (per_cu->sect_off) >= (static_cast<uint64_t> (1) << 32)) return true; } for (int i = 0; i < dwarf2_per_objfile->n_type_units; ++i) @@ -1279,10 +1277,8 @@ static size_t psyms_seen_size (struct dwarf2_per_objfile *dwarf2_per_objfile) { size_t psyms_count = 0; - for (int i = 0; i < dwarf2_per_objfile->n_comp_units; ++i) + for (dwarf2_per_cu_data *per_cu : dwarf2_per_objfile->all_comp_units) { - struct dwarf2_per_cu_data *per_cu - = dwarf2_per_objfile->all_comp_units[i]; struct partial_symtab *psymtab = per_cu->v.psymtab; if (psymtab != NULL && psymtab->user == NULL) @@ -1308,7 +1304,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->n_comp_units); + cu_index_htab.reserve (dwarf2_per_objfile->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 @@ -1316,7 +1312,7 @@ 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->n_comp_units; ++i) + for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i) { struct dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->all_comp_units[i]; @@ -1353,7 +1349,7 @@ write_gdbindex (struct dwarf2_per_objfile *dwarf2_per_objfile, FILE *out_file) sig_data.objfile = objfile; sig_data.symtab = &symtab; - sig_data.cu_index = dwarf2_per_objfile->n_comp_units; + sig_data.cu_index = dwarf2_per_objfile->all_comp_units.size (); htab_traverse_noresize (dwarf2_per_objfile->signatured_types, write_one_signatured_type, &sig_data); } @@ -1428,7 +1424,7 @@ 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->n_comp_units; ++i) + for (int i = 0; i < dwarf2_per_objfile->all_comp_units.size (); ++i) { const dwarf2_per_cu_data *per_cu = dwarf2_per_objfile->all_comp_units[i]; partial_symtab *psymtab = per_cu->v.psymtab; @@ -1496,7 +1492,8 @@ write_debug_names (struct dwarf2_per_objfile *dwarf2_per_objfile, header.append_uint (2, dwarf5_byte_order, 0); /* comp_unit_count - The number of CUs in the CU list. */ - header.append_uint (4, dwarf5_byte_order, dwarf2_per_objfile->n_comp_units); + header.append_uint (4, dwarf5_byte_order, + dwarf2_per_objfile->all_comp_units.size ()); /* local_type_unit_count - The number of TUs in the local TU list. */ |