summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/include/lldb/Host/FileSpec.h3
-rw-r--r--lldb/include/lldb/Host/FileSystem.h2
-rw-r--r--lldb/source/Host/common/FileSpec.cpp26
-rw-r--r--lldb/source/Host/common/HostInfoBase.cpp2
-rw-r--r--lldb/source/Host/posix/FileSystem.cpp22
-rw-r--r--lldb/source/Host/windows/FileSystem.cpp6
6 files changed, 31 insertions, 30 deletions
diff --git a/lldb/include/lldb/Host/FileSpec.h b/lldb/include/lldb/Host/FileSpec.h
index d8eb49f0ec1..81243d7b25f 100644
--- a/lldb/include/lldb/Host/FileSpec.h
+++ b/lldb/include/lldb/Host/FileSpec.h
@@ -511,9 +511,6 @@ public:
bool
IsSymbolicLink () const;
-
- FileSpec
- ResolveSymbolicLink () const;
//------------------------------------------------------------------
/// Get the memory cost of this object.
diff --git a/lldb/include/lldb/Host/FileSystem.h b/lldb/include/lldb/Host/FileSystem.h
index 3867a34ece6..3d7bfcd4f09 100644
--- a/lldb/include/lldb/Host/FileSystem.h
+++ b/lldb/include/lldb/Host/FileSystem.h
@@ -39,6 +39,8 @@ class FileSystem
static Error Symlink(const FileSpec &src, const FileSpec &dst);
static Error Readlink(const FileSpec &src, FileSpec &dst);
static Error Unlink(const FileSpec &file_spec);
+
+ static Error ResolveSymbolicLink(const FileSpec &src, FileSpec &dst);
static bool CalculateMD5(const FileSpec &file_spec, uint64_t &low, uint64_t &high);
static bool CalculateMD5(const FileSpec &file_spec,
diff --git a/lldb/source/Host/common/FileSpec.cpp b/lldb/source/Host/common/FileSpec.cpp
index f7225a4b0bc..9efdacb010b 100644
--- a/lldb/source/Host/common/FileSpec.cpp
+++ b/lldb/source/Host/common/FileSpec.cpp
@@ -811,32 +811,6 @@ FileSpec::IsSymbolicLink () const
#endif
}
-FileSpec
-FileSpec::ResolveSymbolicLink () const {
- if (!IsSymbolicLink())
- {
- return *this;
- }
-
- char resolved_path[PATH_MAX];
- if (!GetPath (resolved_path, sizeof (resolved_path)))
- {
- return *this;
- }
-
-#ifdef _WIN32
- return *this; // TODO make this work on win32
-#else
- char real_path[PATH_MAX + 1];
- if (realpath(resolved_path, real_path) == nullptr)
- {
- return *this;
- }
-
- return FileSpec(real_path, false);
-#endif
-}
-
uint32_t
FileSpec::GetPermissions () const
{
diff --git a/lldb/source/Host/common/HostInfoBase.cpp b/lldb/source/Host/common/HostInfoBase.cpp
index e7340c538f3..3cb00a875e2 100644
--- a/lldb/source/Host/common/HostInfoBase.cpp
+++ b/lldb/source/Host/common/HostInfoBase.cpp
@@ -308,7 +308,7 @@ HostInfoBase::ComputeSharedLibraryDirectory(FileSpec &file_spec)
Host::GetModuleFileSpecForHostAddress(reinterpret_cast<void *>(reinterpret_cast<intptr_t>(HostInfoBase::GetLLDBPath))));
// This is necessary because when running the testsuite the shlib might be a symbolic link inside the Python resource dir.
- lldb_file_spec = lldb_file_spec.ResolveSymbolicLink();
+ FileSystem::ResolveSymbolicLink(lldb_file_spec, lldb_file_spec);
// Remove the filename so that this FileSpec only represents the directory.
file_spec.GetDirectory() = lldb_file_spec.GetDirectory();
diff --git a/lldb/source/Host/posix/FileSystem.cpp b/lldb/source/Host/posix/FileSystem.cpp
index 4e450202b02..b974c446b91 100644
--- a/lldb/source/Host/posix/FileSystem.cpp
+++ b/lldb/source/Host/posix/FileSystem.cpp
@@ -226,6 +226,28 @@ FileSystem::Readlink(const FileSpec &src, FileSpec &dst)
return error;
}
+Error
+FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst)
+{
+ char resolved_path[PATH_MAX];
+ if (!src.GetPath (resolved_path, sizeof (resolved_path)))
+ {
+ return Error("Couldn't get the canonical path for %s", src.GetCString());
+ }
+
+ char real_path[PATH_MAX + 1];
+ if (realpath(resolved_path, real_path) == nullptr)
+ {
+ Error err;
+ err.SetErrorToErrno();
+ return err;
+ }
+
+ dst = FileSpec(real_path, false);
+
+ return Error();
+}
+
#if defined(__NetBSD__)
static bool IsLocal(const struct statvfs& info)
{
diff --git a/lldb/source/Host/windows/FileSystem.cpp b/lldb/source/Host/windows/FileSystem.cpp
index 3c1e913145f..08190913021 100644
--- a/lldb/source/Host/windows/FileSystem.cpp
+++ b/lldb/source/Host/windows/FileSystem.cpp
@@ -199,6 +199,12 @@ FileSystem::Readlink(const FileSpec &src, FileSpec &dst)
return error;
}
+Error
+FileSystem::ResolveSymbolicLink(const FileSpec &src, FileSpec &dst)
+{
+ return Error("ResolveSymbolicLink() isn't implemented on Windows");
+}
+
bool
FileSystem::IsLocal(const FileSpec &spec)
{
OpenPOWER on IntegriCloud