diff options
author | Tom de Vries <tdevries@suse.de> | 2024-11-27 18:48:43 +0100 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2024-11-27 18:48:43 +0100 |
commit | 8b8a557119f391ee4c3544408d76950e229797dc (patch) | |
tree | 6f7d7ff212a75aee2cf2c69083acf92143ca8413 | |
parent | 4c5d88facd74c392737882608c001b17b7aeb017 (diff) | |
download | binutils-8b8a557119f391ee4c3544408d76950e229797dc.zip binutils-8b8a557119f391ee4c3544408d76950e229797dc.tar.gz binutils-8b8a557119f391ee4c3544408d76950e229797dc.tar.bz2 |
[gdb/symtab] Fix parent map dump
Before the fix for PR symtab/32225, the parent map dump showed a mapping from
section offsets to cooked index entries:
...
0x0000000000000035 0x3ba9560 (0x34: sp1::A)
...
but now that's no longer the case:
...
0x00000000406f5405 0x410a04d0 (0x34: sp1::A)
...
Fix this by extending the annotation somewhat, such that we get:
...
map start:
0x0000000012c52405 0x135fd550
(section: .debug_info, offset: 0x35) -> (0x34: sp1::A)
...
Tested on x86_64-linux.
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32225
-rw-r--r-- | gdb/addrmap.c | 3 | ||||
-rw-r--r-- | gdb/addrmap.h | 1 | ||||
-rw-r--r-- | gdb/dwarf2/parent-map.h | 4 | ||||
-rw-r--r-- | gdb/dwarf2/read.c | 40 |
4 files changed, 36 insertions, 12 deletions
diff --git a/gdb/addrmap.c b/gdb/addrmap.c index 696a7dc..bd5601b 100644 --- a/gdb/addrmap.c +++ b/gdb/addrmap.c @@ -356,6 +356,7 @@ addrmap_mutable::~addrmap_mutable () void addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload, gdb::function_view<void (struct ui_file *outfile, + CORE_ADDR start_addr, const void *value)> annotate_value) { /* True if the previously printed addrmap entry was for PAYLOAD. @@ -381,7 +382,7 @@ addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload, core_addr_to_string (start_addr), addr_str); if (annotate_value != nullptr) - annotate_value (outfile, obj); + annotate_value (outfile, start_addr, obj); gdb_printf (outfile, "\n"); } diff --git a/gdb/addrmap.h b/gdb/addrmap.h index 85d4645..6e2111e 100644 --- a/gdb/addrmap.h +++ b/gdb/addrmap.h @@ -225,6 +225,7 @@ private: void addrmap_dump (struct addrmap *map, struct ui_file *outfile, void *payload, gdb::function_view<void (struct ui_file *outfile, + CORE_ADDR start_addr, const void *value)> annotate_value = nullptr); diff --git a/gdb/dwarf2/parent-map.h b/gdb/dwarf2/parent-map.h index a9ea34e..91a8b8c 100644 --- a/gdb/dwarf2/parent-map.h +++ b/gdb/dwarf2/parent-map.h @@ -102,7 +102,7 @@ public: } /* Dump a human-readable form of this map. */ - void dump () const; + void dump (dwarf2_per_bfd *per_bfd) const; private: @@ -142,7 +142,7 @@ public: } /* Dump a human-readable form of this collection of parent_maps. */ - void dump () const; + void dump (dwarf2_per_bfd *per_bfd) const; private: diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c index 583bd97..5a284be 100644 --- a/gdb/dwarf2/read.c +++ b/gdb/dwarf2/read.c @@ -4458,19 +4458,41 @@ cooked_index_storage::eq_cutu_reader (const void *a, const void *b) /* Dump MAP as parent_map. */ static void -dump_parent_map (const struct addrmap *map) +dump_parent_map (dwarf2_per_bfd *per_bfd, const struct addrmap *map) { auto_obstack temp_storage; auto annotate_cooked_index_entry - = [&] (struct ui_file *outfile, const void *value) + = [&] (struct ui_file *outfile, CORE_ADDR start_addr, const void *value) { const cooked_index_entry *parent_entry = (const cooked_index_entry *)value; + + gdb_printf (outfile, "\n\t"); + + bool found = false; + for (auto sections : {per_bfd->infos, per_bfd->types}) + for (auto section : sections) + if ((CORE_ADDR)section.buffer <= start_addr + && start_addr < (CORE_ADDR) (section.buffer + section.size)) + { + gdb_printf (outfile, "(section: %s, offset: 0x%" PRIx64 ")", + section.get_name (), + start_addr - (CORE_ADDR)section.buffer); + found = true; + break; + } + + if (!found) + gdb_printf (outfile, "()"); + if (parent_entry == nullptr) - return; + { + gdb_printf (outfile, " -> ()"); + return; + } - gdb_printf (outfile, " (0x%" PRIx64 ": %s)", + gdb_printf (outfile, " -> (0x%" PRIx64 ": %s)", to_underlying (parent_entry->die_offset), parent_entry->full_name (&temp_storage, false)); }; @@ -4482,20 +4504,20 @@ dump_parent_map (const struct addrmap *map) /* See parent-map.h. */ void -parent_map::dump () const +parent_map::dump (dwarf2_per_bfd *per_bfd) const { - dump_parent_map (&m_map); + dump_parent_map (per_bfd, &m_map); } /* See parent-map.h. */ void -parent_map_map::dump () const +parent_map_map::dump (dwarf2_per_bfd *per_bfd) const { for (const auto &iter : m_maps) { gdb_printf (gdb_stdlog, "map start:\n"); - dump_parent_map (iter); + dump_parent_map (per_bfd, iter); } } @@ -4896,7 +4918,7 @@ private: if (dwarf_read_debug > 1) { dwarf_read_debug_printf_v ("Final m_all_parents_map:"); - m_all_parents_map.dump (); + m_all_parents_map.dump (m_per_objfile->per_bfd); } } |