aboutsummaryrefslogtreecommitdiff
path: root/gdb/dwarf2/read.c
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2023-10-14 12:31:31 -0600
committerTom Tromey <tom@tromey.com>2023-10-29 10:34:51 -0600
commitc7224db7af39652f36fd538ac997eb40cc79d770 (patch)
treef04a5221ce6fc168d64d457d65b4ba1dcb480b6c /gdb/dwarf2/read.c
parentca362799ee0ab2bd4d4ea4f521726fefbfbad738 (diff)
downloadgdb-c7224db7af39652f36fd538ac997eb40cc79d770.zip
gdb-c7224db7af39652f36fd538ac997eb40cc79d770.tar.gz
gdb-c7224db7af39652f36fd538ac997eb40cc79d770.tar.bz2
Pre-read .debug_aranges section
While working on background DWARF reading, I found a race case that I tracked down to the handling of the .debug_aranges section. Currently the section data is only read in after the CUs have all been created. However, there's no real reason to do this -- it seems fine to read it a little earlier, when all the other necessary sections are read in. This patch makes this change, and updates the read_addrmap_from_aranges API to assert that the section is read in. This patch slightly changes the read_addrmap_from_aranges API as well, to reject an empty section. This seems better to me than what the current code does, which is try to read an empty section but then do no work. Regression tested on x86-64 Fedora 38. Reviewed-By: Guinevere Larsen <blarsen@redhat.com>
Diffstat (limited to 'gdb/dwarf2/read.c')
-rw-r--r--gdb/dwarf2/read.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/gdb/dwarf2/read.c b/gdb/dwarf2/read.c
index ea0b232..c8e21aa 100644
--- a/gdb/dwarf2/read.c
+++ b/gdb/dwarf2/read.c
@@ -1586,6 +1586,7 @@ dwarf2_per_bfd::map_info_sections (struct objfile *objfile)
ranges.read (objfile);
rnglists.read (objfile);
addr.read (objfile);
+ debug_aranges.read (objfile);
for (auto &section : types)
section.read (objfile);
@@ -1843,6 +1844,11 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
dwarf2_section_info *section,
addrmap *mutable_map)
{
+ /* Caller must ensure that the section has already been read. */
+ gdb_assert (section->readin);
+ if (section->empty ())
+ return false;
+
struct objfile *objfile = per_objfile->objfile;
bfd *abfd = objfile->obfd.get ();
struct gdbarch *gdbarch = objfile->arch ();
@@ -1870,13 +1876,8 @@ read_addrmap_from_aranges (dwarf2_per_objfile *per_objfile,
}
std::set<sect_offset> debug_info_offset_seen;
-
- section->read (objfile);
-
const bfd_endian dwarf5_byte_order = gdbarch_byte_order (gdbarch);
-
const gdb_byte *addr = section->buffer;
-
while (addr < section->buffer + section->size)
{
const gdb_byte *const entry_addr = addr;