]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
[gdb/symtab] Don't expand non-Ada CUs for info exceptions
authorTom de Vries <tdevries@suse.de>
Tue, 24 Sep 2024 08:24:22 +0000 (10:24 +0200)
committerTom de Vries <tdevries@suse.de>
Tue, 24 Sep 2024 08:24:22 +0000 (10:24 +0200)
commit00105aa1c4d9933fe3cfe9bc1be0daefe9f8ca36
treedd077abbf5a07581e38eb098133690987dc4ae4b
parent7d5702b8fdee17a5b4597b2b03c93e97d5b4c136
[gdb/symtab] Don't expand non-Ada CUs for info exceptions

I noticed when running test-case gdb.ada/info_exc.exp with glibc debug info
installed, that the "info exceptions" command that lists all Ada exceptions
also expands non-Ada CUs, which includes CUs in
/lib64/ld-linux-x86-64.so.2 and /lib64/libc.so.6.

Fix this by:
- adding a new lang_matcher parameter to the expand_symtabs_matching
  function, and
- using that new parameter in the expand_symtabs_matching call in
  ada_add_global_exceptions.

The new parameter is a hint, meaning implementations are free to ignore it and
expand CUs with any language.  This is the case for partial symtabs, I'm not
sure whether it makes sense to implement support for this there.

Conversely, when processing a CU with language C and name "<artificial>"
(as produced by GCC LTO), the CU may not really have a single language and we
should ignore the lang_matcher.  See also commit d2f67711730
("Fix 'catch exception' with -flto").

Now that we have lang_matcher available, also use it to limit name splitting
styles and symbol matchers to those applicable to the matched languages.

Without this patch we have (with a gdb build with -O0):
...
$ time gdb -q -batch -x outputs/gdb.ada/info_exc/gdb.in.1 > /dev/null
real 0m1.866s
user 0m2.089s
sys 0m0.120s
...
and with this patch we have:
...
$ time gdb -q -batch -x outputs/gdb.ada/info_exc/gdb.in.1 > /dev/null
real 0m0.469s
user 0m0.777s
sys 0m0.051s
...

Or, to put it in terms of number of CUs, we have 1853 CUs:
...
$ gdb -q -batch -readnow outputs/gdb.ada/info_exc/foo \
    -ex start \
    -ex "maint info symtabs" \
    | grep -c " name "
1853
...

Without this patch, we have:
...
$ gdb -q -batch outputs/gdb.ada/info_exc/foo \
    -ex start \
    -ex "info exceptions" \
    -ex "maint info symtabs" \
    | grep -c " name "
1393
...
so ~75% of the CUs is expanded, and with this patch we have:
...
$ gdb <same-as-above>
20
...
so ~1% of the CUs is expanded.

Tested on x86_64-linux.

Approved-By: Tom Tromey <tom@tromey.com>
PR symtab/32182
Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=32182
12 files changed:
gdb/ada-lang.c
gdb/dwarf2/cooked-index.h
gdb/dwarf2/read-gdb-index.c
gdb/dwarf2/read.c
gdb/dwarf2/read.h
gdb/objfiles.h
gdb/psymtab.c
gdb/psymtab.h
gdb/quick-symbol.h
gdb/symfile-debug.c
gdb/symfile.c
gdb/symfile.h