diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp index da14da44f5939..333bcaf8c7a13 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -17,6 +17,7 @@ #include "Plugins/Process/Utility/LinuxSignals.h" #include "Utility/ARM64_DWARF_Registers.h" #include "lldb/Core/Debugger.h" +#include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/UnwindPlan.h" @@ -28,6 +29,9 @@ #include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" +#include "lldb/Symbol/SymbolFile.h" +#include "lldb/Symbol/CompileUnit.h" +#include "lldb/Utility/XcodeSDK.h" // Define these constants from Linux mman.h for use when targeting remote linux // systems even when host has different values. @@ -601,3 +605,21 @@ lldb::StopInfoSP PlatformLinux::GetStopInfoFromSiginfo(Thread &thread) { thread, signo_sp->GetValueAsUnsigned(-1), siginfo_description.c_str(), sicode_sp->GetValueAsUnsigned(0)); } + +llvm::Expected +PlatformLinux::GetSDKPathFromDebugInfo(CompileUnit &unit) { + ModuleSP module_sp = unit.CalculateSymbolContextModule(); + if (!module_sp) + return llvm::createStringError("compile unit has no module"); + + SymbolFile *sym_file = module_sp->GetSymbolFile(); + if (!sym_file) + return llvm::createStringError( + llvm::formatv("No symbol file available for module '{0}'", + module_sp->GetFileSpec().GetFilename())); + + // For Linux, we don't have Xcode SDKs, but we can try to extract + // system library paths from debug info. This is particularly useful + // for Swift runtime libraries. + return sym_file->ParseXcodeSDK(unit); +} diff --git a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h index 0fd33b03dcd23..04ebd0ea4a4ab 100644 --- a/lldb/source/Plugins/Platform/Linux/PlatformLinux.h +++ b/lldb/source/Plugins/Platform/Linux/PlatformLinux.h @@ -64,6 +64,8 @@ class PlatformLinux : public PlatformPOSIX { lldb::StopInfoSP GetStopInfoFromSiginfo(Thread &thread) override; + llvm::Expected GetSDKPathFromDebugInfo(CompileUnit &unit) override; + std::vector m_supported_architectures; private: