Skip to content

Commit 99dd6c9

Browse files
committed
[lldb][Platform] Move the GetSDKPathFromDebugInfo helpers from PlatformDarwin into Platform
This will soon be needed for llvm#102309, where we plan on calling these APIs from generic ExpressionParser code.
1 parent 29817a9 commit 99dd6c9

File tree

2 files changed

+39
-26
lines changed

2 files changed

+39
-26
lines changed

lldb/include/lldb/Target/Platform.h

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "lldb/Utility/StructuredData.h"
2828
#include "lldb/Utility/Timeout.h"
2929
#include "lldb/Utility/UserIDResolver.h"
30+
#include "lldb/Utility/XcodeSDK.h"
3031
#include "lldb/lldb-private-forward.h"
3132
#include "lldb/lldb-public.h"
3233

@@ -436,6 +437,39 @@ class Platform : public PluginInterface {
436437
return lldb_private::ConstString();
437438
}
438439

440+
/// Search each CU associated with the specified 'module' for
441+
/// the SDK paths the CUs were compiled against. In the presence
442+
/// of different SDKs, we try to pick the most appropriate one
443+
/// using \ref XcodeSDK::Merge.
444+
///
445+
/// \param[in] module Module whose debug-info CUs to parse for
446+
/// which SDK they were compiled against.
447+
///
448+
/// \returns If successful, returns a pair of a parsed XcodeSDK
449+
/// object and a boolean that is 'true' if we encountered
450+
/// a conflicting combination of SDKs when parsing the CUs
451+
/// (e.g., a public and internal SDK).
452+
virtual llvm::Expected<std::pair<XcodeSDK, bool>>
453+
GetSDKPathFromDebugInfo(Module &module) {
454+
return llvm::createStringError(llvm::formatv(
455+
"{0} not implemented for '{1}' platform.", __func__, GetName()));
456+
}
457+
458+
/// Returns the full path of the most appropriate SDK for the
459+
/// specified 'module'. This function gets this path by parsing
460+
/// debug-info (see \ref `GetSDKPathFromDebugInfo`).
461+
///
462+
/// \param[in] module Module whose debug-info to parse for
463+
/// which SDK it was compiled against.
464+
///
465+
/// \returns If successful, returns the full path to an
466+
/// Xcode SDK.
467+
virtual llvm::Expected<std::string>
468+
ResolveSDKPathFromDebugInfo(Module &module) {
469+
return llvm::createStringError(llvm::formatv(
470+
"{0} not implemented for '{1}' platform.", __func__, GetName()));
471+
}
472+
439473
const std::string &GetRemoteURL() const { return m_remote_url; }
440474

441475
bool IsHost() const {

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.h

Lines changed: 5 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -124,32 +124,11 @@ class PlatformDarwin : public PlatformPOSIX {
124124
/// located in.
125125
static FileSpec GetCurrentCommandLineToolsDirectory();
126126

127-
/// Search each CU associated with the specified 'module' for
128-
/// the SDK paths the CUs were compiled against. In the presence
129-
/// of different SDKs, we try to pick the most appropriate one
130-
/// using \ref XcodeSDK::Merge.
131-
///
132-
/// \param[in] module Module whose debug-info CUs to parse for
133-
/// which SDK they were compiled against.
134-
///
135-
/// \returns If successful, returns a pair of a parsed XcodeSDK
136-
/// object and a boolean that is 'true' if we encountered
137-
/// a conflicting combination of SDKs when parsing the CUs
138-
/// (e.g., a public and internal SDK).
139-
static llvm::Expected<std::pair<XcodeSDK, bool>>
140-
GetSDKPathFromDebugInfo(Module &module);
141-
142-
/// Returns the full path of the most appropriate SDK for the
143-
/// specified 'module'. This function gets this path by parsing
144-
/// debug-info (see \ref `GetSDKPathFromDebugInfo`).
145-
///
146-
/// \param[in] module Module whose debug-info to parse for
147-
/// which SDK it was compiled against.
148-
///
149-
/// \returns If successful, returns the full path to an
150-
/// Xcode SDK.
151-
static llvm::Expected<std::string>
152-
ResolveSDKPathFromDebugInfo(Module &module);
127+
llvm::Expected<std::pair<XcodeSDK, bool>>
128+
GetSDKPathFromDebugInfo(Module &module) override;
129+
130+
llvm::Expected<std::string>
131+
ResolveSDKPathFromDebugInfo(Module &module) override;
153132

154133
protected:
155134
static const char *GetCompatibleArch(ArchSpec::Core core, size_t idx);

0 commit comments

Comments
 (0)