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 ).