The gdb-generated .gdb_index doesn't have duplicate entries in the symbol table for classes and namespaces (gdb's .gdb_index is based on its partial symbols, and gdb only keeps one copy of global partial syms). The gold-generated .gdb_index does have duplicate entries for classes and namespaces. This causes performance issues in gdb. e.g. "break foo::misspelled" will expand the debug info for every CU recorded for "foo" in .gdb_index. Example: foo.h: namespace N1 { class C1 { public: static void baz () {} }; } foo-1.cc: #include "foo.h" namespace N1 { void foo () { C1::baz (); } } int main () { return 0; } foo-2.cc: #include "namespace-n.h" namespace N1 { void bar () { C1::baz (); } } The gold generated index has: [721] N1::C1::baz: 2 [global function] 3 [global function] [759] N1: 2 [global type] 3 [global type] [961] N1::C1: 2 [global type] 3 [global type] The gdb generated index has: [721] N1::C1::baz: 2 [global function] [759] N1: T0 [global type] [961] N1::C1: T0 [global type]
Checked in this workaround in gdb: https://sourceware.org/ml/src-cvs/2013-q4/msg00119.html
I found this bug while debugging another issue I had with gdb, described here: https://sourceware.org/bugzilla/show_bug.cgi?id=23042 Any idea why my problem is not resolved by the workaround pushed here? Could the workaround be extended to also handle the other case? Also, it would be great if the gold index could be made more compatible, which is the scope of this bug I guess. Best regards, Martin
Retested with binutils-2.29, same issue.
The master branch has been updated by Tom de Vries <vries@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=40d22035a7fc239ac1e944b75a2e3ee9029d1b76 commit 40d22035a7fc239ac1e944b75a2e3ee9029d1b76 Author: Tom de Vries <tdevries@suse.de> Date: Tue May 26 11:35:32 2020 +0200 [gdb/testsuite] Add test-case gold-gdb-index.exp There's a PR binutils/15646 - "gold-generated .gdb_index has duplicated symbols that gdb-generated index doesn't", and gdb contains a workaround, added in commit 8943b87476 "Work around gold/15646". Add a test-case testing this workaround. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2020-05-26 Tom de Vries <tdevries@suse.de> * gdb.base/gold-gdb-index-2.c: New test. * gdb.base/gold-gdb-index.c: New test. * gdb.base/gold-gdb-index.exp: New file. * gdb.base/gold-gdb-index.h: New test.
The master branch has been updated by Tom de Vries <vries@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f030440daa989ae3dadc1fa4342cfa16d690db3c commit f030440daa989ae3dadc1fa4342cfa16d690db3c Author: Tom de Vries <tdevries@suse.de> Date: Thu May 28 17:26:22 2020 +0200 [gdb/symtab] Make gold index workaround more precise There's a PR gold/15646 - "gold-generated .gdb_index has duplicated symbols that gdb-generated index doesn't", that causes gold to generate duplicate symbols in the index. F.i., a namespace N1 declared in a header file can be listed for two CUs that include the header file: ... [759] N1: 2 [global type] 3 [global type] ... This causes a gdb performance problem: f.i. when attempting to set a breakpoint on a non-existing function N1::misspelled, the symtab for both CUs will be expanded. Gdb contains a workaround for this, added in commit 8943b87476 "Work around gold/15646", that skips duplicate global symbols in the index. However, the workaround does not check for the symbol kind ("type" in the example above). Make the workaround more precise by limiting it to symbol kind "type". Tested on x86_64-linux, with target boards cc-with-gdb-index and gold-gdb-index. gdb/ChangeLog: 2020-05-28 Tom de Vries <tdevries@suse.de> * dwarf2/read.c (dw2_symtab_iter_next, dw2_expand_marked_cus): Limit PR gold/15646 workaround to symbol kind "type".