<div dir="ltr">Can you move this to FileSystem.h? I don't think we should be adding more things that hit the file system to FileSpec. That's exactly the reason FileSystem.h exists, because many of the operations will be implemented differently across platforms, so we should be using the Host layer.</div><br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 18, 2015 at 2:38 PM Sean Callanan via lldb-commits <<a href="mailto:lldb-commits@lists.llvm.org">lldb-commits@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">spyffe updated this revision to Diff 35138.<br>
spyffe added a comment.<br>
<br>
Updated to reflect Greg's comments.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D12984" rel="noreferrer" target="_blank">http://reviews.llvm.org/D12984</a><br>
<br>
Files:<br>
include/lldb/Host/FileSpec.h<br>
source/Host/common/FileSpec.cpp<br>
source/Host/common/HostInfoBase.cpp<br>
<br>
Index: source/Host/common/HostInfoBase.cpp<br>
===================================================================<br>
--- source/Host/common/HostInfoBase.cpp<br>
+++ source/Host/common/HostInfoBase.cpp<br>
@@ -306,7 +306,10 @@<br>
<br>
FileSpec lldb_file_spec(<br>
Host::GetModuleFileSpecForHostAddress(reinterpret_cast<void *>(reinterpret_cast<intptr_t>(HostInfoBase::GetLLDBPath))));<br>
-<br>
+<br>
+ // This is necessary because when running the testsuite the shlib might be a symbolic link inside the Python resource dir.<br>
+ lldb_file_spec = lldb_file_spec.ResolveSymbolicLink();<br>
+<br>
// Remove the filename so that this FileSpec only represents the directory.<br>
file_spec.GetDirectory() = lldb_file_spec.GetDirectory();<br>
<br>
Index: source/Host/common/FileSpec.cpp<br>
===================================================================<br>
--- source/Host/common/FileSpec.cpp<br>
+++ source/Host/common/FileSpec.cpp<br>
@@ -811,6 +811,32 @@<br>
#endif<br>
}<br>
<br>
+FileSpec<br>
+FileSpec::ResolveSymbolicLink () const {<br>
+ if (!IsSymbolicLink())<br>
+ {<br>
+ return *this;<br>
+ }<br>
+<br>
+ char resolved_path[PATH_MAX];<br>
+ if (!GetPath (resolved_path, sizeof (resolved_path)))<br>
+ {<br>
+ return *this;<br>
+ }<br>
+<br>
+#ifdef _WIN32<br>
+ return *this; // TODO make this work on win32<br>
+#else<br>
+ char real_path[PATH_MAX + 1];<br>
+ if (realpath(resolved_path, real_path) == nullptr)<br>
+ {<br>
+ return *this;<br>
+ }<br>
+<br>
+ return FileSpec(real_path, false);<br>
+#endif<br>
+}<br>
+<br>
uint32_t<br>
FileSpec::GetPermissions () const<br>
{<br>
Index: include/lldb/Host/FileSpec.h<br>
===================================================================<br>
--- include/lldb/Host/FileSpec.h<br>
+++ include/lldb/Host/FileSpec.h<br>
@@ -73,7 +73,7 @@<br>
/// The full or partial path to a file.<br>
///<br>
/// @param[in] resolve_path<br>
- /// If \b true, then we resolve the path with realpath,<br>
+ /// If \b true, then we resolve the path, removing stray ../.. and so forth,<br>
/// if \b false we trust the path is in canonical form already.<br>
///<br>
/// @see FileSpec::SetFile (const char *path, bool resolve)<br>
@@ -511,6 +511,9 @@<br>
<br>
bool<br>
IsSymbolicLink () const;<br>
+<br>
+ FileSpec<br>
+ ResolveSymbolicLink () const;<br>
<br>
//------------------------------------------------------------------<br>
/// Get the memory cost of this object.<br>
<br>
<br>
_______________________________________________<br>
lldb-commits mailing list<br>
<a href="mailto:lldb-commits@lists.llvm.org" target="_blank">lldb-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits</a><br>
</blockquote></div>