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
<<attachment: test.zip>>
_______________________________________________ lldb-dev mailing list lldb-dev@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-dev