Index: include/lldb/Host/FileSpec.h =================================================================== --- include/lldb/Host/FileSpec.h +++ include/lldb/Host/FileSpec.h @@ -511,9 +511,6 @@ bool IsSymbolicLink () const; - - FileSpec - ResolveSymbolicLink () const; //------------------------------------------------------------------ /// Get the memory cost of this object. Index: include/lldb/Host/FileSystem.h =================================================================== --- include/lldb/Host/FileSystem.h +++ include/lldb/Host/FileSystem.h @@ -39,6 +39,8 @@ 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 Realpath(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, Index: source/Host/common/FileSpec.cpp =================================================================== --- source/Host/common/FileSpec.cpp +++ source/Host/common/FileSpec.cpp @@ -811,32 +811,6 @@ #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 { Index: source/Host/common/HostInfoBase.cpp =================================================================== --- source/Host/common/HostInfoBase.cpp +++ source/Host/common/HostInfoBase.cpp @@ -308,7 +308,7 @@ Host::GetModuleFileSpecForHostAddress(reinterpret_cast(reinterpret_cast(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::Realpath(lldb_file_spec, lldb_file_spec); // Remove the filename so that this FileSpec only represents the directory. file_spec.GetDirectory() = lldb_file_spec.GetDirectory(); Index: source/Host/posix/FileSystem.cpp =================================================================== --- source/Host/posix/FileSystem.cpp +++ source/Host/posix/FileSystem.cpp @@ -226,6 +226,28 @@ return error; } +Error +FileSystem::Realpath(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) { Index: source/Host/windows/FileSystem.cpp =================================================================== --- source/Host/windows/FileSystem.cpp +++ source/Host/windows/FileSystem.cpp @@ -199,6 +199,12 @@ return error; } +Error +FileSystem::Realpath(const FileSpec &src, FileSpec &dst) +{ + return Error("Realpath() isn't implemented on Windows"); +} + bool FileSystem::IsLocal(const FileSpec &spec) {