https://github.com/Michael137 created https://github.com/llvm/llvm-project/pull/102488
This will soon be needed for https://github.com/llvm/llvm-project/pull/102309, where we plan on calling these APIs from generic ExpressionParser code. >From 99dd6c9d974ffd95f3c2aed9dfb2a861cc55f084 Mon Sep 17 00:00:00 2001 From: Michael Buch <michaelbuc...@gmail.com> Date: Thu, 8 Aug 2024 16:07:21 +0100 Subject: [PATCH] [lldb][Platform] Move the GetSDKPathFromDebugInfo helpers from PlatformDarwin into Platform This will soon be needed for https://github.com/llvm/llvm-project/pull/102309, where we plan on calling these APIs from generic ExpressionParser code. --- lldb/include/lldb/Target/Platform.h | 34 +++++++++++++++++++ .../Plugins/Platform/MacOSX/PlatformDarwin.h | 31 +++-------------- 2 files changed, 39 insertions(+), 26 deletions(-) diff --git a/lldb/include/lldb/Target/Platform.h b/lldb/include/lldb/Target/Platform.h index 5ed2fc33356d9d..8cf52a486e2c87 100644 --- a/lldb/include/lldb/Target/Platform.h +++ b/lldb/include/lldb/Target/Platform.h @@ -27,6 +27,7 @@ #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/Timeout.h" #include "lldb/Utility/UserIDResolver.h" +#include "lldb/Utility/XcodeSDK.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-public.h" @@ -436,6 +437,39 @@ class Platform : public PluginInterface { return lldb_private::ConstString(); } + /// Search each CU associated with the specified 'module' for + /// the SDK paths the CUs were compiled against. In the presence + /// of different SDKs, we try to pick the most appropriate one + /// using \ref XcodeSDK::Merge. + /// + /// \param[in] module Module whose debug-info CUs to parse for + /// which SDK they were compiled against. + /// + /// \returns If successful, returns a pair of a parsed XcodeSDK + /// object and a boolean that is 'true' if we encountered + /// a conflicting combination of SDKs when parsing the CUs + /// (e.g., a public and internal SDK). + virtual llvm::Expected<std::pair<XcodeSDK, bool>> + GetSDKPathFromDebugInfo(Module &module) { + return llvm::createStringError(llvm::formatv( + "{0} not implemented for '{1}' platform.", __func__, GetName())); + } + + /// Returns the full path of the most appropriate SDK for the + /// specified 'module'. This function gets this path by parsing + /// debug-info (see \ref `GetSDKPathFromDebugInfo`). + /// + /// \param[in] module Module whose debug-info to parse for + /// which SDK it was compiled against. + /// + /// \returns If successful, returns the full path to an + /// Xcode SDK. + virtual llvm::Expected<std::string> + ResolveSDKPathFromDebugInfo(Module &module) { + return llvm::createStringError(llvm::formatv( + "{0} not implemented for '{1}' platform.", __func__, GetName())); + } + const std::string &GetRemoteURL() const { return m_remote_url; } bool IsHost() const { diff --git a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h index ff7087da6825d9..66a26d2f496776 100644 --- a/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ b/lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -124,32 +124,11 @@ class PlatformDarwin : public PlatformPOSIX { /// located in. static FileSpec GetCurrentCommandLineToolsDirectory(); - /// Search each CU associated with the specified 'module' for - /// the SDK paths the CUs were compiled against. In the presence - /// of different SDKs, we try to pick the most appropriate one - /// using \ref XcodeSDK::Merge. - /// - /// \param[in] module Module whose debug-info CUs to parse for - /// which SDK they were compiled against. - /// - /// \returns If successful, returns a pair of a parsed XcodeSDK - /// object and a boolean that is 'true' if we encountered - /// a conflicting combination of SDKs when parsing the CUs - /// (e.g., a public and internal SDK). - static llvm::Expected<std::pair<XcodeSDK, bool>> - GetSDKPathFromDebugInfo(Module &module); - - /// Returns the full path of the most appropriate SDK for the - /// specified 'module'. This function gets this path by parsing - /// debug-info (see \ref `GetSDKPathFromDebugInfo`). - /// - /// \param[in] module Module whose debug-info to parse for - /// which SDK it was compiled against. - /// - /// \returns If successful, returns the full path to an - /// Xcode SDK. - static llvm::Expected<std::string> - ResolveSDKPathFromDebugInfo(Module &module); + llvm::Expected<std::pair<XcodeSDK, bool>> + GetSDKPathFromDebugInfo(Module &module) override; + + llvm::Expected<std::string> + ResolveSDKPathFromDebugInfo(Module &module) override; protected: static const char *GetCompatibleArch(ArchSpec::Core core, size_t idx); _______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits