teemperor created this revision.
teemperor added a reviewer: aprantl.
Herald added subscribers: lldb-commits, abidh.
Herald added a project: LLDB.
`GetSystemIncludeDirectories` is currently only implemented for Linux where it
returns `/usr/include` with a potential sysroot
as a prefix. This patch implements the equivalent functionality on macOS.
Repository:
rLLDB LLDB
https://reviews.llvm.org/D61240
Files:
lldb/include/lldb/Target/Platform.h
lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
lldb/source/Plugins/Platform/Linux/PlatformLinux.h
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
+++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.h
@@ -69,6 +69,10 @@
lldb_private::ConstString
GetSDKDirectory(lldb_private::Target &target) override;
+ std::vector<std::string>
+ GetSystemIncludeDirectories(lldb::LanguageType lang,
+ lldb_private::Target &target) override;
+
void
AddClangModuleCompilationOptions(lldb_private::Target *target,
std::vector<std::string> &options) override {
Index: lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
===================================================================
--- lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
+++ lldb/source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp
@@ -226,6 +226,27 @@
return ConstString();
}
+std::vector<std::string>
+PlatformMacOSX::GetSystemIncludeDirectories(LanguageType lang,
+ lldb_private::Target &target) {
+ std::string sys_root = GetSDKDirectory(target).AsCString("");
+ switch (lang) {
+ case lldb::eLanguageTypeC:
+ case lldb::eLanguageTypeC89:
+ case lldb::eLanguageTypeC99:
+ case lldb::eLanguageTypeC11:
+ case lldb::eLanguageTypeC_plus_plus:
+ case lldb::eLanguageTypeC_plus_plus_03:
+ case lldb::eLanguageTypeC_plus_plus_11:
+ case lldb::eLanguageTypeC_plus_plus_14:
+ case lldb::eLanguageTypeObjC:
+ case lldb::eLanguageTypeObjC_plus_plus:
+ return {sys_root + "/usr/include/"};
+ default:
+ return {};
+ }
+}
+
Status PlatformMacOSX::GetSymbolFile(const FileSpec &platform_file,
const UUID *uuid_ptr,
FileSpec &local_file) {
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.h
===================================================================
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.h
+++ lldb/source/Plugins/Platform/Linux/PlatformLinux.h
@@ -49,7 +49,8 @@
bool CanDebugProcess() override;
std::vector<std::string>
- GetSystemIncludeDirectories(lldb::LanguageType lang) override;
+ GetSystemIncludeDirectories(lldb::LanguageType lang,
+ lldb_private::Target &target) override;
lldb::ProcessSP DebugProcess(ProcessLaunchInfo &launch_info,
Debugger &debugger, Target *target,
Index: lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
===================================================================
--- lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
+++ lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp
@@ -261,7 +261,8 @@
}
std::vector<std::string>
-PlatformLinux::GetSystemIncludeDirectories(lldb::LanguageType lang) {
+PlatformLinux::GetSystemIncludeDirectories(lldb::LanguageType lang,
+ lldb_private::Target &target) {
std::string sys_root = GetSDKRootDirectory().AsCString("");
switch (lang) {
case lldb::eLanguageTypeC:
Index: lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
===================================================================
--- lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
+++ lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
@@ -217,10 +217,9 @@
std::shared_ptr<clang::TextDiagnosticBuffer> m_passthrough;
};
-static void
-SetupModuleHeaderPaths(CompilerInstance *compiler,
- std::vector<ConstString> include_directories,
- lldb::TargetSP target_sp) {
+static void SetupModuleHeaderPaths(CompilerInstance *compiler,
+ std::vector<ConstString> include_directories,
+ lldb_private::Target &target) {
Log *log(lldb_private::GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS));
HeaderSearchOptions &search_opts = compiler->getHeaderSearchOpts();
@@ -249,8 +248,8 @@
search_opts.ImplicitModuleMaps = true;
std::vector<std::string> system_include_directories =
- target_sp->GetPlatform()->GetSystemIncludeDirectories(
- lldb::eLanguageTypeC_plus_plus);
+ target.GetPlatform()->GetSystemIncludeDirectories(
+ lldb::eLanguageTypeC_plus_plus, target);
for (const std::string &include_dir : system_include_directories) {
search_opts.AddPath(include_dir, frontend::System, false, true);
@@ -512,8 +511,7 @@
lang_opts.DoubleSquareBracketAttributes = true;
lang_opts.CPlusPlus11 = true;
- SetupModuleHeaderPaths(m_compiler.get(), m_include_directories,
- target_sp);
+ SetupModuleHeaderPaths(m_compiler.get(), m_include_directories, *target_sp);
}
if (process_sp && lang_opts.ObjC) {
Index: lldb/include/lldb/Target/Platform.h
===================================================================
--- lldb/include/lldb/Target/Platform.h
+++ lldb/include/lldb/Target/Platform.h
@@ -258,15 +258,19 @@
virtual bool SetRemoteWorkingDirectory(const FileSpec &working_dir);
/// Retrieve the system include directories on this platform for the
- /// given language.
+ /// given language and target.
///
/// \param[in] lang
/// The language for which the include directories should be queried.
///
+ /// \param[in] target
+ /// The target for which the include directories should be queried.
+ ///
/// \param[out] directories
/// The include directories for this system.
virtual std::vector<std::string>
- GetSystemIncludeDirectories(lldb::LanguageType lang) {
+ GetSystemIncludeDirectories(lldb::LanguageType lang,
+ lldb_private::Target &target) {
return {};
}
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits