diff options
-rw-r--r-- | gdb/addrmap.c | 18 | ||||
-rw-r--r-- | gdb/addrmap.h | 9 | ||||
-rw-r--r-- | gdb/dwarf2/parent-map.h | 6 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 49 |
4 files changed, 75 insertions, 7 deletions
diff --git a/gdb/addrmap.c b/gdb/addrmap.c index b9a0f77..696a7dc 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -354,7 +354,9 @@ addrmap_mutable::~addrmap_mutable () /* See addrmap.h. */ void -addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload) +addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload, + gdb::function_view<void (struct ui_file *outfile, + const void *value)> annotate_value) { /* True if the previously printed addrmap entry was for PAYLOAD. If so, we want to print the next one as well (since the next @@ -373,10 +375,16 @@ addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload) addr_str = "<ends here>"; if (matches || previous_matched) - gdb_printf (outfile, " %s%s %s\n", - payload != nullptr ? " " : "", - core_addr_to_string (start_addr), - addr_str); + { + gdb_printf (outfile, " %s%s %s", + payload != nullptr ? " " : "", + core_addr_to_string (start_addr), + addr_str); + if (annotate_value != nullptr) + annotate_value (outfile, obj); + + gdb_printf (outfile, "\n"); + } previous_matched = matches; diff --git a/gdb/addrmap.h b/gdb/addrmap.h index abd1ee3..85d4645 100644 --- a/gdb/addrmap.h +++ b/gdb/addrmap.h @@ -219,8 +219,13 @@ private: /* Dump the addrmap to OUTFILE. If PAYLOAD is non-NULL, only dump any components that map to PAYLOAD. (If PAYLOAD is NULL, the entire - map is dumped.) */ + map is dumped.) If ANNOTATE_VALUE is non-nullptr, call it for each + value. */ + void addrmap_dump (struct addrmap *map, struct ui_file *outfile, - void *payload); + void *payload, + gdb::function_view<void (struct ui_file *outfile, + const void *value)> + annotate_value = nullptr); #endif /* ADDRMAP_H */ diff --git a/gdb/dwarf2/parent-map.h b/gdb/dwarf2/parent-map.h index 5307d4d..6cff548 100644 --- a/gdb/dwarf2/parent-map.h +++ b/gdb/dwarf2/parent-map.h @@ -104,6 +104,9 @@ public: return new (obstack) addrmap_fixed (obstack, &m_map); } + /* Dump a human-readable form of this map. */ + void dump () const; + private: /* An addrmap that maps from section offsets to cooked_index_entry *. */ @@ -141,6 +144,9 @@ public: return nullptr; } + /* Dump a human-readable form of this collection of parent_maps. */ + void dump () const; + private: /* Storage for the convert maps. */ diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 193a52e..749e39d 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4449,6 +4449,50 @@ cooked_index_storage::eq_cutu_reader (const void *a, const void *b) return ra->cu->per_cu->index == *rb; } +/* Dump MAP as parent_map. */ + +static void +dump_parent_map (const struct addrmap *map) +{ + auto_obstack temp_storage; + + auto annotate_cooked_index_entry + = [&] (struct ui_file *outfile, const void *value) + { + const cooked_index_entry *parent_entry + = (const cooked_index_entry *)value; + if (parent_entry == nullptr) + return; + + gdb_printf (outfile, " (0x%" PRIx64 ": %s)", + to_underlying (parent_entry->die_offset), + parent_entry->full_name (&temp_storage, false)); + }; + + addrmap_dump (const_cast<addrmap *> (map), gdb_stdlog, nullptr, + annotate_cooked_index_entry); +} + +/* See parent-map.h. */ + +void +parent_map::dump () const +{ + dump_parent_map (&m_map); +} + +/* See parent-map.h. */ + +void +parent_map_map::dump () const +{ + for (const auto &iter : m_maps) + { + gdb_printf (gdb_stdlog, "map start:\n"); + dump_parent_map (iter); + } +} + /* An instance of this is created to index a CU. */ class cooked_indexer @@ -4841,6 +4885,11 @@ private: { if (dwarf_read_debug > 0) print_tu_stats (m_per_objfile); + if (dwarf_read_debug > 1) + { + dwarf_read_debug_printf_v ("Final m_all_parents_map:"); + m_all_parents_map.dump (); + } } /* After the last DWARF-reading task has finished, this function |