summaryrefslogtreecommitdiffstats
path: root/lldb/source/Core
diff options
context:
space:
mode:
authorZachary Turner <zturner@google.com>2017-03-08 17:56:08 +0000
committerZachary Turner <zturner@google.com>2017-03-08 17:56:08 +0000
commit7d86ee5ab0ca98edff2f07c373967f34227c960e (patch)
tree622b630eca7be4ea6b604c8eacc956031dbb8ee9 /lldb/source/Core
parent5c13623a69baed43b7f0cbf2912a3baa951285e2 (diff)
downloadbcm5719-llvm-7d86ee5ab0ca98edff2f07c373967f34227c960e.tar.gz
bcm5719-llvm-7d86ee5ab0ca98edff2f07c373967f34227c960e.zip
Resubmit FileSystem changes.
This was originall reverted due to some test failures in ModuleCache and TestCompDirSymlink. These issues have all been resolved and the code now passes all tests. Differential Revision: https://reviews.llvm.org/D30698 llvm-svn: 297300
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, 36 insertions, 42 deletions
diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 7d4f94af68a..8af2bad2255 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, FileSpec::FileType file_type,
+LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
const FileSpec &file_spec) {
Error error;
@@ -569,13 +569,13 @@ LoadPluginCallback(void *baton, FileSpec::FileType file_type,
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 (file_type == FileSpec::eFileTypeRegular ||
- file_type == FileSpec::eFileTypeSymbolicLink ||
- file_type == FileSpec::eFileTypeUnknown) {
+ if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
+ ft == fs::file_type::type_unknown) {
FileSpec plugin_file_spec(file_spec);
plugin_file_spec.ResolvePath();
@@ -588,9 +588,9 @@ LoadPluginCallback(void *baton, FileSpec::FileType file_type,
debugger->LoadPlugin(plugin_file_spec, plugin_load_error);
return FileSpec::eEnumerateDirectoryResultNext;
- } else if (file_type == FileSpec::eFileTypeUnknown ||
- file_type == FileSpec::eFileTypeDirectory ||
- file_type == FileSpec::eFileTypeSymbolicLink) {
+ } else if (ft == fs::file_type::directory_file ||
+ ft == fs::file_type::symlink_file ||
+ ft == fs::file_type::type_unknown) {
// 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 2f2713af336..0f790279897 100644
--- a/lldb/source/Core/FileSpecList.cpp
+++ b/lldb/source/Core/FileSpecList.cpp
@@ -16,6 +16,7 @@
// Other libraries and framework includes
// Project includes
#include "lldb/Utility/Stream.h"
+#include "llvm/Support/FileSystem.h"
using namespace lldb_private;
using namespace std;
@@ -150,32 +151,23 @@ size_t FileSpecList::GetFilesMatchingPartialPath(const char *path,
FileSpecList &matches) {
#if 0 // FIXME: Just sketching...
matches.Clear();
- 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
- {
+ using namespace llvm::sys::fs;
+ file_status stats;
+ if (status(path, stats, false))
+ return 0;
+ if (exists(stats)) {
+ if (is_symlink_file(stats)) {
+ // 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 {
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 c8afb61e37b..d2034d6518d 100644
--- a/lldb/source/Core/Module.cpp
+++ b/lldb/source/Core/Module.cpp
@@ -12,6 +12,7 @@
// 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"
@@ -1439,7 +1440,7 @@ void Module::SetSymbolFileFileSpec(const FileSpec &file) {
// ("/tmp/a.out.dSYM/Contents/Resources/DWARF/a.out"). So we need to
// check this
- if (file.IsDirectory()) {
+ if (llvm::sys::fs::is_directory(file.GetPath())) {
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 8ec3047dce8..0262185eed0 100644
--- a/lldb/source/Core/ModuleList.cpp
+++ b/lldb/source/Core/ModuleList.cpp
@@ -26,6 +26,7 @@
#include "lldb/Symbol/VariableList.h"
#include "lldb/Utility/Log.h"
+#include "llvm/Support/FileSystem.h"
#include "llvm/Support/Threading.h"
using namespace lldb;
@@ -766,7 +767,8 @@ Error ModuleList::GetSharedModule(const ModuleSpec &module_spec,
auto search_path_spec = module_search_paths_ptr->GetFileSpecAtIndex(idx);
if (!search_path_spec.ResolvePath())
continue;
- if (!search_path_spec.Exists() || !search_path_spec.IsDirectory())
+ namespace fs = llvm::sys::fs;
+ if (!fs::is_directory(search_path_spec.GetPath()))
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 71a0f6eccea..136d722e9bc 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, FileSpec::FileType file_type,
+LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft,
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 (file_type == FileSpec::eFileTypeRegular ||
- file_type == FileSpec::eFileTypeSymbolicLink ||
- file_type == FileSpec::eFileTypeUnknown) {
+ if (ft == fs::file_type::regular_file || ft == fs::file_type::symlink_file ||
+ ft == fs::file_type::type_unknown) {
FileSpec plugin_file_spec(file_spec);
plugin_file_spec.ResolvePath();
@@ -135,9 +135,8 @@ LoadPluginCallback(void *baton, FileSpec::FileType file_type,
}
}
- if (file_type == FileSpec::eFileTypeUnknown ||
- file_type == FileSpec::eFileTypeDirectory ||
- file_type == FileSpec::eFileTypeSymbolicLink) {
+ if (ft == fs::file_type::directory_file ||
+ ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) {
// 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