Do more DWARF reading in the background
authorTom Tromey <tom@tromey.com>
Sat, 25 Mar 2023 05:35:02 +0000 (23:35 -0600)
committerTom Tromey <tom@tromey.com>
Tue, 9 Jan 2024 01:40:21 +0000 (18:40 -0700)
commit33c6eaaefcedd45e86d564d014f14cce2620f933
tree65e9699822f70d866cb3e0c6b7d2d05e88712d46
parentf7840e9e3eb9d1a157eaae772ea6841f1b83f1ba
Do more DWARF reading in the background

This patch rearranges the DWARF reader so that more work is done in
the background.  This is PR symtab/29942.

The idea here is that there is only a small amount of work that must
be done on the main thread when scanning DWARF -- before the main
scan, the only part is mapping the section data.

Currently, the DWARF reader uses the quick_symbol_functions "lazy"
functionality to defer even starting to read.  This patch instead
changes the reader to start reading immediately, but doing more in
worker tasks.

Before this patch, "file" on my machine:

    (gdb) file /tmp/gdb
    2023-10-23 12:29:56.885 - command started
    Reading symbols from /tmp/gdb...
    2023-10-23 12:29:58.047 - command finished
    Command execution time: 5.867228 (cpu), 1.162444 (wall)

After the patch, more work is done in the background and so this takes
a bit less time:

    (gdb) file /tmp/gdb
    2023-10-23 13:25:51.391 - command started
    Reading symbols from /tmp/gdb...
    2023-10-23 13:25:51.712 - command finished
    Command execution time: 1.894500 (cpu), 0.320306 (wall)

I think this could be further sped up by using the shared library load
map to avoid objfile loops like the one in expand_symtab_containing_pc
-- it seems like the correct objfile could be chosen more directly.

Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=29942
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30174
13 files changed:
gdb/dwarf2/cooked-index.c
gdb/dwarf2/cooked-index.h
gdb/dwarf2/read.c
gdb/dwarf2/read.h
gdb/testsuite/gdb.dwarf2/debug-aranges-duplicate-offset-warning.exp
gdb/testsuite/gdb.dwarf2/dw2-error.exp
gdb/testsuite/gdb.dwarf2/dw2-missing-cu-tag.exp
gdb/testsuite/gdb.dwarf2/dw2-stack-boundary.exp
gdb/testsuite/gdb.dwarf2/dw2-using-debug-str.exp
gdb/testsuite/gdb.dwarf2/dw2-zero-range.exp
gdb/testsuite/gdb.dwarf2/fission-reread.exp
gdb/testsuite/gdb.dwarf2/no-gnu-debuglink.exp
gdb/testsuite/gdb.dwarf2/struct-with-sig-2.exp