var create through mi mode on std::istream sometimes very slow

Björn Carlsson
Thu Mar 5 08:57:00 GMT 2020

I need some help to further investigate a problem.
When using VSCode to debug using gdb, it unfortunately load the variables
for all the frames in current thread.
VSCode uses gdb's mi mode to get a vizualisation of these variables.

Most var-create takes 1 or 2 ms. But a few takes hundreds or a couple of
thousand ms.
The worst is std::istream taking around 2 seconds to be created, from the
1: (51975) <-1343-var-create - * "is"
1: (54172)
1: (54172) ->(gdb)
1: (54172) 1343: elapsed time 2197

I can't say that I can reproduce it while running normal gdb, not using mi
mode. And I can't reproduce in a simple small test project, with just a
main and one function call with an std::istream, then the var-create is
down to around 1 ms.

When I test it now I run gdb without my gdbinit to avoid the influence of
our pretty-printers.
I did also test to register a pretty-printer for std::istream that just
returned a static text, it got the time down to around 1400 ms.

Any advice on how to further investigate this problem?

Running gdb 9.1 (same problem in 8.2)
Ubuntu 18.04
C++ (a rather big executable with around 100 threads)

More information about the Gdb mailing list