[lldb-dev] SymbolFileDWARF::ParseDeclsForContext getting slow with multiple expr evals
Guilherme Andrade via lldb-dev
lldb-dev at lists.llvm.org
Sat Aug 3 10:22:15 PDT 2019
Hi,
I've noticed that `expr` causes LLDB to spend a substantial amount of time
on SymbolFileDWARF::ParseDeclsForContext as more types get realized. So I
put together a tiny project to try to better understand that behavior, and
I was wondering if you guys could help me.
The project (test.zip) consists of a main function that calls three
functions (f1, f2, f3) in an infinite loop. Each function is implemented in
its own file and the function itself simply declares a local variable of a
type declared inside the function file in an anonymous namespace.
I added a breakpoint to the loop in main (`cd test && g++ -g -x c++ *.cpp
&& lldb a.out -o 'b main.cpp:7' -o 'r'`), and tried to evaluate an
undefined symbol (`expr undefinedVariable`) inside the loop, then inside
each of the functions, and inside of the loop again (`s` and `expr
undefinedVariable` four times). To my surprise, the symbols hidden inside
the anonymous namespace of the function files would be carried around,
regardless of the current scope (custom log trying to describe the calls to
ClangASTContext::DeclContextFindDeclByName and
SymbolFileDWARF::ParseDeclsForContext
- https://pastebin.com/wVhvsFXe). So, I have a few questions about that.
1) Why do we need to keep track of names out of scope?
2) Despite the reason behind 1), aren't we missing an opportunity of
caching those compiler declaration contexts somehow so as to avoid
iterating over the whole DIE vector inside ParseDeclsForContext every time?
If I understood the code correctly, when you run multiple expression
evaluations, the vast majority of the
`ast_parser->GetDeclForUIDFromDWARF(decl)`
calls (https://github.com/llvm/llvm-project/blob/
23f70e83594f650830764cca446fdfcba7368460/lldb/source/
Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp#L1195) will end up having no
side effect as those DIEs will already be in the
DWARFASTParserClang::m_die_to_decl map (https://github.com/llvm/llvm-
project/blob/af44f18ad66b4f7bbe6a8f6ffa29637a4a5aeea1/lldb/source/
Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp#L3315).
I'm sorry for the lengthy email.
Many thanks!
Guilherme
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190803/982fc522/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test.zip
Type: application/octet-stream
Size: 1819 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-dev/attachments/20190803/982fc522/attachment.obj>
More information about the lldb-dev
mailing list