llvm-project/lldb
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
..
cmake [lldb][CMake] Build LLDB.framework with -Wdocumentation in Xcode 2019-09-18 10:41:13 +00:00
docs [lldb][CMake] Infer `Clang_DIR` if not passed explicitly 2019-09-18 10:20:28 +00:00
examples Revert [heap.py] Add missing declaration for malloc_get_all_zones 2019-08-22 21:01:45 +00:00
include/lldb [lldb] Decouple importing the std C++ module from the way the program is compiled 2019-09-24 10:08:18 +00:00
lit Fix command-script-import.test on linux 2019-09-18 12:58:52 +00:00
packages/Python/lldbsuite [lldb] Decouple importing the std C++ module from the way the program is compiled 2019-09-24 10:08:18 +00:00
resources [CMake] Revised LLDB.framework builds 2019-01-04 12:46:50 +00:00
scripts prepare_binding_Python: print readable errors if SWIG fails 2019-09-20 23:41:32 +00:00
source [lldb] Decouple importing the std C++ module from the way the program is compiled 2019-09-24 10:08:18 +00:00
test [test] Fix various module cache bugs and inconsistencies 2019-08-29 18:37:05 +00:00
third_party/Python/module dotest.py: bugfix: test filters with -f do not work on Python3 2019-09-20 23:41:29 +00:00
tools [LLDB] Rework a MinGW build fix from D65691 2019-09-23 20:43:11 +00:00
unittests [lldb] Decouple importing the std C++ module from the way the program is compiled 2019-09-24 10:08:18 +00:00
utils [test] Fix various module cache bugs and inconsistencies 2019-08-29 18:37:05 +00:00
.arcconfig
.clang-format
.gitignore Add .noindex to the gitignore 2019-04-05 17:57:42 +00:00
CMakeLists.txt [test] Fix various module cache bugs and inconsistencies 2019-08-29 18:37:05 +00:00
CODE_OWNERS.txt [lldb][NFC] Cleanup mentions and code related to lldb-mi 2019-07-19 15:55:23 +00:00
LICENSE.TXT Fix typos throughout the license files that somehow I and my reviewers 2019-01-21 09:52:34 +00:00
use_lldb_suite_root.py