summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core/FileSpec.cpp
diff options
context:
space:
mode:
authorCaroline Tice <ctice@apple.com>2010-09-12 00:10:52 +0000
committerCaroline Tice <ctice@apple.com>2010-09-12 00:10:52 +0000
commit391a9603a098d0f892135362650c72487b178d61 (patch)
tree8740f0ec73a62dec9de30d801cd8131f50cb506c /lldb/source/Core/FileSpec.cpp
parent32b3de519d1079a00cd688fd4ecabd1d1335760b (diff)
downloadbcm5719-llvm-391a9603a098d0f892135362650c72487b178d61.tar.gz
bcm5719-llvm-391a9603a098d0f892135362650c72487b178d61.zip
Remove Host::ResolveExecutableLocation (very recent addition); replace use of
it with llvm::sys::Program::FindProgramByName. llvm-svn: 113709
Diffstat (limited to 'lldb/source/Core/FileSpec.cpp')
-rw-r--r--lldb/source/Core/FileSpec.cpp34
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
OpenPOWER on IntegriCloud