summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-03-07 13:19:15 +0000
committerPavel Labath <labath@google.com>2017-03-07 13:19:15 +0000
commit30e6cbfcfca4836c2b3497d84ffc2043b548b2a6 (patch)
tree3b24106c96c514a5490b04bfe541e2e6a2ac5518 /lldb/source/Core
parent3d0af578ccc071dc1f9fc1672af55a969e0beb5a (diff)
downloadbcm5719-llvm-30e6cbfcfca4836c2b3497d84ffc2043b548b2a6.tar.gz
bcm5719-llvm-30e6cbfcfca4836c2b3497d84ffc2043b548b2a6.zip
Revert "Use LLVM for all stat-related functionality."
this reverts r297116 because it breaks the unittests and TestCompDirSymlink. The ModuleCache unit test is trivially fixable, but the CompDirSymlink failure is a symptom of a deeper problem: llvm's stat functionality is not a drop-in replacement for lldb's. The former is based on stat(2) (which does symlink resolution), while the latter is based on lstat(2) (which does not). This also reverts subsequent build fixes (r297128, r297120, 297117) and r297119 (Remove FileSpec dependency on FileSystem) which builds on top of this. llvm-svn: 297139
Diffstat (limited to 'lldb/source/Core')
-rw-r--r--lldb/source/Core/Debugger.cpp14
-rw-r--r--lldb/source/Core/FileSpecList.cpp44
-rw-r--r--lldb/source/Core/Module.cpp3
-rw-r--r--lldb/source/Core/ModuleList.cpp4
-rw-r--r--lldb/source/Core/PluginManager.cpp13
5 files changed, 42 insertions, 36 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 8af2bad2255..7d4f94af68a 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -557,7 +557,7 @@ bool Debugger::LoadPlugin(const FileSpec &spec, Error &error) {
}
static FileSpec::EnumerateDirectoryResult
-LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
+LoadPluginCallback(void *baton, FileSpec::FileType file_type,
const FileSpec &file_spec) {
Error error;
@@ -569,13 +569,13 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
Debugger *debugger = (Debugger *)baton;
- namespace fs = llvm::sys::fs;
// If we have a regular file, a symbolic link or unknown file type, try
// and process the file. We must handle unknown as sometimes the directory
// enumeration might be enumerating a file system that doesn't have correct
// file type information.
- if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
- ft == fs::file_type::type_unknown) {
+ if (file_type == FileSpec::eFileTypeRegular ||
+ file_type == FileSpec::eFileTypeSymbolicLink ||
+ file_type == FileSpec::eFileTypeUnknown) {
FileSpec plugin_file_spec(file_spec);
plugin_file_spec.ResolvePath();
@@ -588,9 +588,9 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
debugger->LoadPlugin(plugin_file_spec, plugin_load_error);
return FileSpec::eEnumerateDirectoryResultNext;
- } else if (ft == fs::file_type::directory_file ||
- ft == fs::file_type::symlink_file ||
- ft == fs::file_type::type_unknown) {
+ } else if (file_type == FileSpec::eFileTypeUnknown ||
+ file_type == FileSpec::eFileTypeDirectory ||
+ file_type == FileSpec::eFileTypeSymbolicLink) {
// Try and recurse into anything that a directory or symbolic link.
// We must also do this for unknown as sometimes the directory enumeration
// might be enumerating a file system that doesn't have correct file type
diff --git a/lldb/source/Core/FileSpecList.cpp b/lldb/source/Core/FileSpecList.cpp
index 828aef9c6cd..2f2713af336 100644
--- a/lldb/source/Core/FileSpecList.cpp
+++ b/lldb/source/Core/FileSpecList.cpp
@@ -16,7 +16,6 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Utility/Stream.h"
-#include "llvm/Support/FileSystem.h"
using namespace lldb_private;
using namespace std;
@@ -151,23 +150,32 @@ size_t FileSpecList::GetFilesMatchingPartialPath(const char *path,
FileSpecList &matches) {
#if 0 // FIXME: Just sketching...
matches.Clear();
- using namespace llvm::sys::fs;
- file_status stats;
- if (status(path, stats))
- return 0;
- if (exists(stats)) {
- if (stats.type() == file_type::symlink_file) {
- // Shouldn't there be a method that realpath's a file?
- }
- if (is_regular_file(stats) || (is_directory(stats) && dir_okay)) {
- matches.Append(FileSpec(path));
- return 1;
- } else if (is_directory(stats)) {
- // Fill the match list with all the files in the directory:
- } else {
- return 0;
- }
- } else {
+ FileSpec path_spec = FileSpec (path);
+ if (path_spec.Exists ())
+ {
+ FileSpec::FileType type = path_spec.GetFileType();
+ if (type == FileSpec::eFileTypeSymbolicLink)
+ // Shouldn't there be a Resolve on a file spec that real-path's it?
+ {
+ }
+
+ if (type == FileSpec::eFileTypeRegular
+ || (type == FileSpec::eFileTypeDirectory && dir_okay))
+ {
+ matches.Append (path_spec);
+ return 1;
+ }
+ else if (type == FileSpec::eFileTypeDirectory)
+ {
+ // Fill the match list with all the files in the directory:
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ else
+ {
ConstString dir_name = path_spec.GetDirectory();
ConstString file_name = GetFilename();
if (dir_name == nullptr)
diff --git a/lldb/source/Core/Module.cpp b/lldb/source/Core/Module.cpp
index d2034d6518d..c8afb61e37b 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -12,7 +12,6 @@
// C Includes
// C++ Includes
// Other libraries and framework includes
-#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Signals.h"
#include "llvm/Support/raw_os_ostream.h"
@@ -1440,7 +1439,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
// ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
// check this
- if (llvm::sys::fs::is_directory(file.GetPath())) {
+ if (file.IsDirectory()) {
std::string new_path(file.GetPath());
std::string old_path(obj_file->GetFileSpec().GetPath());
if (old_path.find(new_path) == 0) {
diff --git a/lldb/source/Core/ModuleList.cpp b/lldb/source/Core/ModuleList.cpp
index 0262185eed0..8ec3047dce8 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -26,7 +26,6 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Utility/Log.h"
-#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Threading.h"
using namespace lldb;
@@ -767,8 +766,7 @@ Error ModuleList::GetSharedModule(const ModuleSpec &module_spec,
auto search_path_spec = module_search_paths_ptr->GetFileSpecAtIndex(idx);
if (!search_path_spec.ResolvePath())
continue;
- namespace fs = llvm::sys::fs;
- if (!fs::is_directory(search_path_spec.GetPath()))
+ if (!search_path_spec.Exists() || !search_path_spec.IsDirectory())
continue;
search_path_spec.AppendPathComponent(
module_spec.GetFileSpec().GetFilename().AsCString());
diff --git a/lldb/source/Core/PluginManager.cpp b/lldb/source/Core/PluginManager.cpp
index 136d722e9bc..71a0f6eccea 100644
--- a/lldb/source/Core/PluginManager.cpp
+++ b/lldb/source/Core/PluginManager.cpp
@@ -79,18 +79,18 @@ template <typename FPtrTy> static FPtrTy CastToFPtr(void *VPtr) {
}
static FileSpec::EnumerateDirectoryResult
-LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
+LoadPluginCallback(void *baton, FileSpec::FileType file_type,
const FileSpec &file_spec) {
// PluginManager *plugin_manager = (PluginManager *)baton;
Error error;
- namespace fs = llvm::sys::fs;
// If we have a regular file, a symbolic link or unknown file type, try
// and process the file. We must handle unknown as sometimes the directory
// enumeration might be enumerating a file system that doesn't have correct
// file type information.
- if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
- ft == fs::file_type::type_unknown) {
+ if (file_type == FileSpec::eFileTypeRegular ||
+ file_type == FileSpec::eFileTypeSymbolicLink ||
+ file_type == FileSpec::eFileTypeUnknown) {
FileSpec plugin_file_spec(file_spec);
plugin_file_spec.ResolvePath();
@@ -135,8 +135,9 @@ LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
}
}
- if (ft == fs::file_type::directory_file ||
- ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
+ if (file_type == FileSpec::eFileTypeUnknown ||
+ file_type == FileSpec::eFileTypeDirectory ||
+ file_type == FileSpec::eFileTypeSymbolicLink) {
// Try and recurse into anything that a directory or symbolic link.
// We must also do this for unknown as sometimes the directory enumeration
// might be enumerating a file system that doesn't have correct file type
OpenPOWER on IntegriCloud