]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb] Add regression test for PR symtab/33777
authorTom de Vries <tdevries@suse.de>
Tue, 20 Jan 2026 08:06:20 +0000 (09:06 +0100)
committerTom de Vries <tdevries@suse.de>
Tue, 20 Jan 2026 08:06:20 +0000 (09:06 +0100)
commit2f23cf072533e786aea133fe713df44f9ffca74e
tree1832a37add5bd79d3da16e99ee33e3455144f020
parent5953fa4a7b72c27bad2b8e08060ae66fdd39cefe
[gdb] Add regression test for PR symtab/33777

PR symtab/33777 reports a problem where toplevel DIEs of partial units are
read many times.

The problem manifest as a timeout when building gdb with -O0 and Asan, and
running test-case gdb.base/tls-dlobj.exp with glibc debuginfo installed.

Reproduce the problem in a simpler and quicker way, without relying on glibc
debuginfo:
- build an executable with 100 partial units
- run info line "$file:$line" a 100 times
- add a line to "maint print statistics" that tells us how many time a
  toplevel DIE is read.

Without the fix we have:
...
   Number of read units: 1
   Number of unread units: 108
   Number of read top-level DIEs: 10118
...
and with the fix we have:
...
   Number of read units: 1
   Number of unread units: 108
   Number of read top-level DIEs: 218
...

Detect the problem by asserting:
...
gdb_assert { $top_level_die <= 3 * ( $read_cu + $unread_cu ) }
...

The factor 3 is used because for some target boards $top_level_die is slightly
more than 2 * ( $read_cu + $unread_cu ).

Tested on x86_64-linux.
gdb/dwarf2/read.c
gdb/dwarf2/read.h
gdb/testsuite/gdb.dwarf2/dwz-many-2.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/dwz-many.c [new file with mode: 0644]
gdb/testsuite/gdb.dwarf2/dwz-many.exp [new file with mode: 0644]