Skip to content

Commit f5d59eb

Browse files
Use the root directory as the SDK root on POSIX platforms
LLDB has the concept of an "SDK root", which expresses where the system libraries and so which are necessary for debugging can be found. On POSIX platforms, the SDK root is just the root of the file system, or /. We need to implement the appropriate method on HostInfoPosix to prevent the use of the default implementation for which just returns an error. This change is needed to support the Swift REPL but may be useful for other use cases as well.
1 parent 16a54eb commit f5d59eb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lldb/include/lldb/Host/posix/HostInfoPosix.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ class HostInfoPosix : public HostInfoBase {
4343
static bool ComputeSwiftResourceDirectory(FileSpec &lldb_shlib_spec,
4444
FileSpec &file_spec, bool verify);
4545
#endif
46-
46+
47+
static llvm::Expected<llvm::StringRef> GetSDKRoot(SDKOptions options);
48+
4749
protected:
4850
static bool ComputeSupportExeDirectory(FileSpec &file_spec);
4951
static bool ComputeHeaderDirectory(FileSpec &file_spec);

lldb/source/Host/posix/HostInfoPosix.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,12 @@ std::optional<std::string> PosixUserIDResolver::DoGetGroupName(id_t gid) {
117117
return std::nullopt;
118118
}
119119

120+
/// The SDK is the directory where the system C headers, libraries, can be found.
121+
/// On POSIX platforms this is simply the root directory.
122+
llvm::Expected<llvm::StringRef> HostInfoPosix::GetSDKRoot(SDKOptions options) {
123+
return "/";
124+
}
125+
120126
static llvm::ManagedStatic<PosixUserIDResolver> g_user_id_resolver;
121127

122128
UserIDResolver &HostInfoPosix::GetUserIDResolver() {

0 commit comments

Comments
 (0)