diff options
author | Tom Tromey <tom@tromey.com> | 2021-05-28 15:52:44 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2022-04-12 09:31:16 -0600 |
commit | fa38ad7d8aa15309cfc51d4dec48108816e3fcbd (patch) | |
tree | e6f69d2040a3b8045dcf1297ce3e79b463acd251 | |
parent | fca9326e27b7b41847565d7afcd9070144256306 (diff) | |
download | fsf-binutils-gdb-fa38ad7d8aa15309cfc51d4dec48108816e3fcbd.zip fsf-binutils-gdb-fa38ad7d8aa15309cfc51d4dec48108816e3fcbd.tar.gz fsf-binutils-gdb-fa38ad7d8aa15309cfc51d4dec48108816e3fcbd.tar.bz2 |
Genericize addrmap handling in the DWARF index writer
This updates the DWARF index writing code to make the addrmap-writing
a bit more generic. Now, it can handle multiple maps, and it can work
using the maps generated by the new indexer.
Note that the new addrmap_index_data::using_index field will be
deleted in a future patch, when the rest of the DWARF psymtab code is
removed.
-rw-r--r-- | gdb/dwarf2/index-write.c | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/gdb/dwarf2/index-write.c b/gdb/dwarf2/index-write.c index 509dde4..9fe7724 100644 --- a/gdb/dwarf2/index-write.c +++ b/gdb/dwarf2/index-write.c @@ -412,8 +412,11 @@ typedef std::unordered_map<dwarf2_per_cu_data *, unsigned int> cu_index_map; /* Helper struct for building the address table. */ struct addrmap_index_data { - addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_) - : addr_vec (addr_vec_), cu_index_htab (cu_index_htab_) + addrmap_index_data (data_buf &addr_vec_, cu_index_map &cu_index_htab_, + bool using_index_) + : addr_vec (addr_vec_), + cu_index_htab (cu_index_htab_), + using_index (using_index_) {} data_buf &addr_vec; @@ -421,6 +424,8 @@ struct addrmap_index_data int operator() (CORE_ADDR start_addr, void *obj); + /* True if the DWARF reader uses the new DWARF indexer. */ + bool using_index; /* True if the previous_* fields are valid. We can't write an entry until we see the next entry (since it is only then that we know the end of the entry). */ @@ -447,7 +452,11 @@ add_address_entry (data_buf &addr_vec, int addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) { - dwarf2_psymtab *pst = (dwarf2_psymtab *) obj; + dwarf2_per_cu_data *per_cu; + if (using_index) + per_cu = (dwarf2_per_cu_data *) obj; + else + per_cu = obj == nullptr ? nullptr : ((dwarf2_psymtab *) obj)->per_cu_data; if (previous_valid) add_address_entry (addr_vec, @@ -455,9 +464,9 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) previous_cu_index); previous_cu_start = start_addr; - if (pst != NULL) + if (per_cu != NULL) { - const auto it = cu_index_htab.find (pst->per_cu_data); + const auto it = cu_index_htab.find (per_cu); gdb_assert (it != cu_index_htab.cend ()); previous_cu_index = it->second; previous_valid = true; @@ -474,9 +483,10 @@ addrmap_index_data::operator() (CORE_ADDR start_addr, void *obj) static void write_address_map (struct addrmap *addrmap, data_buf &addr_vec, - cu_index_map &cu_index_htab) + cu_index_map &cu_index_htab, bool using_index) { - struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab); + struct addrmap_index_data addrmap_index_data (addr_vec, cu_index_htab, + using_index); addrmap_foreach (addrmap, addrmap_index_data); @@ -1377,8 +1387,17 @@ write_gdbindex (dwarf2_per_objfile *per_objfile, FILE *out_file, /* Dump the address map. */ data_buf addr_vec; - write_address_map (per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap, - addr_vec, cu_index_htab); + if (per_objfile->per_bfd->using_index) + { + std::vector<addrmap *> addrmaps + = per_objfile->per_bfd->cooked_index_table->get_addrmaps (); + for (auto map : addrmaps) + write_address_map (map, addr_vec, cu_index_htab, true); + } + else + write_address_map (per_objfile->per_bfd->partial_symtabs->psymtabs_addrmap, + addr_vec, cu_index_htab, + per_objfile->per_bfd->using_index); /* Now that we've processed all symbols we can shrink their cu_indices lists. */ |