llvm-project/lldb/unittests
Raphael Isemann 9379d19ff8 [lldb] Decouple importing the std C++ module from the way the program is compiled
Summary:
At the moment, when trying to import the `std` module in LLDB, we look at the imported modules used in the compiled program
and try to infer the Clang configuration we need from the DWARF module-import. That was the initial idea but turned out to
cause a few problems or inconveniences:

* It requires that users compile their programs with C++ modules. Given how experimental C++ modules are makes this feature inaccessible
for many users. Also it means that people can't just get the benefits of this feature for free when we activate it by default
(and we can't just close all the associated bug reports).
* Relying on DWARF's imported module tags (that are only emitted by default on macOS) means this can only be used when using DWARF (and with -glldb on Linux).
* We essentially hardcoded the C standard library paths on some platforms (Linux) or just couldn't support this feature on other platforms (macOS).

This patch drops the whole idea of looking at the imported module DWARF tags and instead just uses the support files of the compilation unit.
If we look at the support files and see file paths that indicate where the C standard library and libc++ are, we can just create the module
configuration this information. This fixes all the problems above which means we can enable all the tests now on Linux, macOS and with other debug information
than what we currently had. The only debug information specific code is now the iteration over external type module when -gmodules is used (as `std` and also the
`Darwin` module are their own external type module with their own files).

The meat of this patch is the CppModuleConfiguration which looks at the file paths from the compilation unit and then figures out the include paths
based on those paths. It's quite conservative in that it only enables modules if we find a single C library and single libc++ library. It's still missing some
test mode where we try to compile an expression before we actually activate the config for the user (which probably also needs some caching mechanism),
but for now it works and makes the feature usable.

Reviewers: aprantl, shafik, jdoerfert

Reviewed By: aprantl

Subscribers: mgorny, abidh, JDevlieghere, lldb-commits

Tags: #c_modules_in_lldb, #lldb

Differential Revision: https://reviews.llvm.org/D67760

llvm-svn: 372716
2019-09-24 10:08:18 +00:00
..
Breakpoint Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Core unittests: Use yaml2obj as a library instead of an external process 2019-08-20 12:28:36 +00:00
Disassembler When disassembling Aarch64 target and vendor Apple, set the cpu to 2019-03-07 03:16:45 +00:00
Editline [lldb][NFC] Allow for-ranges on StringList 2019-08-16 14:27:35 +00:00
Expression [lldb] Decouple importing the std C++ module from the way the program is compiled 2019-09-24 10:08:18 +00:00
Host File::SetDescriptor() should require options 2019-09-23 20:36:46 +00:00
Interpreter [lldb][NFC] Remove WordComplete mode, make result array indexed from 0 and remove any undocumented/redundant return values 2019-08-22 07:41:23 +00:00
Language Make CPlusPlusNameParser robust against nullptr StringRefs. 2019-05-31 00:18:42 +00:00
ObjectFile Breakpad: Add support for parsing STACK WIN records 2019-08-26 11:25:28 +00:00
Platform Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Process [Reproducer] Move GDB Remote Packet into Utility. (NFC) 2019-09-13 23:14:10 +00:00
ScriptInterpreter [CMake] Only the Python scirpt interpreter should link against Python. 2019-04-01 22:03:04 +00:00
Signals Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00
Symbol [lldb][NFC] Remove unused include in TestLineEntry.cpp 2019-09-20 10:30:38 +00:00
SymbolFile [LLDB] Check for _WIN32 instead of _MSC_VER for code specific to windows in general 2019-09-23 12:03:56 +00:00
Target Move ProcessInstanceInfoTest to Utility 2019-08-26 13:07:02 +00:00
TestingSupport [lldb] - Update unit tests after lib/ObjectYAML change. 2019-09-13 16:00:28 +00:00
UnwindAssembly Add support for mid-function epilogues on x86 that end in a non-local jump. 2019-06-03 22:34:12 +00:00
Utility [lldb] Remove redundant argument lists in CompletionRequest 2019-09-24 07:22:44 +00:00
debugserver [NFC] Remove ASCII lines from comments 2019-04-10 20:48:55 +00:00
tools [lldb-server] Disable a test on Windows until it can be fixed 2019-08-16 03:49:41 +00:00
CMakeLists.txt [CMake] Align debugserver with lldb-server on Darwin 2019-07-20 11:18:31 +00:00
gtest_common.h Update the file headers across all of the LLVM projects in the monorepo 2019-01-19 08:50:56 +00:00