s at martinien dot de
2018-04-09 13:49:19 UTC
https://sourceware.org/bugzilla/show_bug.cgi?id=23042
Bug ID: 23042
Summary: typedef resolution traverses all CUs for MI var-create
Product: gdb
Version: 8.1
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: s at martinien dot de
Target Milestone: ---
Hi,
when using gdb via MI (e.g. via Visual Studio Code or Studio) on a build
compiled with -gsplit-dwarf, debugging becomes unusably slow.
This can be traced down to Visual Studio's feature which displays values of
function arguments in the callstack. They do this via simple MI commands:
1-var-create - * "i"
It appears this command is very slow when i is a common typedef, like size_t.
With this example:
---
typedef unsigned long size_ttt;
typedef unsigned long size_t;
int main()
{
size_ttt fast = 0;
size_t slow = 0;
return 0;
}
---
1-var-create - * "fast" is fast, but
1-var-create - * "slow" is slow.
Note that in my example I have lots of other shared libraries linked into the
program.
Stepping through gdb for these two commands above, the main difference is that
for the fast case, dw2_symtab_iter_next() always returns 0x0. For the slow case
it returns CUs, and then dw2_instantiate_symtab() is called which seems to take
all the time.
In the code I saw this comment:
dwarf2read.c
4241 /* Work around gold/15646. */
4242 if (!is_static && iter->global_seen)
Looking at https://sourceware.org/bugzilla/show_bug.cgi?id=15646 this seems to
be related to the gdbindex of gold, which incidentally was enabled on my
binaries. Switching to indexing via gdb solved the problem.
Now some questions:
- Can this be workarounded in gdb also? The gold builtin gdbindexer is faster,
so I would prefer using that.
- Should the gold gdbindex be fixed (can it?) Unfortunately nothing has
happened in the other bug... I will also try lld.
- Why does this only trigger via MI? "p slow", "ptype slow" both return
quickly.
I'm attaching a simple reproducer that shows the behavior for the two
var-create commands. You can place a breakpoint in dw2_symtab_iter_next() and
compare the return values.
Thanks and Best regards,
Martin
Bug ID: 23042
Summary: typedef resolution traverses all CUs for MI var-create
Product: gdb
Version: 8.1
Status: UNCONFIRMED
Severity: minor
Priority: P2
Component: gdb
Assignee: unassigned at sourceware dot org
Reporter: s at martinien dot de
Target Milestone: ---
Hi,
when using gdb via MI (e.g. via Visual Studio Code or Studio) on a build
compiled with -gsplit-dwarf, debugging becomes unusably slow.
This can be traced down to Visual Studio's feature which displays values of
function arguments in the callstack. They do this via simple MI commands:
1-var-create - * "i"
It appears this command is very slow when i is a common typedef, like size_t.
With this example:
---
typedef unsigned long size_ttt;
typedef unsigned long size_t;
int main()
{
size_ttt fast = 0;
size_t slow = 0;
return 0;
}
---
1-var-create - * "fast" is fast, but
1-var-create - * "slow" is slow.
Note that in my example I have lots of other shared libraries linked into the
program.
Stepping through gdb for these two commands above, the main difference is that
for the fast case, dw2_symtab_iter_next() always returns 0x0. For the slow case
it returns CUs, and then dw2_instantiate_symtab() is called which seems to take
all the time.
In the code I saw this comment:
dwarf2read.c
4241 /* Work around gold/15646. */
4242 if (!is_static && iter->global_seen)
Looking at https://sourceware.org/bugzilla/show_bug.cgi?id=15646 this seems to
be related to the gdbindex of gold, which incidentally was enabled on my
binaries. Switching to indexing via gdb solved the problem.
Now some questions:
- Can this be workarounded in gdb also? The gold builtin gdbindexer is faster,
so I would prefer using that.
- Should the gold gdbindex be fixed (can it?) Unfortunately nothing has
happened in the other bug... I will also try lld.
- Why does this only trigger via MI? "p slow", "ptype slow" both return
quickly.
I'm attaching a simple reproducer that shows the behavior for the two
var-create commands. You can place a breakpoint in dw2_symtab_iter_next() and
compare the return values.
Thanks and Best regards,
Martin
--
You are receiving this mail because:
You are on the CC list for the bug.
You are receiving this mail because:
You are on the CC list for the bug.