diff options
Diffstat (limited to 'lldb/source/Core/FileSpec.cpp')
| -rw-r--r-- | lldb/source/Core/FileSpec.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/lldb/source/Core/FileSpec.cpp b/lldb/source/Core/FileSpec.cpp index b4aea9c888a..fc197ad2412 100644 --- a/lldb/source/Core/FileSpec.cpp +++ b/lldb/source/Core/FileSpec.cpp @@ -18,6 +18,10 @@ #include <fstream> +#include "llvm/ADT/StringRef.h" +#include "llvm/System/Path.h" +#include "llvm/System/Program.h" + #include "lldb/Core/FileSpec.h" #include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataBufferMemoryMap.h" @@ -418,7 +422,35 @@ FileSpec::Exists () const bool FileSpec::ResolveExecutableLocation () { - return Host::ResolveExecutableLocation (m_directory, m_filename); + if (m_directory.GetLength() == 0) + { + const std::string file_str (m_filename.AsCString()); + llvm::sys::Path path = llvm::sys::Program::FindProgramByName (file_str); + llvm::StringRef dir_ref = path.getDirname(); + if (! dir_ref.empty()) + { + // FindProgramByName returns "." if it can't find the file. + if (strcmp (".", dir_ref.data()) == 0) + return false; + + m_directory.SetCString (dir_ref.data()); + if (Exists()) + return true; + else + { + // If FindProgramByName found the file, it returns the directory + filename in its return results. + // We need to separate them. + FileSpec tmp_file (dir_ref.data()); + if (tmp_file.Exists()) + { + m_directory = tmp_file.m_directory; + return true; + } + } + } + } + + return false; } uint64_t |

