[Lldb-commits] [PATCH] D58125: Add ability to import std module into expression parser to improve C++ debugging

Raphael Isemann via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Tue Feb 12 08:06:40 PST 2019


teemperor created this revision.
teemperor added reviewers: aprantl, jingham, shafik, friss, davide.
teemperor added a project: C++ modules in LLDB.
Herald added subscribers: lldb-commits, jdoerfert, abidh, mgorny.
Herald added a reviewer: serge-sans-paille.
Herald added a project: LLDB.

This patch is the MVP version of importing the std module into the expression parser to improve C++ debugging.

What happens in this patch is that we inject a `@import std` into our expression source code. We also
modify our internal Clang instance for parsing this expression to work with modules and debug info
at the same time (which is the main change in terms of LOC). We implicitly build the `std` module on the first use. The
C++ include paths for building are extracted from the debug info, which means that this currently only
works if the program is compiled with `-glldb -fmodules` and uses the std module. The C include paths
are currently specified by LLDB.

I enabled the tests currently only for libc++ and Linux because I could test this locally. I'll enable the tests
for other platforms once this has landed and doesn't break any bots (and I implemented the platform-specific
C include paths for them).

With this patch we can now:

- Build a libc++ as a module and import it into the expression parser.
- Read from the module while also referencing declarations from the debug info. E.g. `std::abs(local_variable)`.

What doesn't work (yet):

- Merging debug info and C++ module declarations. E.g. `std::vector<CustomClass>` doesn't work.
- Pretty much anything that involves the ASTImporter and templated code. As the ASTImporter is used for saving the result declaration, this means that we can't

call yet any function that returns a non-trivial type.

- Use libstdc++ for this, as it requires multiple include paths and Clang only emits one include path per module. Also libstdc++ doesn't support Clang modules without patches.


Repository:
  rLLDB LLDB

https://reviews.llvm.org/D58125

Files:
  lldb/include/lldb/Expression/ExpressionSourceCode.h
  lldb/include/lldb/Symbol/CompileUnit.h
  lldb/include/lldb/Symbol/SymbolFile.h
  lldb/include/lldb/Symbol/SymbolVendor.h
  lldb/include/lldb/Target/Platform.h
  lldb/include/lldb/Target/Target.h
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/basic/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/basic/TestImportStdModule.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/basic/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/conflicts/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/conflicts/TestImportStdModule.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/conflicts/main.cpp
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/no-std-module/Makefile
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/no-std-module/TestImportStdModule.py
  lldb/packages/Python/lldbsuite/test/expression_command/import-std-module/no-std-module/main.cpp
  lldb/source/Expression/ExpressionSourceCode.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ASTConsumerUtils.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ASTConsumerUtils.h
  lldb/source/Plugins/ExpressionParser/Clang/CMakeLists.txt
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.h
  lldb/source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangUserExpression.h
  lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
  lldb/source/Plugins/Platform/Linux/PlatformLinux.h
  lldb/source/Plugins/SymbolFile/Breakpad/SymbolFileBreakpad.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.h
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.h
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.cpp
  lldb/source/Plugins/SymbolFile/NativePDB/SymbolFileNativePDB.h
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.cpp
  lldb/source/Plugins/SymbolFile/PDB/SymbolFilePDB.h
  lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.cpp
  lldb/source/Plugins/SymbolFile/Symtab/SymbolFileSymtab.h
  lldb/source/Symbol/CompileUnit.cpp
  lldb/source/Symbol/SymbolVendor.cpp
  lldb/source/Target/Target.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58125.186458.patch
Type: text/x-patch
Size: 75912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190212/46b6cf7e/attachment-0001.bin>


More information about the lldb-commits mailing list