[Lldb-commits] [PATCH] D59537: Instantiate 'std' templates explicitly in the expression evaluator

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Mar 19 02:36:58 PDT 2019


teemperor created this revision.
teemperor added reviewers: aprantl, shafik, jingham.
teemperor added a project: C++ modules in LLDB.
Herald added subscribers: lldb-commits, jdoerfert, abidh, mgrang, mgorny.
Herald added a reviewer: martong.
Herald added a reviewer: serge-sans-paille.
Herald added a project: LLDB.
teemperor added a parent revision: D59485: [ASTImporter] Allow adding a import strategy to the ASTImporter.
Herald added a subscriber: rnkovacs.

This patch is a follow-up for D58125 <https://reviews.llvm.org/D58125>. It implements the manual instantiation and merging of 'std' templates like
`std::vector` and `std::shared_ptr` with information from the debug info AST. This (finally) allows using these classes
in the expression evaluator like every other class (i.e. things like `vec.size()` and shared_ptr debugging now works, yay!).

The main logic is the `StdModuleHandler` which intercept the ASTImporter import process and replaces any `std` decls
by decls from the C++ module. The decls from the C++ module are "imported" by just deserializing them directly in
the expression evaluation context. This is mostly because we don't want to rely on the ASTImporter to correctly import
these declarations.

This patch doesn't contain the automatic desugaring for result variables. This means that if you call for example
`size` of `std::vector` you maybe get some very verbose typedef'd type as the variable type, e.g.
`std::vector<int, std::allocator<int>>::value_type`.

This is not only unreadable, it also means that our ASTImporter has to import all these types and associated
decls into the persisent variable context. This currently usually leads to some assertion getting triggered
in Clang when the ASTImporter either makes a mistake during importing or our debug info AST is inconsitent.
The current workaround I use in the tests is to just cast the result to it's actual type (e.g. `size_t` or `int`) to prevent
the ASTImporter from having to handle all these complicated decls.

The automatic desugaring will be a future patch because I'm not happy yet with the current code for that and because
I anticipate that this will be a controversial patch.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D59537

Files:
  lldb/include/lldb/Symbol/ClangASTContext.h
  lldb/include/lldb/Symbol/ClangASTImporter.h
  lldb/include/lldb/Symbol/StdModuleHandler.h
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-basic/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-basic/TestBasicDeque.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/deque-basic/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-basic/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-basic/TestBasicForwardList.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/forward_list-basic/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-basic/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-basic/TestBasicList.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/list-basic/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr/TestSharedPtr.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/shared_ptr/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr/TestUniquePtr.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/unique_ptr/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-basic/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-basic/TestBasicVector.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-basic/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-bool/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-bool/TestBoolVector.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/vector-bool/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/weak_ptr/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/weak_ptr/TestWeakPtr.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/weak_ptr/main.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangASTSource.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Symbol/CMakeLists.txt
  lldb/source/Symbol/ClangASTContext.cpp
  lldb/source/Symbol/ClangASTImporter.cpp
  lldb/source/Symbol/StdModuleHandler.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59537.191262.patch
Type: text/x-patch
Size: 41854 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190319/cd66efc1/attachment-0001.bin>


More information about the lldb-commits mailing list