Index: include/lldb/Breakpoint/BreakpointResolver.h =================================================================== --- include/lldb/Breakpoint/BreakpointResolver.h +++ include/lldb/Breakpoint/BreakpointResolver.h @@ -17,8 +17,8 @@ #include "lldb/Breakpoint/Breakpoint.h" #include "lldb/Core/Address.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/lldb-private.h" Index: include/lldb/Core/AddressResolverFileLine.h =================================================================== --- include/lldb/Core/AddressResolverFileLine.h +++ include/lldb/Core/AddressResolverFileLine.h @@ -12,7 +12,7 @@ #include "lldb/Core/AddressResolver.h" #include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::CallbackR... -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN #include // for uint32_t Index: include/lldb/Core/Debugger.h =================================================================== --- include/lldb/Core/Debugger.h +++ include/lldb/Core/Debugger.h @@ -24,13 +24,13 @@ #include "lldb/Core/IOHandler.h" #include "lldb/Core/SourceManager.h" #include "lldb/Core/UserSettingsController.h" +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Host/HostThread.h" #include "lldb/Host/Terminal.h" #include "lldb/Target/ExecutionContext.h" // for ExecutionContext #include "lldb/Target/Platform.h" #include "lldb/Target/TargetList.h" #include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/Utility/Status.h" // for Status #include "lldb/Utility/UserID.h" #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN Index: include/lldb/Core/Disassembler.h =================================================================== --- include/lldb/Core/Disassembler.h +++ include/lldb/Core/Disassembler.h @@ -15,16 +15,16 @@ #include "lldb/Core/FormatEntity.h" // for FormatEntity #include "lldb/Core/Opcode.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Interpreter/OptionValue.h" #include "lldb/Symbol/LineEntry.h" #include "lldb/Target/ExecutionContext.h" // for ExecutionContext #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/FileSpec.h" -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN -#include "lldb/lldb-forward.h" // for InstructionSP, DisassemblerSP +#include "lldb/Utility/ConstString.h" // for ConstString +#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-forward.h" // for InstructionSP, DisassemblerSP #include "lldb/lldb-private-enumerations.h" // for AddressClass -#include "lldb/lldb-types.h" // for addr_t, offset_t +#include "lldb/lldb-types.h" // for addr_t, offset_t #include "llvm/ADT/StringRef.h" // for StringRef Index: include/lldb/Core/FileLineResolver.h =================================================================== --- include/lldb/Core/FileLineResolver.h +++ include/lldb/Core/FileLineResolver.h @@ -11,9 +11,9 @@ #define liblldb_FileLineResolver_h_ #include "lldb/Core/SearchFilter.h" // for Searcher, Searcher::CallbackR... +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Symbol/SymbolContext.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN +#include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN #include // for uint32_t, UINT32_MAX Index: include/lldb/Core/FileSpecList.h =================================================================== --- include/lldb/Core/FileSpecList.h +++ include/lldb/Core/FileSpecList.h @@ -11,7 +11,7 @@ #define liblldb_FileSpecList_h_ #if defined(__cplusplus) -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include Index: include/lldb/Core/FormatEntity.h =================================================================== --- include/lldb/Core/FormatEntity.h +++ include/lldb/Core/FormatEntity.h @@ -10,8 +10,8 @@ #ifndef liblldb_FormatEntity_h_ #define liblldb_FormatEntity_h_ +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Utility/CompletionRequest.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/Utility/Status.h" #include "lldb/lldb-enumerations.h" // for Format::eFormatDefault, Format #include "lldb/lldb-types.h" // for addr_t Index: include/lldb/Core/Module.h =================================================================== --- include/lldb/Core/Module.h +++ include/lldb/Core/Module.h @@ -12,14 +12,14 @@ #include "lldb/Core/Address.h" // for Address #include "lldb/Core/ModuleSpec.h" // for ModuleSpec +#include "lldb/Host/FileSpec.h" #include "lldb/Symbol/ObjectFile.h" // for ObjectFile #include "lldb/Symbol/SymbolContextScope.h" #include "lldb/Symbol/TypeSystem.h" #include "lldb/Target/PathMappingList.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/FileSpec.h" -#include "lldb/Utility/Status.h" // for Status +#include "lldb/Utility/Status.h" // for Status #include "lldb/Utility/UUID.h" #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN #include "lldb/lldb-enumerations.h" // for LanguageType, SymbolType Index: include/lldb/Core/ModuleList.h =================================================================== --- include/lldb/Core/ModuleList.h +++ include/lldb/Core/ModuleList.h @@ -13,7 +13,7 @@ #include "lldb/Core/Address.h" // for Address #include "lldb/Core/ModuleSpec.h" // for ModuleSpec #include "lldb/Core/UserSettingsController.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Utility/Iterable.h" #include "lldb/Utility/Status.h" // for Status #include "lldb/lldb-enumerations.h" Index: include/lldb/Core/ModuleSpec.h =================================================================== --- include/lldb/Core/ModuleSpec.h +++ include/lldb/Core/ModuleSpec.h @@ -11,9 +11,9 @@ #define liblldb_ModuleSpec_h_ // Project includes +#include "lldb/Host/FileSpec.h" #include "lldb/Target/PathMappingList.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/UUID.h" Index: include/lldb/Core/PluginManager.h =================================================================== --- include/lldb/Core/PluginManager.h +++ include/lldb/Core/PluginManager.h @@ -11,7 +11,7 @@ #define liblldb_PluginManager_h_ #include "lldb/Core/Architecture.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/Status.h" // for Status #include "lldb/lldb-enumerations.h" // for ScriptLanguage #include "lldb/lldb-forward.h" // for OptionValuePropertiesSP Index: include/lldb/Core/SearchFilter.h =================================================================== --- include/lldb/Core/SearchFilter.h +++ include/lldb/Core/SearchFilter.h @@ -13,7 +13,7 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Utility/StructuredData.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/lldb-forward.h" // for SearchFilterSP, TargetSP, Modu... #include // for uint32_t Index: include/lldb/Core/SourceManager.h =================================================================== --- include/lldb/Core/SourceManager.h +++ include/lldb/Core/SourceManager.h @@ -10,7 +10,7 @@ #ifndef liblldb_SourceManager_h_ #define liblldb_SourceManager_h_ -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/lldb-defines.h" // for DISALLOW_COPY_AND_ASSIGN #include "lldb/lldb-forward.h" // for DebuggerSP, DebuggerWP, DataBufferSP Index: include/lldb/Host/Editline.h =================================================================== --- include/lldb/Host/Editline.h +++ include/lldb/Host/Editline.h @@ -54,7 +54,7 @@ #include #include "lldb/Host/ConnectionFileDescriptor.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/Predicate.h" namespace lldb_private { Index: include/lldb/Host/FileCache.h =================================================================== --- include/lldb/Host/FileCache.h +++ include/lldb/Host/FileCache.h @@ -15,7 +15,7 @@ #include "lldb/lldb-forward.h" #include "lldb/lldb-types.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/Status.h" namespace lldb_private { Index: include/lldb/Host/FileSystem.h =================================================================== --- include/lldb/Host/FileSystem.h +++ include/lldb/Host/FileSystem.h @@ -10,9 +10,11 @@ #ifndef liblldb_Host_FileSystem_h #define liblldb_Host_FileSystem_h -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/Status.h" + #include "llvm/Support/Chrono.h" +#include "llvm/Support/VirtualFileSystem.h" #include "lldb/lldb-types.h" @@ -26,6 +28,12 @@ static const char *DEV_NULL; static const char *PATH_CONVERSION_ERROR; + FileSystem() : m_fs(llvm::vfs::getRealFileSystem()) {} + + static FileSystem &Instance(); + + void ChangeFileSystem(llvm::IntrusiveRefCntPtr fs); + static Status Symlink(const FileSpec &src, const FileSpec &dst); static Status Readlink(const FileSpec &src, FileSpec &dst); @@ -35,8 +43,67 @@ /// manipulated and closed with the normal ::fread, ::fclose, etc. functions. static FILE *Fopen(const char *path, const char *mode); - static llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec); + /// Returns the modification time of the given file. + /// @{ + llvm::sys::TimePoint<> GetModificationTime(const FileSpec &file_spec) const; + llvm::sys::TimePoint<> GetModificationTime(const llvm::Twine &path) const; + /// @} + + /// Returns the on-disk size of the given file in bytes. + /// @{ + uint64_t GetByteSize(const FileSpec &file_spec) const; + uint64_t GetByteSize(const llvm::Twine &path) const; + /// @} + + /// Return the current permissions of the given file. + /// + /// Returns a bitmask for the current permissions of the file (zero or more + /// of the permission bits defined in File::Permissions). + /// @{ + uint32_t GetPermissions(const FileSpec &file_spec) const; + uint32_t GetPermissions(const llvm::Twine &path) const; + /// @} + + /// Returns whether the given file exists. + /// @{ + bool Exists(const FileSpec &file_spec) const; + bool Exists(const llvm::Twine &path) const; + /// @} + + /// Make the given file path absolute. + /// @{ + std::error_code MakeAbsolute(llvm::SmallVectorImpl &path) const; + std::error_code MakeAbsolute(FileSpec &file_spec) const; + /// @} + + enum EnumerateDirectoryResult { + /// Enumerate next entry in the current directory. + eEnumerateDirectoryResultNext, + /// Recurse into the current entry if it is a directory or symlink, or next + /// if not. + eEnumerateDirectoryResultEnter, + /// Stop directory enumerations at any level. + eEnumerateDirectoryResultQuit + }; + + typedef EnumerateDirectoryResult (*EnumerateDirectoryCallbackType)( + void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef); + + typedef std::function + DirectoryCallback; + + void EnumerateDirectory(llvm::Twine path, bool find_directories, + bool find_files, bool find_other, + EnumerateDirectoryCallbackType callback, + void *callback_baton); + + std::error_code GetRealPath(const llvm::Twine &path, + llvm::SmallVectorImpl &output) const; + +private: + llvm::IntrusiveRefCntPtr m_fs; }; -} +} // namespace lldb_private #endif Index: include/lldb/Host/Host.h =================================================================== --- include/lldb/Host/Host.h +++ include/lldb/Host/Host.h @@ -11,9 +11,9 @@ #define LLDB_HOST_HOST_H #include "lldb/Host/File.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostThread.h" #include "lldb/Utility/Environment.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Timeout.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-private.h" Index: include/lldb/Host/HostInfoBase.h =================================================================== --- include/lldb/Host/HostInfoBase.h +++ include/lldb/Host/HostInfoBase.h @@ -10,8 +10,8 @@ #ifndef lldb_Host_HostInfoBase_h_ #define lldb_Host_HostInfoBase_h_ +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/lldb-enumerations.h" #include "llvm/ADT/StringRef.h" Index: include/lldb/Host/Symbols.h =================================================================== --- include/lldb/Host/Symbols.h +++ include/lldb/Host/Symbols.h @@ -16,7 +16,7 @@ // C++ Includes // Other libraries and framework includes // Project includes -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" namespace lldb_private { Index: include/lldb/Host/freebsd/HostInfoFreeBSD.h =================================================================== --- include/lldb/Host/freebsd/HostInfoFreeBSD.h +++ include/lldb/Host/freebsd/HostInfoFreeBSD.h @@ -10,8 +10,8 @@ #ifndef lldb_Host_freebsd_HostInfoFreeBSD_h_ #define lldb_Host_freebsd_HostInfoFreeBSD_h_ +#include "lldb/Host/FileSpec.h" #include "lldb/Host/posix/HostInfoPosix.h" -#include "lldb/Utility/FileSpec.h" #include "llvm/Support/VersionTuple.h" namespace lldb_private { Index: include/lldb/Host/linux/HostInfoLinux.h =================================================================== --- include/lldb/Host/linux/HostInfoLinux.h +++ include/lldb/Host/linux/HostInfoLinux.h @@ -10,8 +10,8 @@ #ifndef lldb_Host_linux_HostInfoLinux_h_ #define lldb_Host_linux_HostInfoLinux_h_ +#include "lldb/Host/FileSpec.h" #include "lldb/Host/posix/HostInfoPosix.h" -#include "lldb/Utility/FileSpec.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/VersionTuple.h" Index: include/lldb/Host/macosx/HostInfoMacOSX.h =================================================================== --- include/lldb/Host/macosx/HostInfoMacOSX.h +++ include/lldb/Host/macosx/HostInfoMacOSX.h @@ -10,8 +10,8 @@ #ifndef lldb_Host_macosx_HostInfoMacOSX_h_ #define lldb_Host_macosx_HostInfoMacOSX_h_ +#include "lldb/Host/FileSpec.h" #include "lldb/Host/posix/HostInfoPosix.h" -#include "lldb/Utility/FileSpec.h" #include "llvm/Support/VersionTuple.h" namespace lldb_private { Index: include/lldb/Host/netbsd/HostInfoNetBSD.h =================================================================== --- include/lldb/Host/netbsd/HostInfoNetBSD.h +++ include/lldb/Host/netbsd/HostInfoNetBSD.h @@ -10,8 +10,8 @@ #ifndef lldb_Host_netbsd_HostInfoNetBSD_h_ #define lldb_Host_netbsd_HostInfoNetBSD_h_ +#include "lldb/Host/FileSpec.h" #include "lldb/Host/posix/HostInfoPosix.h" -#include "lldb/Utility/FileSpec.h" #include "llvm/Support/VersionTuple.h" namespace lldb_private { Index: include/lldb/Host/openbsd/HostInfoOpenBSD.h =================================================================== --- include/lldb/Host/openbsd/HostInfoOpenBSD.h +++ include/lldb/Host/openbsd/HostInfoOpenBSD.h @@ -10,8 +10,8 @@ #ifndef lldb_Host_openbsd_HostInfoOpenBSD_h_ #define lldb_Host_openbsd_HostInfoOpenBSD_h_ +#include "lldb/Host/FileSpec.h" #include "lldb/Host/posix/HostInfoPosix.h" -#include "lldb/Utility/FileSpec.h" namespace lldb_private { Index: include/lldb/Host/posix/HostInfoPosix.h =================================================================== --- include/lldb/Host/posix/HostInfoPosix.h +++ include/lldb/Host/posix/HostInfoPosix.h @@ -10,8 +10,8 @@ #ifndef lldb_Host_posix_HostInfoPosix_h_ #define lldb_Host_posix_HostInfoPosix_h_ +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfoBase.h" -#include "lldb/Utility/FileSpec.h" namespace lldb_private { Index: include/lldb/Host/windows/HostInfoWindows.h =================================================================== --- include/lldb/Host/windows/HostInfoWindows.h +++ include/lldb/Host/windows/HostInfoWindows.h @@ -10,8 +10,8 @@ #ifndef lldb_Host_windows_HostInfoWindows_h_ #define lldb_Host_windows_HostInfoWindows_h_ +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfoBase.h" -#include "lldb/Utility/FileSpec.h" #include "llvm/Support/VersionTuple.h" namespace lldb_private { Index: include/lldb/Interpreter/OptionValueFileSpec.h =================================================================== --- include/lldb/Interpreter/OptionValueFileSpec.h +++ include/lldb/Interpreter/OptionValueFileSpec.h @@ -12,7 +12,7 @@ #include "lldb/Interpreter/OptionValue.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/Support/Chrono.h" namespace lldb_private { Index: include/lldb/Symbol/Declaration.h =================================================================== --- include/lldb/Symbol/Declaration.h +++ include/lldb/Symbol/Declaration.h @@ -10,7 +10,7 @@ #ifndef liblldb_Declaration_h_ #define liblldb_Declaration_h_ -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/lldb-private.h" namespace lldb_private { Index: include/lldb/Symbol/LineEntry.h =================================================================== --- include/lldb/Symbol/LineEntry.h +++ include/lldb/Symbol/LineEntry.h @@ -11,7 +11,7 @@ #define liblldb_LineEntry_h_ #include "lldb/Core/AddressRange.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/lldb-private.h" namespace lldb_private { Index: include/lldb/Symbol/ObjectContainer.h =================================================================== --- include/lldb/Symbol/ObjectContainer.h +++ include/lldb/Symbol/ObjectContainer.h @@ -16,9 +16,9 @@ // Project includes #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/lldb-private.h" namespace lldb_private { Index: include/lldb/Symbol/ObjectFile.h =================================================================== --- include/lldb/Symbol/ObjectFile.h +++ include/lldb/Symbol/ObjectFile.h @@ -13,11 +13,11 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Core/ModuleChild.h" #include "lldb/Core/PluginInterface.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Symbol/Symtab.h" #include "lldb/Symbol/UnwindTable.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/UUID.h" #include "lldb/lldb-private.h" #include "llvm/Support/VersionTuple.h" Index: include/lldb/Target/DynamicLoader.h =================================================================== --- include/lldb/Target/DynamicLoader.h +++ include/lldb/Target/DynamicLoader.h @@ -12,7 +12,7 @@ // Project includes #include "lldb/Core/PluginInterface.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Utility/Status.h" #include "lldb/Utility/UUID.h" #include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS Index: include/lldb/Target/FileAction.h =================================================================== --- include/lldb/Target/FileAction.h +++ include/lldb/Target/FileAction.h @@ -10,7 +10,7 @@ #ifndef liblldb_Target_FileAction_h #define liblldb_Target_FileAction_h -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include namespace lldb_private { Index: include/lldb/Target/ModuleCache.h =================================================================== --- include/lldb/Target/ModuleCache.h +++ include/lldb/Target/ModuleCache.h @@ -14,7 +14,7 @@ #include "lldb/lldb-types.h" #include "lldb/Host/File.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/Status.h" #include Index: include/lldb/Target/Platform.h =================================================================== --- include/lldb/Target/Platform.h +++ include/lldb/Target/Platform.h @@ -23,10 +23,10 @@ // Project includes #include "lldb/Core/PluginInterface.h" #include "lldb/Core/UserSettingsController.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Interpreter/Options.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Timeout.h" #include "lldb/lldb-private-forward.h" #include "lldb/lldb-public.h" Index: include/lldb/Target/ProcessInfo.h =================================================================== --- include/lldb/Target/ProcessInfo.h +++ include/lldb/Target/ProcessInfo.h @@ -11,10 +11,10 @@ #define liblldb_ProcessInfo_h_ // LLDB headers +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/Environment.h" -#include "lldb/Utility/FileSpec.h" namespace lldb_private { //---------------------------------------------------------------------- Index: include/lldb/Target/ProcessLaunchInfo.h =================================================================== --- include/lldb/Target/ProcessLaunchInfo.h +++ include/lldb/Target/ProcessLaunchInfo.h @@ -16,11 +16,11 @@ // LLDB Headers #include "lldb/Utility/Flags.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/PseudoTerminal.h" #include "lldb/Target/FileAction.h" #include "lldb/Target/ProcessInfo.h" -#include "lldb/Utility/FileSpec.h" namespace lldb_private { Index: include/lldb/Utility/Args.h =================================================================== --- include/lldb/Utility/Args.h +++ include/lldb/Utility/Args.h @@ -10,6 +10,7 @@ #ifndef LLDB_UTILITY_ARGS_H #define LLDB_UTILITY_ARGS_H +#include "lldb/Utility/ConstString.h" #include "lldb/Utility/Environment.h" #include "lldb/lldb-private-types.h" #include "lldb/lldb-types.h" @@ -329,7 +330,7 @@ static uint32_t StringToGenericRegister(llvm::StringRef s); - static const char *GetShellSafeArgument(const FileSpec &shell, + static const char *GetShellSafeArgument(ConstString shell, const char *unsafe_arg, std::string &safe_arg); Index: include/lldb/Utility/StructuredData.h =================================================================== --- include/lldb/Utility/StructuredData.h +++ include/lldb/Utility/StructuredData.h @@ -13,7 +13,6 @@ #include "llvm/ADT/StringRef.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/lldb-enumerations.h" // for StructuredDataType #include // for assert @@ -547,8 +546,6 @@ }; static ObjectSP ParseJSON(std::string json_text); - - static ObjectSP ParseJSONFromFile(const FileSpec &file, Status &error); }; } // namespace lldb_private Index: source/API/SBFileSpec.cpp =================================================================== --- source/API/SBFileSpec.cpp +++ source/API/SBFileSpec.cpp @@ -12,8 +12,8 @@ #include "lldb/API/SBFileSpec.h" #include "lldb/API/SBStream.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/PosixApi.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" Index: source/API/SBFileSpecList.cpp =================================================================== --- source/API/SBFileSpecList.cpp +++ source/API/SBFileSpecList.cpp @@ -13,8 +13,8 @@ #include "lldb/API/SBFileSpecList.h" #include "lldb/API/SBStream.h" #include "lldb/Core/FileSpecList.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/PosixApi.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Stream.h" Index: source/API/SBHostOS.cpp =================================================================== --- source/API/SBHostOS.cpp +++ source/API/SBHostOS.cpp @@ -11,14 +11,14 @@ #include "Plugins/ScriptInterpreter/Python/lldb-python.h" #endif -#include "lldb/API/SBHostOS.h" #include "lldb/API/SBError.h" +#include "lldb/API/SBHostOS.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostNativeThread.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "Plugins/ExpressionParser/Clang/ClangHost.h" Index: source/API/SBTarget.cpp =================================================================== --- source/API/SBTarget.cpp +++ source/API/SBTarget.cpp @@ -43,6 +43,7 @@ #include "lldb/Core/ValueObjectConstResult.h" #include "lldb/Core/ValueObjectList.h" #include "lldb/Core/ValueObjectVariable.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/DeclVendor.h" @@ -60,7 +61,6 @@ #include "lldb/Target/TargetList.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/Args.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" Index: source/Commands/CommandCompletions.cpp =================================================================== --- source/Commands/CommandCompletions.cpp +++ source/Commands/CommandCompletions.cpp @@ -22,6 +22,7 @@ #include "lldb/Core/FileSpecList.h" #include "lldb/Core/Module.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -30,7 +31,6 @@ #include "lldb/Symbol/Variable.h" #include "lldb/Target/Target.h" #include "lldb/Utility/Args.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/TildeExpressionResolver.h" Index: source/Commands/CommandObjectLog.cpp =================================================================== --- source/Commands/CommandObjectLog.cpp +++ source/Commands/CommandObjectLog.cpp @@ -15,6 +15,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Interpreter/CommandReturnObject.h" @@ -27,7 +28,6 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/Args.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" Index: source/Commands/CommandObjectSource.cpp =================================================================== --- source/Commands/CommandObjectSource.cpp +++ source/Commands/CommandObjectSource.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/SourceManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/OptionParser.h" #include "lldb/Interpreter/CommandCompletions.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -31,7 +32,6 @@ #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/StackFrame.h" #include "lldb/Target/TargetList.h" -#include "lldb/Utility/FileSpec.h" using namespace lldb; using namespace lldb_private; Index: source/Core/Address.cpp =================================================================== --- source/Core/Address.cpp +++ source/Core/Address.cpp @@ -12,6 +12,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleList.h" // for ModuleList #include "lldb/Core/Section.h" +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Symbol/Block.h" #include "lldb/Symbol/Declaration.h" // for Declaration #include "lldb/Symbol/LineEntry.h" // for LineEntry @@ -31,7 +32,6 @@ #include "lldb/Utility/ConstString.h" // for ConstString #include "lldb/Utility/DataExtractor.h" // for DataExtractor #include "lldb/Utility/Endian.h" // for InlHostByteOrder -#include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/Utility/Status.h" // for Status #include "lldb/Utility/Stream.h" // for Stream #include "lldb/Utility/StreamString.h" // for StreamString Index: source/Core/AddressRange.cpp =================================================================== --- source/Core/AddressRange.cpp +++ source/Core/AddressRange.cpp @@ -9,9 +9,9 @@ #include "lldb/Core/AddressRange.h" #include "lldb/Core/Module.h" +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Target/Target.h" #include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/FileSpec.h" // for FileSpec #include "lldb/Utility/Stream.h" #include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS Index: source/Core/Debugger.cpp =================================================================== --- source/Core/Debugger.cpp +++ source/Core/Debugger.cpp @@ -21,6 +21,7 @@ #include "lldb/DataFormatters/DataVisualization.h" #include "lldb/Expression/REPL.h" #include "lldb/Host/File.h" // for File, File::kInv... +#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/Terminal.h" #include "lldb/Host/ThreadLauncher.h" @@ -604,16 +605,16 @@ return false; } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { Status error; static ConstString g_dylibext(".dylib"); static ConstString g_solibext(".so"); if (!baton) - return FileSpec::eEnumerateDirectoryResultQuit; + return FileSystem::eEnumerateDirectoryResultQuit; Debugger *debugger = (Debugger *)baton; @@ -624,18 +625,18 @@ // file type information. 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); + FileSpec plugin_file_spec(path, false); plugin_file_spec.ResolvePath(); if (plugin_file_spec.GetFileNameExtension() != g_dylibext && plugin_file_spec.GetFileNameExtension() != g_solibext) { - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } Status plugin_load_error; debugger->LoadPlugin(plugin_file_spec, plugin_load_error); - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } else if (ft == fs::file_type::directory_file || ft == fs::file_type::symlink_file || ft == fs::file_type::type_unknown) { @@ -643,10 +644,10 @@ // also do this for unknown as sometimes the directory enumeration might be // enumerating a file system that doesn't have correct file type // information. - return FileSpec::eEnumerateDirectoryResultEnter; + return FileSystem::eEnumerateDirectoryResultEnter; } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } void Debugger::InstanceInitialize() { @@ -656,15 +657,17 @@ char dir_path[PATH_MAX]; if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) { if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) { - FileSpec::EnumerateDirectory(dir_path, find_directories, find_files, - find_other, LoadPluginCallback, this); + FileSystem::Instance().EnumerateDirectory(dir_path, find_directories, + find_files, find_other, + LoadPluginCallback, this); } } if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) { if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) { - FileSpec::EnumerateDirectory(dir_path, find_directories, find_files, - find_other, LoadPluginCallback, this); + FileSystem::Instance().EnumerateDirectory(dir_path, find_directories, + find_files, find_other, + LoadPluginCallback, this); } } Index: source/Core/FormatEntity.cpp =================================================================== --- source/Core/FormatEntity.cpp +++ source/Core/FormatEntity.cpp @@ -21,6 +21,7 @@ #include "lldb/DataFormatters/FormatManager.h" #include "lldb/DataFormatters/TypeSummary.h" // for TypeSummaryImpl::... #include "lldb/Expression/ExpressionVariable.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Interpreter/CommandInterpreter.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/CompileUnit.h" @@ -41,9 +42,8 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Utility/AnsiTerminal.h" -#include "lldb/Utility/ArchSpec.h" // for ArchSpec -#include "lldb/Utility/ConstString.h" // for ConstString, oper... -#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/ArchSpec.h" // for ArchSpec +#include "lldb/Utility/ConstString.h" // for ConstString, oper... #include "lldb/Utility/Log.h" // for Log #include "lldb/Utility/Logging.h" // for GetLogIfAllCatego... #include "lldb/Utility/RegisterValue.h" // for RegisterValue Index: source/Core/Module.cpp =================================================================== --- source/Core/Module.cpp +++ source/Core/Module.cpp @@ -171,10 +171,11 @@ } if (module_spec.GetFileSpec()) - m_mod_time = FileSystem::GetModificationTime(module_spec.GetFileSpec()); - else if (matching_module_spec.GetFileSpec()) m_mod_time = - FileSystem::GetModificationTime(matching_module_spec.GetFileSpec()); + FileSystem::Instance().GetModificationTime(module_spec.GetFileSpec()); + else if (matching_module_spec.GetFileSpec()) + m_mod_time = FileSystem::Instance().GetModificationTime( + matching_module_spec.GetFileSpec()); // Copy the architecture from the actual spec if we got one back, else use // the one that was specified @@ -219,8 +220,8 @@ Module::Module(const FileSpec &file_spec, const ArchSpec &arch, const ConstString *object_name, lldb::offset_t object_offset, const llvm::sys::TimePoint<> &object_mod_time) - : m_mod_time(FileSystem::GetModificationTime(file_spec)), m_arch(arch), - m_file(file_spec), m_object_offset(object_offset), + : m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), + m_arch(arch), m_file(file_spec), m_object_offset(object_offset), m_object_mod_time(object_mod_time), m_file_has_changed(false), m_first_file_changed_log(false) { // Scope for locker below... @@ -1064,7 +1065,7 @@ // Container objects whose paths do not specify a file directly can call this // function to correct the file and object names. m_file = file; - m_mod_time = FileSystem::GetModificationTime(file); + m_mod_time = FileSystem::Instance().GetModificationTime(file); m_object_name = object_name; } @@ -1127,7 +1128,7 @@ bool Module::FileHasChanged() const { if (!m_file_has_changed) m_file_has_changed = - (FileSystem::GetModificationTime(m_file) != m_mod_time); + (FileSystem::Instance().GetModificationTime(m_file) != m_mod_time); return m_file_has_changed; } Index: source/Core/ModuleList.cpp =================================================================== --- source/Core/ModuleList.cpp +++ source/Core/ModuleList.cpp @@ -950,7 +950,7 @@ // If we didn't have a UUID in mind when looking for the object file, // then we should make sure the modification time hasn't changed! if (platform_module_spec.GetUUIDPtr() == nullptr) { - auto file_spec_mod_time = FileSystem::GetModificationTime( + auto file_spec_mod_time = FileSystem::Instance().GetModificationTime( located_binary_modulespec.GetFileSpec()); if (file_spec_mod_time != llvm::sys::TimePoint<>()) { if (file_spec_mod_time != module_sp->GetModificationTime()) { Index: source/Core/PluginManager.cpp =================================================================== --- source/Core/PluginManager.cpp +++ source/Core/PluginManager.cpp @@ -10,10 +10,11 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/Debugger.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" #include "lldb/Interpreter/OptionValueProperties.h" #include "lldb/Utility/ConstString.h" // for ConstString -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StringList.h" // for StringList @@ -89,9 +90,9 @@ return reinterpret_cast(reinterpret_cast(VPtr)); } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult LoadPluginCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { // PluginManager *plugin_manager = (PluginManager *)baton; Status error; @@ -102,11 +103,11 @@ // file type information. 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); + FileSpec plugin_file_spec(path, false); plugin_file_spec.ResolvePath(); if (PluginIsLoaded(plugin_file_spec)) - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; else { PluginInfo plugin_info; @@ -138,7 +139,7 @@ // plug-in info so we don't try to load it again and again. SetPluginInfo(plugin_file_spec, plugin_info); - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } } } @@ -149,10 +150,10 @@ // also do this for unknown as sometimes the directory enumeration might be // enumerating a file system that doesn't have correct file type // information. - return FileSpec::eEnumerateDirectoryResultEnter; + return FileSystem::eEnumerateDirectoryResultEnter; } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } void PluginManager::Initialize() { @@ -163,15 +164,17 @@ char dir_path[PATH_MAX]; if (FileSpec dir_spec = HostInfo::GetSystemPluginDir()) { if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) { - FileSpec::EnumerateDirectory(dir_path, find_directories, find_files, - find_other, LoadPluginCallback, nullptr); + FileSystem::Instance().EnumerateDirectory(dir_path, find_directories, + find_files, find_other, + LoadPluginCallback, nullptr); } } if (FileSpec dir_spec = HostInfo::GetUserPluginDir()) { if (dir_spec.Exists() && dir_spec.GetPath(dir_path, sizeof(dir_path))) { - FileSpec::EnumerateDirectory(dir_path, find_directories, find_files, - find_other, LoadPluginCallback, nullptr); + FileSystem::Instance().EnumerateDirectory(dir_path, find_directories, + find_files, find_other, + LoadPluginCallback, nullptr); } } #endif Index: source/Core/Section.cpp =================================================================== --- source/Core/Section.cpp +++ source/Core/Section.cpp @@ -10,12 +10,12 @@ #include "lldb/Core/Section.h" #include "lldb/Core/Address.h" // for Address #include "lldb/Core/Module.h" +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" // for FileSpec -#include "lldb/Utility/Stream.h" // for Stream -#include "lldb/Utility/VMRange.h" // for VMRange +#include "lldb/Utility/Stream.h" // for Stream +#include "lldb/Utility/VMRange.h" // for VMRange #include // for PRIx64 #include // for numeric_limits Index: source/Core/SourceManager.cpp =================================================================== --- source/Core/SourceManager.cpp +++ source/Core/SourceManager.cpp @@ -370,14 +370,14 @@ SourceManager::File::File(const FileSpec &file_spec, lldb::DebuggerSP debugger_sp) : m_file_spec_orig(file_spec), m_file_spec(file_spec), - m_mod_time(FileSystem::GetModificationTime(file_spec)), + m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), m_debugger_wp(debugger_sp) { CommonInitializer(file_spec, nullptr); } SourceManager::File::File(const FileSpec &file_spec, Target *target) : m_file_spec_orig(file_spec), m_file_spec(file_spec), - m_mod_time(FileSystem::GetModificationTime(file_spec)), + m_mod_time(FileSystem::Instance().GetModificationTime(file_spec)), m_debugger_wp(target ? target->GetDebugger().shared_from_this() : DebuggerSP()) { CommonInitializer(file_spec, target); @@ -421,7 +421,8 @@ SymbolContext sc; sc_list.GetContextAtIndex(0, sc); m_file_spec = sc.comp_unit; - m_mod_time = FileSystem::GetModificationTime(m_file_spec); + m_mod_time = + FileSystem::Instance().GetModificationTime(m_file_spec); } } } @@ -434,7 +435,7 @@ if (target->GetSourcePathMap().FindFile(m_file_spec, new_file_spec) || target->GetImages().FindSourceFile(m_file_spec, new_file_spec)) { m_file_spec = new_file_spec; - m_mod_time = FileSystem::GetModificationTime(m_file_spec); + m_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec); } } } @@ -514,7 +515,7 @@ // TODO: use host API to sign up for file modifications to anything in our // source cache and only update when we determine a file has been updated. // For now we check each time we want to display info for the file. - auto curr_mod_time = FileSystem::GetModificationTime(m_file_spec); + auto curr_mod_time = FileSystem::Instance().GetModificationTime(m_file_spec); if (curr_mod_time != llvm::sys::TimePoint<>() && m_mod_time != curr_mod_time) { Index: source/Core/Value.cpp =================================================================== --- source/Core/Value.cpp +++ source/Core/Value.cpp @@ -11,6 +11,7 @@ #include "lldb/Core/Address.h" // for Address #include "lldb/Core/Module.h" +#include "lldb/Host/FileSpec.h" // for FileSpec #include "lldb/Symbol/CompilerType.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -23,8 +24,7 @@ #include "lldb/Utility/ConstString.h" // for ConstString #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/Endian.h" // for InlHostByteOrder -#include "lldb/Utility/FileSpec.h" // for FileSpec +#include "lldb/Utility/Endian.h" // for InlHostByteOrder #include "lldb/Utility/State.h" #include "lldb/Utility/Stream.h" #include "lldb/lldb-defines.h" // for LLDB_INVALID_ADDRESS Index: source/Host/CMakeLists.txt =================================================================== --- source/Host/CMakeLists.txt +++ source/Host/CMakeLists.txt @@ -18,6 +18,7 @@ add_host_subdirectory(common common/File.cpp common/FileCache.cpp + common/FileSpec.cpp common/FileSystem.cpp common/GetOptInc.cpp common/Host.cpp Index: source/Host/common/Editline.cpp =================================================================== --- source/Host/common/Editline.cpp +++ source/Host/common/Editline.cpp @@ -13,8 +13,8 @@ #include "lldb/Host/ConnectionFileDescriptor.h" #include "lldb/Host/Editline.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/SelectHelper.h" #include "lldb/Utility/Status.h" Index: source/Host/common/File.cpp =================================================================== --- source/Host/common/File.cpp +++ source/Host/common/File.cpp @@ -30,9 +30,9 @@ #include "llvm/Support/Process.h" // for llvm::sys::Process::FileDescriptorHasColors() #include "lldb/Host/Config.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" using namespace lldb; Index: source/Host/common/FileSpec.cpp =================================================================== --- source/Host/common/FileSpec.cpp +++ source/Host/common/FileSpec.cpp @@ -7,7 +7,8 @@ // //===----------------------------------------------------------------------===// -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/TildeExpressionResolver.h" @@ -167,53 +168,55 @@ return true; for (auto i = path.find_first_of("\\/"); i != llvm::StringRef::npos; i = path.find_first_of("\\/", i + 1)) { - const auto next = safeCharAtIndex(path, i+1); + const auto next = safeCharAtIndex(path, i + 1); switch (next) { + case 0: + // path separator char at the end of the string which should be + // stripped unless it is the one and only character + return i > 0; + case '/': + case '\\': + // two path separator chars in the middle of a path needs to be + // normalized + if (i > 0) + return true; + ++i; + break; + + case '.': { + const auto next_next = safeCharAtIndex(path, i + 2); + switch (next_next) { + default: + break; case 0: - // path separator char at the end of the string which should be - // stripped unless it is the one and only character - return i > 0; + return true; // ends with "/." case '/': case '\\': - // two path separator chars in the middle of a path needs to be - // normalized - if (i > 0) - return true; - ++i; - break; - + return true; // contains "/./" case '.': { - const auto next_next = safeCharAtIndex(path, i+2); - switch (next_next) { - default: break; - case 0: return true; // ends with "/." - case '/': - case '\\': - return true; // contains "/./" - case '.': { - const auto next_next_next = safeCharAtIndex(path, i+3); - switch (next_next_next) { - default: break; - case 0: return true; // ends with "/.." - case '/': - case '\\': - return true; // contains "/../" - } - break; - } - } + const auto next_next_next = safeCharAtIndex(path, i + 3); + switch (next_next_next) { + default: + break; + case 0: + return true; // ends with "/.." + case '/': + case '\\': + return true; // contains "/../" } break; + } + } + } break; - default: - break; + default: + break; } } return false; } - -} +} // namespace //------------------------------------------------------------------ // Assignment operator. //------------------------------------------------------------------ @@ -271,10 +274,10 @@ // Split path into filename and directory. We rely on the underlying char // pointer to be nullptr when the components are empty. llvm::StringRef filename = llvm::sys::path::filename(resolved, m_style); - if(!filename.empty()) + if (!filename.empty()) m_filename.SetString(filename); llvm::StringRef directory = llvm::sys::path::parent_path(resolved, m_style); - if(!directory.empty()) + if (!directory.empty()) m_directory.SetString(directory); } @@ -425,9 +428,8 @@ // case sensitivity of equality test const bool case_sensitive = a.IsCaseSensitive() || b.IsCaseSensitive(); - const bool filenames_equal = ConstString::Equals(a.m_filename, - b.m_filename, - case_sensitive); + const bool filenames_equal = + ConstString::Equals(a.m_filename, b.m_filename, case_sensitive); if (!filenames_equal) return false; @@ -508,21 +510,13 @@ } uint64_t FileSpec::GetByteSize() const { - uint64_t Size = 0; - if (llvm::sys::fs::file_size(GetPath(), Size)) - return 0; - return Size; + return FileSystem::Instance().GetByteSize(GetPath()); } FileSpec::Style FileSpec::GetPathStyle() const { return m_style; } uint32_t FileSpec::GetPermissions() const { - namespace fs = llvm::sys::fs; - fs::file_status st; - if (fs::status(GetPath(), st, false)) - return fs::perms::perms_not_known; - - return st.permissions(); + return FileSystem::Instance().GetPermissions(GetPath()); } //------------------------------------------------------------------ @@ -602,39 +596,6 @@ return m_filename.MemorySize() + m_directory.MemorySize(); } -void FileSpec::EnumerateDirectory(llvm::StringRef dir_path, - bool find_directories, bool find_files, - bool find_other, - EnumerateDirectoryCallbackType callback, - void *callback_baton) { - namespace fs = llvm::sys::fs; - std::error_code EC; - fs::recursive_directory_iterator Iter(dir_path, EC); - fs::recursive_directory_iterator End; - for (; Iter != End && !EC; Iter.increment(EC)) { - const auto &Item = *Iter; - llvm::ErrorOr Status = Item.status(); - if (!Status) - break; - if (!find_files && fs::is_regular_file(*Status)) - continue; - if (!find_directories && fs::is_directory(*Status)) - continue; - if (!find_other && fs::is_other(*Status)) - continue; - - FileSpec Spec(Item.path(), false); - auto Result = callback(callback_baton, Status->type(), Spec); - if (Result == eEnumerateDirectoryResultQuit) - return; - if (Result == eEnumerateDirectoryResultNext) { - // Default behavior is to recurse. Opt out if the callback doesn't want - // this behavior. - Iter.no_push(); - } - } -} - FileSpec FileSpec::CopyByAppendingPathComponent(llvm::StringRef component) const { FileSpec ret = *this; @@ -713,9 +674,7 @@ return g_source_file_regex.Execute(extension.GetStringRef()); } -bool FileSpec::IsRelative() const { - return !IsAbsolute(); -} +bool FileSpec::IsRelative() const { return !IsAbsolute(); } bool FileSpec::IsAbsolute() const { llvm::SmallString<64> current_path; Index: source/Host/common/FileSystem.cpp =================================================================== --- source/Host/common/FileSystem.cpp +++ source/Host/common/FileSystem.cpp @@ -10,6 +10,7 @@ #include "lldb/Host/FileSystem.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/Threading.h" #include #include @@ -17,12 +18,114 @@ using namespace lldb; using namespace lldb_private; +using namespace llvm; + +FileSystem &FileSystem::Instance() { + static FileSystem *g_fs; + static llvm::once_flag g_once_flag; + llvm::call_once(g_once_flag, []() { + if (g_fs == nullptr) + g_fs = new FileSystem(); + }); + return *g_fs; +} + +void FileSystem::ChangeFileSystem(IntrusiveRefCntPtr fs) { + m_fs = fs; +} llvm::sys::TimePoint<> -FileSystem::GetModificationTime(const FileSpec &file_spec) { - llvm::sys::fs::file_status status; - std::error_code ec = llvm::sys::fs::status(file_spec.GetPath(), status); - if (ec) +FileSystem::GetModificationTime(const FileSpec &file_spec) const { + return GetModificationTime(file_spec.GetPath()); +} + +llvm::sys::TimePoint<> +FileSystem::GetModificationTime(const Twine &path) const { + llvm::ErrorOr status = m_fs->status(path); + if (!status) return llvm::sys::TimePoint<>(); - return status.getLastModificationTime(); + return status->getLastModificationTime(); +} + +uint64_t FileSystem::GetByteSize(const FileSpec &file_spec) const { + return GetByteSize(file_spec.GetPath()); +} + +uint64_t FileSystem::GetByteSize(const Twine &path) const { + llvm::ErrorOr status = m_fs->status(path); + if (!status) + return 0; + return status->getSize(); +} + +uint32_t FileSystem::GetPermissions(const FileSpec &file_spec) const { + return GetPermissions(file_spec.GetPath()); +} + +uint32_t FileSystem::GetPermissions(const Twine &path) const { + llvm::ErrorOr status = m_fs->status(path); + if (!status) + return llvm::sys::fs::perms::perms_not_known; + return status->getPermissions(); +} + +bool FileSystem::Exists(const llvm::Twine &path) const { + return m_fs->exists(path); +} + +bool FileSystem::Exists(const FileSpec &file_spec) const { + return Exists(file_spec.GetPath()); +} + +void FileSystem::EnumerateDirectory(Twine path, bool find_directories, + bool find_files, bool find_other, + EnumerateDirectoryCallbackType callback, + void *callback_baton) { + std::error_code EC; + llvm::vfs::recursive_directory_iterator Iter(*m_fs, path, EC); + llvm::vfs::recursive_directory_iterator End; + for (; Iter != End && !EC; Iter.increment(EC)) { + const auto &Item = *Iter; + llvm::ErrorOr Status = m_fs->status(Item.path()); + if (!Status) + break; + if (!find_files && Status->isRegularFile()) + continue; + if (!find_directories && Status->isDirectory()) + continue; + if (!find_other && Status->isOther()) + continue; + + auto Result = callback(callback_baton, Status->getType(), Item.path()); + if (Result == eEnumerateDirectoryResultQuit) + return; + if (Result == eEnumerateDirectoryResultNext) { + // Default behavior is to recurse. Opt out if the callback doesn't want + // this behavior. + Iter.no_push(); + } + } +} + +std::error_code FileSystem::MakeAbsolute(SmallVectorImpl &path) const { + return m_fs->makeAbsolute(path); +} + +std::error_code FileSystem::MakeAbsolute(FileSpec &file_spec) const { + llvm::SmallString<128> path; + file_spec.GetPath(path, false); + + auto EC = MakeAbsolute(path); + if (EC) + return EC; + + FileSpec new_file_spec(path, false, file_spec.GetPathStyle()); + file_spec = new_file_spec; + return {}; +} + +std::error_code +FileSystem::GetRealPath(const llvm::Twine &path, + llvm::SmallVectorImpl &output) const { + return m_fs->getRealPath(path, output); } Index: source/Host/common/Host.cpp =================================================================== --- source/Host/common/Host.cpp +++ source/Host/common/Host.cpp @@ -48,6 +48,7 @@ // C++ Includes #include +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/HostProcess.h" @@ -59,7 +60,6 @@ #include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/DataBufferLLVM.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Predicate.h" #include "lldb/Utility/Status.h" Index: source/Host/macosx/objcxx/Host.mm =================================================================== --- source/Host/macosx/objcxx/Host.mm +++ source/Host/macosx/objcxx/Host.mm @@ -55,16 +55,16 @@ #include #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/ThreadLauncher.h" -#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Target/Process.h" +#include "lldb/Target/ProcessLaunchInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" #include "lldb/Utility/Endian.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/NameMatches.h" #include "lldb/Utility/StreamString.h" Index: source/Host/posix/ProcessLauncherPosixFork.cpp =================================================================== --- source/Host/posix/ProcessLauncherPosixFork.cpp +++ source/Host/posix/ProcessLauncherPosixFork.cpp @@ -8,11 +8,11 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/posix/ProcessLauncherPosixFork.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostProcess.h" #include "lldb/Host/Pipe.h" #include "lldb/Target/ProcessLaunchInfo.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "llvm/Support/Errno.h" Index: source/Host/windows/HostProcessWindows.cpp =================================================================== --- source/Host/windows/HostProcessWindows.cpp +++ source/Host/windows/HostProcessWindows.cpp @@ -8,10 +8,10 @@ //===----------------------------------------------------------------------===// #include "lldb/Host/windows/HostProcessWindows.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Host/windows/windows.h" -#include "lldb/Utility/FileSpec.h" #include "llvm/ADT/STLExtras.h" #include "llvm/Support/ConvertUTF.h" Index: source/Interpreter/CommandObject.cpp =================================================================== --- source/Interpreter/CommandObject.cpp +++ source/Interpreter/CommandObject.cpp @@ -24,9 +24,9 @@ // FIXME: Make a separate file for the completers. #include "lldb/Core/FileSpecList.h" #include "lldb/DataFormatters/FormatManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Target/Language.h" Index: source/Interpreter/OptionValueFileSpec.cpp =================================================================== --- source/Interpreter/OptionValueFileSpec.cpp +++ source/Interpreter/OptionValueFileSpec.cpp @@ -109,7 +109,8 @@ const lldb::DataBufferSP &OptionValueFileSpec::GetFileContents() { if (m_current_value) { - const auto file_mod_time = FileSystem::GetModificationTime(m_current_value); + const auto file_mod_time = + FileSystem::Instance().GetModificationTime(m_current_value); if (m_data_sp && m_data_mod_time == file_mod_time) return m_data_sp; m_data_sp = DataBufferLLVM::CreateFromPath(m_current_value.GetPath()); Index: source/Interpreter/OptionValuePathMappings.cpp =================================================================== --- source/Interpreter/OptionValuePathMappings.cpp +++ source/Interpreter/OptionValuePathMappings.cpp @@ -13,9 +13,9 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Host/FileSpec.h" #include "lldb/Host/StringConvert.h" #include "lldb/Utility/Args.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" using namespace lldb; Index: source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h =================================================================== --- source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h +++ source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.h @@ -21,9 +21,9 @@ #include "lldb/Host/SafeMachO.h" // Project includes +#include "lldb/Host/FileSpec.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/UUID.h" class DynamicLoaderDarwinKernel : public lldb_private::DynamicLoader { Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.h @@ -18,10 +18,10 @@ // Other libraries and framework includes // Project includes +#include "lldb/Host/FileSpec.h" #include "lldb/Host/SafeMachO.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp @@ -115,7 +115,7 @@ // No UUID, we must rely upon the cached module modification time and the // modification time of the file on disk if (module_sp->GetModificationTime() != - FileSystem::GetModificationTime(module_sp->GetFileSpec())) + FileSystem::Instance().GetModificationTime(module_sp->GetFileSpec())) module_sp.reset(); } Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOS.h @@ -25,9 +25,9 @@ // Other libraries and framework includes // Project includes +#include "lldb/Host/FileSpec.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" Index: source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h =================================================================== --- source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h +++ source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderMacOSXDYLD.h @@ -28,10 +28,10 @@ // Other libraries and framework includes // Project includes +#include "lldb/Host/FileSpec.h" #include "lldb/Host/SafeMachO.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" Index: source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h =================================================================== --- source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h +++ source/Plugins/DynamicLoader/POSIX-DYLD/DYLDRendezvous.h @@ -16,7 +16,7 @@ #include // Other libraries and framework includes -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/lldb-defines.h" #include "lldb/lldb-types.h" Index: source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h =================================================================== --- source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h +++ source/Plugins/DynamicLoader/Static/DynamicLoaderStatic.h @@ -14,9 +14,9 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Host/FileSpec.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/UUID.h" class DynamicLoaderStatic : public lldb_private::DynamicLoader { Index: source/Plugins/ExpressionParser/Clang/ClangHost.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangHost.cpp +++ source/Plugins/ExpressionParser/Clang/ClangHost.cpp @@ -22,7 +22,7 @@ #if !defined(_WIN32) #include "lldb/Host/posix/HostInfoPosix.h" #endif -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/Log.h" #include Index: source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp =================================================================== --- source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp +++ source/Plugins/ExpressionParser/Clang/ClangModulesDeclVendor.cpp @@ -29,11 +29,11 @@ #include "ClangModulesDeclVendor.h" #include "lldb/Core/ModuleList.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp =================================================================== --- source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp +++ source/Plugins/LanguageRuntime/ObjC/AppleObjCRuntime/AppleObjCTrampolineHandler.cpp @@ -25,6 +25,7 @@ #include "lldb/Expression/FunctionCaller.h" #include "lldb/Expression/UserExpression.h" #include "lldb/Expression/UtilityFunction.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/Symbol.h" #include "lldb/Target/ABI.h" @@ -36,7 +37,6 @@ #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadPlanRunToAddress.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "llvm/ADT/STLExtras.h" Index: source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h =================================================================== --- source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h +++ source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.h @@ -11,10 +11,10 @@ #define liblldb_ObjectContainerBSDArchive_h_ #include "lldb/Core/UniqueCStringMap.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Symbol/ObjectContainer.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" // Other libraries and framework includes #include "llvm/Support/Chrono.h" Index: source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp =================================================================== --- source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp +++ source/Plugins/ObjectContainer/BSD-Archive/ObjectContainerBSDArchive.cpp @@ -461,7 +461,8 @@ return 0; const size_t initial_count = specs.GetSize(); - llvm::sys::TimePoint<> file_mod_time = FileSystem::GetModificationTime(file); + llvm::sys::TimePoint<> file_mod_time = + FileSystem::Instance().GetModificationTime(file); Archive::shared_ptr archive_sp( Archive::FindCachedArchive(file, ArchSpec(), file_mod_time, file_offset)); bool set_archive_arch = false; Index: source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h =================================================================== --- source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h +++ source/Plugins/ObjectContainer/Universal-Mach-O/ObjectContainerUniversalMachO.h @@ -14,9 +14,9 @@ // C++ Includes // Other libraries and framework includes // Project includes +#include "lldb/Host/FileSpec.h" #include "lldb/Host/SafeMachO.h" #include "lldb/Symbol/ObjectContainer.h" -#include "lldb/Utility/FileSpec.h" class ObjectContainerUniversalMachO : public lldb_private::ObjectContainer { public: Index: source/Plugins/ObjectFile/ELF/ObjectFileELF.h =================================================================== --- source/Plugins/ObjectFile/ELF/ObjectFileELF.h +++ source/Plugins/ObjectFile/ELF/ObjectFileELF.h @@ -16,9 +16,9 @@ // C++ Includes #include +#include "lldb/Host/FileSpec.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/UUID.h" #include "lldb/lldb-private.h" Index: source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp =================================================================== --- source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp +++ source/Plugins/ObjectFile/JIT/ObjectFileJIT.cpp @@ -18,6 +18,7 @@ #include "lldb/Core/RangeMap.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Platform.h" @@ -27,7 +28,6 @@ #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h =================================================================== --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.h @@ -17,9 +17,9 @@ #include "lldb/Core/Address.h" #include "lldb/Core/FileSpecList.h" #include "lldb/Core/RangeMap.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/SafeMachO.h" #include "lldb/Symbol/ObjectFile.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/UUID.h" //---------------------------------------------------------------------- Index: source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp =================================================================== --- source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp +++ source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp @@ -25,6 +25,7 @@ #include "lldb/Core/RangeMap.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/DWARFCallFrameInfo.h" #include "lldb/Symbol/ObjectFile.h" @@ -38,7 +39,6 @@ #include "lldb/Target/ThreadList.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataBuffer.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegisterValue.h" #include "lldb/Utility/Status.h" Index: source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp =================================================================== --- source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp +++ source/Plugins/ObjectFile/PECOFF/ObjectFilePECOFF.cpp @@ -16,13 +16,13 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Process.h" #include "lldb/Target/SectionLoadList.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" #include "lldb/Utility/UUID.h" Index: source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp =================================================================== --- source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp +++ source/Plugins/ObjectFile/PECOFF/WindowsMiniDump.cpp @@ -11,7 +11,7 @@ // collisions with WinAPI preprocessor macros. #include "WindowsMiniDump.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/Support/ConvertUTF.h" #ifdef _WIN32 Index: source/Plugins/Platform/Android/AdbClient.cpp =================================================================== --- source/Plugins/Platform/Android/AdbClient.cpp +++ source/Plugins/Platform/Android/AdbClient.cpp @@ -16,13 +16,13 @@ #include "llvm/Support/FileUtilities.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/PosixApi.h" #include "lldb/Utility/DataBuffer.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataEncoder.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timeout.h" @@ -484,7 +484,9 @@ return Status("Failed to send file chunk: %s", error.AsCString()); } error = SendSyncRequest( - kDONE, llvm::sys::toTimeT(FileSystem::GetModificationTime(local_file)), + kDONE, + llvm::sys::toTimeT( + FileSystem::Instance().GetModificationTime(local_file)), nullptr); if (error.Fail()) return error; Index: source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp =================================================================== --- source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp +++ source/Plugins/Platform/FreeBSD/PlatformFreeBSD.cpp @@ -23,10 +23,10 @@ #include "lldb/Breakpoint/BreakpointSite.h" #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" Index: source/Plugins/Platform/Kalimba/PlatformKalimba.cpp =================================================================== --- source/Plugins/Platform/Kalimba/PlatformKalimba.cpp +++ source/Plugins/Platform/Kalimba/PlatformKalimba.cpp @@ -19,10 +19,10 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Platform/Linux/PlatformLinux.cpp =================================================================== --- source/Plugins/Platform/Linux/PlatformLinux.cpp +++ source/Plugins/Platform/Linux/PlatformLinux.cpp @@ -21,10 +21,10 @@ // Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" Index: source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h +++ source/Plugins/Platform/MacOSX/PlatformAppleSimulator.h @@ -18,7 +18,7 @@ // Project includes #include "Plugins/Platform/MacOSX/PlatformDarwin.h" #include "Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/ADT/Optional.h" Index: source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformAppleTVSimulator.cpp @@ -18,12 +18,12 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -247,19 +247,20 @@ return error; } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { if (ft == llvm::sys::fs::file_type::directory_file) { + FileSpec file_spec(path, false); const char *filename = file_spec.GetFilename().GetCString(); if (filename && strncmp(filename, "AppleTVSimulator", strlen("AppleTVSimulator")) == 0) { ::snprintf((char *)baton, PATH_MAX, "%s", filename); - return FileSpec::eEnumerateDirectoryResultQuit; + return FileSystem::eEnumerateDirectoryResultQuit; } } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } const char *PlatformAppleTVSimulator::GetSDKDirectoryAsCString() { @@ -277,9 +278,9 @@ bool find_directories = true; bool find_files = false; bool find_other = false; - FileSpec::EnumerateDirectory(sdks_directory, find_directories, find_files, - find_other, EnumerateDirectoryCallback, - sdk_dirname); + FileSystem::Instance().EnumerateDirectory( + sdks_directory, find_directories, find_files, find_other, + EnumerateDirectoryCallback, sdk_dirname); if (sdk_dirname[0]) { m_sdk_directory = sdks_directory; Index: source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformAppleWatchSimulator.cpp @@ -18,12 +18,13 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -247,19 +248,20 @@ return error; } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { if (ft == llvm::sys::fs::file_type::directory_file) { + FileSpec file_spec(path, false); const char *filename = file_spec.GetFilename().GetCString(); if (filename && strncmp(filename, "AppleWatchSimulator", strlen("AppleWatchSimulator")) == 0) { ::snprintf((char *)baton, PATH_MAX, "%s", filename); - return FileSpec::eEnumerateDirectoryResultQuit; + return FileSystem::eEnumerateDirectoryResultQuit; } } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } const char *PlatformAppleWatchSimulator::GetSDKDirectoryAsCString() { @@ -277,9 +279,9 @@ bool find_directories = true; bool find_files = false; bool find_other = false; - FileSpec::EnumerateDirectory(sdks_directory, find_directories, find_files, - find_other, EnumerateDirectoryCallback, - sdk_dirname); + FileSystem::Instance().EnumerateDirectory( + sdks_directory, find_directories, find_files, find_other, + EnumerateDirectoryCallback, sdk_dirname); if (sdk_dirname[0]) { m_sdk_directory = sdks_directory; Index: source/Plugins/Platform/MacOSX/PlatformDarwin.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwin.h +++ source/Plugins/Platform/MacOSX/PlatformDarwin.h @@ -16,7 +16,8 @@ // Other libraries and framework includes // Project includes #include "Plugins/Platform/POSIX/PlatformPOSIX.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/FileSystem.h" #include "llvm/ADT/StringRef.h" #include "llvm/Support/FileSystem.h" @@ -111,9 +112,9 @@ SDKType sdk_type; }; - static lldb_private::FileSpec::EnumerateDirectoryResult + static lldb_private::FileSystem::EnumerateDirectoryResult DirectoryEnumerator(void *baton, llvm::sys::fs::file_type file_type, - const lldb_private::FileSpec &spec); + llvm::StringRef path); static lldb_private::FileSpec FindSDKInXcodeForModules(SDKType sdk_type, Index: source/Plugins/Platform/MacOSX/PlatformDarwin.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwin.cpp +++ source/Plugins/Platform/MacOSX/PlatformDarwin.cpp @@ -22,6 +22,7 @@ #include "lldb/Core/Debugger.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/Symbols.h" @@ -1420,16 +1421,17 @@ return false; } -FileSpec::EnumerateDirectoryResult PlatformDarwin::DirectoryEnumerator( - void *baton, llvm::sys::fs::file_type file_type, const FileSpec &spec) { +FileSystem::EnumerateDirectoryResult PlatformDarwin::DirectoryEnumerator( + void *baton, llvm::sys::fs::file_type file_type, llvm::StringRef path) { SDKEnumeratorInfo *enumerator_info = static_cast(baton); + FileSpec spec(path, false); if (SDKSupportsModules(enumerator_info->sdk_type, spec)) { enumerator_info->found_path = spec; - return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; + return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; } - return FileSpec::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; + return FileSystem::EnumerateDirectoryResult::eEnumerateDirectoryResultNext; } FileSpec PlatformDarwin::FindSDKInXcodeForModules(SDKType sdk_type, @@ -1448,9 +1450,9 @@ enumerator_info.sdk_type = sdk_type; - FileSpec::EnumerateDirectory(sdks_spec.GetPath(), find_directories, - find_files, find_other, DirectoryEnumerator, - &enumerator_info); + FileSystem::Instance().EnumerateDirectory( + sdks_spec.GetPath(), find_directories, find_files, find_other, + DirectoryEnumerator, &enumerator_info); if (llvm::sys::fs::is_directory(enumerator_info.found_path.GetPath())) return enumerator_info.found_path; Index: source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h +++ source/Plugins/Platform/MacOSX/PlatformDarwinKernel.h @@ -18,7 +18,7 @@ // C Includes // C++ Includes // Other libraries and framework includes -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/Support/FileSystem.h" @@ -106,26 +106,25 @@ void AddSDKSubdirsToSearchPaths(const std::string &dir); - static lldb_private::FileSpec::EnumerateDirectoryResult + static lldb_private::FileSystem::EnumerateDirectoryResult FindKDKandSDKDirectoriesInDirectory(void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec); + llvm::StringRef path); void SearchForKextsAndKernelsRecursively(); - static lldb_private::FileSpec::EnumerateDirectoryResult - GetKernelsAndKextsInDirectoryWithRecursion( - void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec); + static lldb_private::FileSystem::EnumerateDirectoryResult + GetKernelsAndKextsInDirectoryWithRecursion(void *baton, + llvm::sys::fs::file_type ft, + llvm::StringRef path); - static lldb_private::FileSpec::EnumerateDirectoryResult - GetKernelsAndKextsInDirectoryNoRecursion( - void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec); + static lldb_private::FileSystem::EnumerateDirectoryResult + GetKernelsAndKextsInDirectoryNoRecursion(void *baton, + llvm::sys::fs::file_type ft, + llvm::StringRef path); - static lldb_private::FileSpec::EnumerateDirectoryResult + static lldb_private::FileSystem::EnumerateDirectoryResult GetKernelsAndKextsInDirectoryHelper(void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec, - bool recurse); + const llvm::StringRef path, bool recurse); static std::vector SearchForExecutablesRecursively(const std::string &dir); Index: source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp +++ source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp @@ -22,6 +22,8 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Interpreter/OptionValueFileSpecList.h" #include "lldb/Interpreter/OptionValueProperties.h" @@ -31,7 +33,6 @@ #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -424,25 +425,26 @@ const bool find_directories = true; const bool find_files = false; const bool find_other = false; - FileSpec::EnumerateDirectory(dir.c_str(), find_directories, find_files, - find_other, FindKDKandSDKDirectoriesInDirectory, - this); + FileSystem::Instance().EnumerateDirectory( + dir.c_str(), find_directories, find_files, find_other, + FindKDKandSDKDirectoriesInDirectory, this); } // Helper function to find *.sdk and *.kdk directories in a given directory. -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformDarwinKernel::FindKDKandSDKDirectoriesInDirectory( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) { + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) { static ConstString g_sdk_suffix = ConstString(".sdk"); static ConstString g_kdk_suffix = ConstString(".kdk"); + FileSpec file_spec(path, false); PlatformDarwinKernel *thisp = (PlatformDarwinKernel *)baton; if (ft == llvm::sys::fs::file_type::directory_file && (file_spec.GetFileNameExtension() == g_sdk_suffix || file_spec.GetFileNameExtension() == g_kdk_suffix)) { AddRootSubdirsToSearchPaths(thisp, file_spec.GetPath()); } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } // Recursively search trough m_search_directories looking for kext and kernel @@ -454,7 +456,7 @@ const bool find_directories = true; const bool find_files = true; const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s. - FileSpec::EnumerateDirectory( + FileSystem::Instance().EnumerateDirectory( dir.GetPath().c_str(), find_directories, find_files, find_other, GetKernelsAndKextsInDirectoryWithRecursion, this); } @@ -464,7 +466,7 @@ const bool find_directories = true; const bool find_files = true; const bool find_other = true; // I think eFileTypeSymbolicLink are "other"s. - FileSpec::EnumerateDirectory( + FileSystem::Instance().EnumerateDirectory( dir.GetPath().c_str(), find_directories, find_files, find_other, GetKernelsAndKextsInDirectoryNoRecursion, this); } @@ -478,25 +480,26 @@ // // Recurse into any subdirectories found. -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformDarwinKernel::GetKernelsAndKextsInDirectoryWithRecursion( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) { - return GetKernelsAndKextsInDirectoryHelper(baton, ft, file_spec, true); + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) { + return GetKernelsAndKextsInDirectoryHelper(baton, ft, path, true); } -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformDarwinKernel::GetKernelsAndKextsInDirectoryNoRecursion( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) { - return GetKernelsAndKextsInDirectoryHelper(baton, ft, file_spec, false); + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) { + return GetKernelsAndKextsInDirectoryHelper(baton, ft, path, false); } -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformDarwinKernel::GetKernelsAndKextsInDirectoryHelper( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec, + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path, bool recurse) { static ConstString g_kext_suffix = ConstString(".kext"); static ConstString g_dsym_suffix = ConstString(".dSYM"); static ConstString g_bundle_suffix = ConstString("Bundle"); + FileSpec file_spec(path, false); ConstString file_spec_extension = file_spec.GetFileNameExtension(); Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM)); @@ -528,7 +531,7 @@ } thisp->m_kernel_binaries_without_dsyms.push_back(file_spec); } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } } else if (ft == llvm::sys::fs::file_type::directory_file && file_spec_extension == g_kext_suffix) { @@ -549,13 +552,13 @@ const bool find_directories = true; const bool find_files = false; const bool find_other = false; - FileSpec::EnumerateDirectory( + FileSystem::Instance().EnumerateDirectory( search_here_too.c_str(), find_directories, find_files, find_other, recurse ? GetKernelsAndKextsInDirectoryWithRecursion : GetKernelsAndKextsInDirectoryNoRecursion, baton); } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } // Don't recurse into dSYM/kext/bundle directories if (recurse && file_spec_extension != g_dsym_suffix && @@ -563,9 +566,9 @@ file_spec_extension != g_bundle_suffix) { if (log_verbose) log_verbose->Printf ("PlatformDarwinKernel descending into directory '%s'", file_spec.GetPath().c_str()); - return FileSpec::eEnumerateDirectoryResultEnter; + return FileSystem::eEnumerateDirectoryResultEnter; } else { - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } } Index: source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp +++ source/Plugins/Platform/MacOSX/PlatformMacOSX.cpp @@ -21,13 +21,13 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h +++ source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.h @@ -16,7 +16,7 @@ // Other libraries and framework includes // Project includes -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/Support/FileSystem.h" Index: source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteAppleBridge.cpp @@ -21,11 +21,11 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h +++ source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.h @@ -16,7 +16,7 @@ // Other libraries and framework includes // Project includes -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/Support/FileSystem.h" Index: source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteAppleTV.cpp @@ -21,11 +21,11 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h +++ source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.h @@ -17,7 +17,7 @@ // Other libraries and framework includes // Project includes -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "PlatformRemoteDarwinDevice.h" Index: source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteAppleWatch.cpp @@ -21,11 +21,11 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h +++ source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.h @@ -17,7 +17,7 @@ // Other libraries and framework includes // Project includes #include "PlatformDarwin.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/Support/FileSystem.h" @@ -84,10 +84,10 @@ const SDKDirectoryInfo *GetSDKDirectoryForCurrentOSVersion(); - static lldb_private::FileSpec::EnumerateDirectoryResult - GetContainedFilesIntoVectorOfStringsCallback( - void *baton, llvm::sys::fs::file_type ft, - const lldb_private::FileSpec &file_spec); + static lldb_private::FileSystem::EnumerateDirectoryResult + GetContainedFilesIntoVectorOfStringsCallback(void *baton, + llvm::sys::fs::file_type ft, + llvm::StringRef path); uint32_t FindFileInAllSDKs(const char *platform_file_path, lldb_private::FileSpecList &file_list); Index: source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteDarwinDevice.cpp @@ -18,10 +18,11 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -139,12 +140,13 @@ return error; } -FileSpec::EnumerateDirectoryResult +FileSystem::EnumerateDirectoryResult PlatformRemoteDarwinDevice::GetContainedFilesIntoVectorOfStringsCallback( - void *baton, llvm::sys::fs::file_type ft, const FileSpec &file_spec) { + void *baton, llvm::sys::fs::file_type ft, llvm::StringRef path) { ((PlatformRemoteDarwinDevice::SDKDirectoryInfoCollection *)baton) - ->push_back(PlatformRemoteDarwinDevice::SDKDirectoryInfo(file_spec)); - return FileSpec::eEnumerateDirectoryResultNext; + ->push_back( + PlatformRemoteDarwinDevice::SDKDirectoryInfo(FileSpec(path, false))); + return FileSystem::eEnumerateDirectoryResultNext; } bool PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded() { @@ -175,10 +177,10 @@ const bool find_other = false; SDKDirectoryInfoCollection builtin_sdk_directory_infos; - FileSpec::EnumerateDirectory(m_device_support_directory, find_directories, - find_files, find_other, - GetContainedFilesIntoVectorOfStringsCallback, - &builtin_sdk_directory_infos); + FileSystem::Instance().EnumerateDirectory( + m_device_support_directory, find_directories, find_files, find_other, + GetContainedFilesIntoVectorOfStringsCallback, + &builtin_sdk_directory_infos); // Only add SDK directories that have symbols in them, some SDKs only // contain developer disk images and no symbols, so they aren't useful to @@ -214,20 +216,20 @@ } char path[PATH_MAX]; if (local_sdk_cache.GetPath(path, sizeof(path))) { - FileSpec::EnumerateDirectory( - path, find_directories, find_files, find_other, - GetContainedFilesIntoVectorOfStringsCallback, - &m_sdk_directory_infos); - const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); - // First try for an exact match of major, minor and update - for (uint32_t i = num_installed; i < num_sdk_infos; ++i) { + FileSystem::Instance().EnumerateDirectory( + path, find_directories, find_files, find_other, + GetContainedFilesIntoVectorOfStringsCallback, + &m_sdk_directory_infos); + const uint32_t num_sdk_infos = m_sdk_directory_infos.size(); + // First try for an exact match of major, minor and update + for (uint32_t i = num_installed; i < num_sdk_infos; ++i) { m_sdk_directory_infos[i].user_cached = true; if (log) { log->Printf("PlatformRemoteDarwinDevice::UpdateSDKDirectoryInfosIfNeeded " "user SDK directory %s", m_sdk_directory_infos[i].directory.GetPath().c_str()); } - } + } } } } @@ -235,10 +237,10 @@ const char *addtional_platform_dirs = getenv("PLATFORM_SDK_DIRECTORY"); if (addtional_platform_dirs) { SDKDirectoryInfoCollection env_var_sdk_directory_infos; - FileSpec::EnumerateDirectory(addtional_platform_dirs, find_directories, - find_files, find_other, - GetContainedFilesIntoVectorOfStringsCallback, - &env_var_sdk_directory_infos); + FileSystem::Instance().EnumerateDirectory( + addtional_platform_dirs, find_directories, find_files, find_other, + GetContainedFilesIntoVectorOfStringsCallback, + &env_var_sdk_directory_infos); FileSpec sdk_symbols_symlink_fspec; for (const auto &sdk_directory_info : env_var_sdk_directory_infos) { sdk_symbols_symlink_fspec = sdk_directory_info.directory; Index: source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h +++ source/Plugins/Platform/MacOSX/PlatformRemoteiOS.h @@ -17,7 +17,7 @@ // Other libraries and framework includes // Project includes #include "PlatformRemoteDarwinDevice.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" #include "llvm/Support/FileSystem.h" Index: source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp +++ source/Plugins/Platform/MacOSX/PlatformRemoteiOS.cpp @@ -18,11 +18,11 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp =================================================================== --- source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp +++ source/Plugins/Platform/MacOSX/PlatformiOSSimulator.cpp @@ -19,12 +19,13 @@ #include "lldb/Core/ModuleList.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" +#include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" @@ -253,18 +254,19 @@ return error; } -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult EnumerateDirectoryCallback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &file_spec) { + llvm::StringRef path) { if (ft == llvm::sys::fs::file_type::directory_file) { + FileSpec file_spec(path, false); const char *filename = file_spec.GetFilename().GetCString(); if (filename && strncmp(filename, "iPhoneSimulator", strlen("iPhoneSimulator")) == 0) { ::snprintf((char *)baton, PATH_MAX, "%s", filename); - return FileSpec::eEnumerateDirectoryResultQuit; + return FileSystem::eEnumerateDirectoryResultQuit; } } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } const char *PlatformiOSSimulator::GetSDKDirectoryAsCString() { @@ -282,9 +284,9 @@ bool find_directories = true; bool find_files = false; bool find_other = false; - FileSpec::EnumerateDirectory(sdks_directory, find_directories, find_files, - find_other, EnumerateDirectoryCallback, - sdk_dirname); + FileSystem::Instance().EnumerateDirectory( + sdks_directory, find_directories, find_files, find_other, + EnumerateDirectoryCallback, sdk_dirname); if (sdk_dirname[0]) { m_sdk_directory = sdks_directory; Index: source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp =================================================================== --- source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp +++ source/Plugins/Platform/NetBSD/PlatformNetBSD.cpp @@ -21,10 +21,10 @@ // Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" Index: source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp =================================================================== --- source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp +++ source/Plugins/Platform/OpenBSD/PlatformOpenBSD.cpp @@ -21,10 +21,10 @@ // Project includes #include "lldb/Core/Debugger.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" #include "lldb/Utility/Status.h" Index: source/Plugins/Platform/POSIX/PlatformPOSIX.cpp =================================================================== --- source/Plugins/Platform/POSIX/PlatformPOSIX.cpp +++ source/Plugins/Platform/POSIX/PlatformPOSIX.cpp @@ -24,6 +24,7 @@ #include "lldb/Expression/UtilityFunction.h" #include "lldb/Host/File.h" #include "lldb/Host/FileCache.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" @@ -35,7 +36,6 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/CleanUp.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp =================================================================== --- source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp +++ source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp @@ -21,12 +21,12 @@ #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/PosixApi.h" #include "lldb/Target/Process.h" #include "lldb/Target/Target.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Process/Darwin/NativeProcessDarwin.h =================================================================== --- source/Plugins/Process/Darwin/NativeProcessDarwin.h +++ source/Plugins/Process/Darwin/NativeProcessDarwin.h @@ -23,12 +23,12 @@ // Other libraries and framework includes #include "lldb/Host/Debug.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/Pipe.h" #include "lldb/Host/common/NativeProcessProtocol.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/lldb-types.h" #include "LaunchFlavor.h" Index: source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp =================================================================== --- source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp +++ source/Plugins/Process/FreeBSD/ProcessFreeBSD.cpp @@ -44,13 +44,13 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Target/DynamicLoader.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Target.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/State.h" #include "lldb/Host/posix/Fcntl.h" Index: source/Plugins/Process/FreeBSD/ProcessMonitor.h =================================================================== --- source/Plugins/Process/FreeBSD/ProcessMonitor.h +++ source/Plugins/Process/FreeBSD/ProcessMonitor.h @@ -18,8 +18,8 @@ #include // Other libraries and framework includes +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostThread.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/lldb-types.h" namespace lldb_private { Index: source/Plugins/Process/Linux/NativeProcessLinux.h =================================================================== --- source/Plugins/Process/Linux/NativeProcessLinux.h +++ source/Plugins/Process/Linux/NativeProcessLinux.h @@ -14,11 +14,11 @@ #include #include "lldb/Host/Debug.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/linux/Support.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/lldb-types.h" #include "NativeThreadLinux.h" Index: source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp =================================================================== --- source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp +++ source/Plugins/Process/MacOSX-Kernel/CommunicationKDP.cpp @@ -18,11 +18,11 @@ // Other libraries and framework includes #include "lldb/Core/DumpDataExtractor.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Target/Process.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" #include "lldb/Utility/UUID.h" Index: source/Plugins/Process/NetBSD/NativeProcessNetBSD.h =================================================================== --- source/Plugins/Process/NetBSD/NativeProcessNetBSD.h +++ source/Plugins/Process/NetBSD/NativeProcessNetBSD.h @@ -10,9 +10,9 @@ #ifndef liblldb_NativeProcessNetBSD_H_ #define liblldb_NativeProcessNetBSD_H_ +#include "lldb/Host/FileSpec.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #include "NativeThreadNetBSD.h" #include "lldb/Host/common/NativeProcessProtocol.h" Index: source/Plugins/Process/Windows/Common/DebuggerThread.cpp =================================================================== --- source/Plugins/Process/Windows/Common/DebuggerThread.cpp +++ source/Plugins/Process/Windows/Common/DebuggerThread.cpp @@ -12,13 +12,13 @@ #include "IDebugDelegate.h" #include "lldb/Core/ModuleSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/ThreadLauncher.h" #include "lldb/Host/windows/HostProcessWindows.h" #include "lldb/Host/windows/HostThreadWindows.h" #include "lldb/Host/windows/ProcessLauncherWindows.h" #include "lldb/Target/Process.h" #include "lldb/Target/ProcessLaunchInfo.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Predicate.h" #include "lldb/Utility/Status.h" Index: source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp =================================================================== --- source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp +++ source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp @@ -18,6 +18,7 @@ // Other libraries and framework includes #include "lldb/Core/StreamFile.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" #include "lldb/Host/Pipe.h" @@ -26,7 +27,6 @@ #include "lldb/Host/ThreadLauncher.h" #include "lldb/Target/Platform.h" #include "lldb/Target/Process.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/RegularExpression.h" #include "lldb/Utility/StreamString.h" Index: source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp =================================================================== --- source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp +++ source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp @@ -38,6 +38,7 @@ #include "lldb/Core/Value.h" #include "lldb/DataFormatters/FormatManager.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostThread.h" #include "lldb/Host/PosixApi.h" @@ -66,7 +67,6 @@ #include "lldb/Target/ThreadPlanCallFunction.h" #include "lldb/Utility/Args.h" #include "lldb/Utility/CleanUp.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/State.h" #include "lldb/Utility/StreamString.h" #include "lldb/Utility/Timer.h" Index: source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp =================================================================== --- source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp +++ source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp @@ -424,7 +424,8 @@ FileSpec oso_file(oso_path, false); ConstString oso_object; if (oso_file.Exists()) { - auto oso_mod_time = FileSystem::GetModificationTime(oso_file); + auto oso_mod_time = + FileSystem::Instance().GetModificationTime(oso_file); if (oso_mod_time != comp_unit_info->oso_mod_time) { obj_file->GetModule()->ReportError( "debug map object file '%s' has changed (actual time is " Index: source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h =================================================================== --- source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h +++ source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.h @@ -19,11 +19,11 @@ // Other libraries and framework include // Project includes #include "lldb/Core/ModuleList.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Target/Process.h" #include "lldb/Target/QueueItem.h" #include "lldb/Target/SystemRuntime.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/UUID.h" Index: source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp =================================================================== --- source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp +++ source/Plugins/SystemRuntime/MacOSX/SystemRuntimeMacOSX.cpp @@ -13,6 +13,7 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/Section.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/ObjectFile.h" #include "lldb/Symbol/SymbolContext.h" @@ -24,7 +25,6 @@ #include "lldb/Target/Thread.h" #include "lldb/Utility/DataBufferHeap.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/StreamString.h" Index: source/Target/PathMappingList.cpp =================================================================== --- source/Target/PathMappingList.cpp +++ source/Target/PathMappingList.cpp @@ -14,12 +14,12 @@ // Other libraries and framework includes // Project includes -#include "lldb/lldb-private-enumerations.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/PosixApi.h" #include "lldb/Target/PathMappingList.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" +#include "lldb/lldb-private-enumerations.h" using namespace lldb; using namespace lldb_private; Index: source/Target/Platform.cpp =================================================================== --- source/Target/Platform.cpp +++ source/Target/Platform.cpp @@ -26,6 +26,7 @@ #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" #include "lldb/Core/StreamFile.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/Host.h" #include "lldb/Host/HostInfo.h" @@ -39,7 +40,6 @@ #include "lldb/Target/Target.h" #include "lldb/Target/UnixSignals.h" #include "lldb/Utility/DataBufferHeap.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/StructuredData.h" @@ -552,16 +552,17 @@ Status error; }; -static FileSpec::EnumerateDirectoryResult +static FileSystem::EnumerateDirectoryResult RecurseCopy_Callback(void *baton, llvm::sys::fs::file_type ft, - const FileSpec &src) { + llvm::StringRef path) { + FileSpec src(path, false); RecurseCopyBaton *rc_baton = (RecurseCopyBaton *)baton; namespace fs = llvm::sys::fs; switch (ft) { case fs::file_type::fifo_file: case fs::file_type::socket_file: // we have no way to copy pipes and sockets - ignore them and continue - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; break; case fs::file_type::directory_file: { @@ -574,7 +575,8 @@ if (error.Fail()) { rc_baton->error.SetErrorStringWithFormat( "unable to setup directory %s on remote end", dst_dir.GetCString()); - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail + // out } // now recurse @@ -586,13 +588,14 @@ recurse_dst.GetDirectory().SetCString(dst_dir.GetPath().c_str()); RecurseCopyBaton rc_baton2 = {recurse_dst, rc_baton->platform_ptr, Status()}; - FileSpec::EnumerateDirectory(src_dir_path, true, true, true, - RecurseCopy_Callback, &rc_baton2); + FileSystem::Instance().EnumerateDirectory(src_dir_path, true, true, true, + RecurseCopy_Callback, &rc_baton2); if (rc_baton2.error.Fail()) { rc_baton->error.SetErrorString(rc_baton2.error.AsCString()); - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail + // out } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } break; case fs::file_type::symlink_file: { @@ -606,15 +609,17 @@ rc_baton->error = FileSystem::Readlink(src, src_resolved); if (rc_baton->error.Fail()) - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail + // out rc_baton->error = rc_baton->platform_ptr->CreateSymlink(dst_file, src_resolved); if (rc_baton->error.Fail()) - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail + // out - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } break; case fs::file_type::regular_file: { @@ -625,15 +630,16 @@ Status err = rc_baton->platform_ptr->PutFile(src, dst_file); if (err.Fail()) { rc_baton->error.SetErrorString(err.AsCString()); - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail + // out } - return FileSpec::eEnumerateDirectoryResultNext; + return FileSystem::eEnumerateDirectoryResultNext; } break; default: rc_baton->error.SetErrorStringWithFormat( "invalid file detected during copy: %s", src.GetPath().c_str()); - return FileSpec::eEnumerateDirectoryResultQuit; // got an error, bail out + return FileSystem::eEnumerateDirectoryResultQuit; // got an error, bail out break; } llvm_unreachable("Unhandled file_type!"); @@ -719,8 +725,8 @@ recurse_dst.GetDirectory().SetCString(fixed_dst.GetCString()); std::string src_dir_path(src.GetPath()); RecurseCopyBaton baton = {recurse_dst, this, Status()}; - FileSpec::EnumerateDirectory(src_dir_path, true, true, true, - RecurseCopy_Callback, &baton); + FileSystem::Instance().EnumerateDirectory( + src_dir_path, true, true, true, RecurseCopy_Callback, &baton); return baton.error; } } break; Index: source/Target/ProcessLaunchInfo.cpp =================================================================== --- source/Target/ProcessLaunchInfo.cpp +++ source/Target/ProcessLaunchInfo.cpp @@ -422,8 +422,8 @@ return false; } else { for (size_t i = 0; argv[i] != nullptr; ++i) { - const char *arg = - Args::GetShellSafeArgument(m_shell, argv[i], safe_arg); + const char *arg = Args::GetShellSafeArgument(m_shell.GetFilename(), + argv[i], safe_arg); shell_command.Printf(" %s", arg); } } Index: source/Target/Target.cpp =================================================================== --- source/Target/Target.cpp +++ source/Target/Target.cpp @@ -28,14 +28,15 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Core/PluginManager.h" -#include "lldb/Core/Section.h" #include "lldb/Core/SearchFilter.h" +#include "lldb/Core/Section.h" #include "lldb/Core/SourceManager.h" #include "lldb/Core/StreamFile.h" #include "lldb/Core/StructuredDataImpl.h" #include "lldb/Core/ValueObject.h" #include "lldb/Expression/REPL.h" #include "lldb/Expression/UserExpression.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/Host.h" #include "lldb/Host/PosixApi.h" #include "lldb/Interpreter/CommandInterpreter.h" @@ -57,7 +58,7 @@ #include "lldb/Target/Target.h" #include "lldb/Target/Thread.h" #include "lldb/Target/ThreadSpec.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Utility/JSON.h" #include "lldb/Utility/LLDBAssert.h" #include "lldb/Utility/Log.h" #include "lldb/Utility/State.h" @@ -990,6 +991,26 @@ return false; } +static StructuredData::ObjectSP ParseJSONFromFile(const FileSpec &input_spec, + Status &error) { + StructuredData::ObjectSP return_sp; + if (!input_spec.Exists()) { + error.SetErrorStringWithFormatv("input file {0} does not exist.", + input_spec); + return return_sp; + } + + auto buffer_or_error = llvm::MemoryBuffer::getFile(input_spec.GetPath()); + if (!buffer_or_error) { + error.SetErrorStringWithFormatv("could not open input file: {0} - {1}.", + input_spec.GetPath(), + buffer_or_error.getError().message()); + return return_sp; + } + + return StructuredData::ParseJSON(buffer_or_error.get()->getBuffer()); +} + Status Target::SerializeBreakpointsToFile(const FileSpec &file, const BreakpointIDList &bp_ids, bool append) { @@ -1007,7 +1028,7 @@ StructuredData::Array *break_store_ptr = nullptr; if (append) { - input_data_sp = StructuredData::ParseJSONFromFile(file, error); + input_data_sp = ParseJSONFromFile(file, error); if (error.Success()) { break_store_ptr = input_data_sp->GetAsArray(); if (!break_store_ptr) { @@ -1096,8 +1117,7 @@ GetBreakpointList().GetListMutex(lock); Status error; - StructuredData::ObjectSP input_data_sp = - StructuredData::ParseJSONFromFile(file, error); + StructuredData::ObjectSP input_data_sp = ParseJSONFromFile(file, error); if (!error.Success()) { return error; } else if (!input_data_sp || !input_data_sp->IsValid()) { Index: source/Utility/Args.cpp =================================================================== --- source/Utility/Args.cpp +++ source/Utility/Args.cpp @@ -8,8 +8,8 @@ //===----------------------------------------------------------------------===// #include "lldb/Utility/Args.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Utility/ConstString.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Stream.h" #include "lldb/Utility/StringList.h" #include "llvm/ADT/StringSwitch.h" @@ -415,7 +415,7 @@ return s.c_str(); } -const char *Args::GetShellSafeArgument(const FileSpec &shell, +const char *Args::GetShellSafeArgument(ConstString shell, const char *unsafe_arg, std::string &safe_arg) { struct ShellDescriptor { @@ -430,9 +430,9 @@ // safe minimal set const char *escapables = " '\""; - if (auto basename = shell.GetFilename()) { + if (shell) { for (const auto &Shell : g_Shells) { - if (Shell.m_basename == basename) { + if (Shell.m_basename == shell) { escapables = Shell.m_escapables; break; } Index: source/Utility/CMakeLists.txt =================================================================== --- source/Utility/CMakeLists.txt +++ source/Utility/CMakeLists.txt @@ -51,7 +51,6 @@ DataEncoder.cpp DataExtractor.cpp Environment.cpp - FileSpec.cpp IOObject.cpp JSON.cpp LLDBAssert.cpp Index: source/Utility/StructuredData.cpp =================================================================== --- source/Utility/StructuredData.cpp +++ source/Utility/StructuredData.cpp @@ -9,7 +9,6 @@ #include "lldb/Utility/StructuredData.h" #include "lldb/Utility/DataBuffer.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/JSON.h" #include "lldb/Utility/Status.h" #include "lldb/Utility/Stream.h" // for Stream @@ -30,28 +29,6 @@ static StructuredData::ObjectSP ParseJSONObject(JSONParser &json_parser); static StructuredData::ObjectSP ParseJSONArray(JSONParser &json_parser); -StructuredData::ObjectSP -StructuredData::ParseJSONFromFile(const FileSpec &input_spec, Status &error) { - StructuredData::ObjectSP return_sp; - if (!input_spec.Exists()) { - error.SetErrorStringWithFormatv("input file {0} does not exist.", - input_spec); - return return_sp; - } - - auto buffer_or_error = llvm::MemoryBuffer::getFile(input_spec.GetPath()); - if (!buffer_or_error) { - error.SetErrorStringWithFormatv("could not open input file: {0} - {1}.", - input_spec.GetPath(), - buffer_or_error.getError().message()); - return return_sp; - } - - JSONParser json_parser(buffer_or_error.get()->getBuffer()); - return_sp = ParseJSONValue(json_parser); - return return_sp; -} - static StructuredData::ObjectSP ParseJSONObject(JSONParser &json_parser) { // The "JSONParser::Token::ObjectStart" token should have already been // consumed by the time this function is called Index: tools/lldb-server/lldb-platform.cpp =================================================================== --- tools/lldb-server/lldb-platform.cpp +++ tools/lldb-server/lldb-platform.cpp @@ -31,10 +31,10 @@ #include "Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.h" #include "Plugins/Process/gdb-remote/ProcessGDBRemoteLog.h" #include "lldb/Host/ConnectionFileDescriptor.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostGetOpt.h" #include "lldb/Host/OptionParser.h" #include "lldb/Host/common/TCPSocket.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/Utility/Status.h" using namespace lldb; Index: unittests/Expression/ClangParserTest.cpp =================================================================== --- unittests/Expression/ClangParserTest.cpp +++ unittests/Expression/ClangParserTest.cpp @@ -9,8 +9,8 @@ #include "Plugins/ExpressionParser/Clang/ClangHost.h" #include "TestingSupport/TestUtilities.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" -#include "lldb/Utility/FileSpec.h" #include "lldb/lldb-defines.h" #include "gtest/gtest.h" Index: unittests/Host/CMakeLists.txt =================================================================== --- unittests/Host/CMakeLists.txt +++ unittests/Host/CMakeLists.txt @@ -1,4 +1,5 @@ set (FILES + FileSpecTest.cpp FileSystemTest.cpp HostInfoTest.cpp HostTest.cpp Index: unittests/Host/FileSpecTest.cpp =================================================================== --- unittests/Host/FileSpecTest.cpp +++ unittests/Host/FileSpecTest.cpp @@ -9,7 +9,7 @@ #include "gtest/gtest.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" using namespace lldb_private; @@ -285,45 +285,34 @@ TEST(FileSpecTest, IsRelative) { llvm::StringRef not_relative[] = { - "/", - "/a", - "/a/", - "/a/b", - "/a/b/", - "//", - "//a/", - "//a/b", - "//a/b/", - "~", - "~/", - "~/a", - "~/a/", - "~/a/b" - "~/a/b/", - "/foo/.", - "/foo/..", - "/foo/../", - "/foo/../.", + "/", + "/a", + "/a/", + "/a/b", + "/a/b/", + "//", + "//a/", + "//a/b", + "//a/b/", + "~", + "~/", + "~/a", + "~/a/", + "~/a/b" + "~/a/b/", + "/foo/.", + "/foo/..", + "/foo/../", + "/foo/../.", }; - for (const auto &path: not_relative) { + for (const auto &path : not_relative) { FileSpec spec(path, false, FileSpec::Style::posix); EXPECT_FALSE(spec.IsRelative()); } llvm::StringRef is_relative[] = { - ".", - "./", - ".///", - "a", - "./a", - "./a/", - "./a/", - "./a/b", - "./a/b/", - "../foo", - "foo/bar.c", - "./foo/bar.c" - }; - for (const auto &path: is_relative) { + ".", "./", ".///", "a", "./a", "./a/", + "./a/", "./a/b", "./a/b/", "../foo", "foo/bar.c", "./foo/bar.c"}; + for (const auto &path : is_relative) { FileSpec spec(path, false, FileSpec::Style::posix); EXPECT_TRUE(spec.IsRelative()); } Index: unittests/Host/FileSystemTest.cpp =================================================================== --- unittests/Host/FileSystemTest.cpp +++ unittests/Host/FileSystemTest.cpp @@ -10,10 +10,148 @@ #include "gtest/gtest.h" #include "lldb/Host/FileSystem.h" +#include "llvm/Support/Errc.h" extern const char *TestMainArgv0; using namespace lldb_private; +using namespace llvm; +using llvm::sys::fs::UniqueID; + +// Copied verbatim from unittests/Support/VirtualFileSystemTest.cpp +namespace { +struct DummyFile : public vfs::File { + vfs::Status S; + explicit DummyFile(vfs::Status S) : S(S) {} + llvm::ErrorOr status() override { return S; } + llvm::ErrorOr> + getBuffer(const Twine &Name, int64_t FileSize, bool RequiresNullTerminator, + bool IsVolatile) override { + llvm_unreachable("unimplemented"); + } + std::error_code close() override { return std::error_code(); } +}; + +class DummyFileSystem : public vfs::FileSystem { + int FSID; // used to produce UniqueIDs + int FileID; // used to produce UniqueIDs + std::map FilesAndDirs; + + static int getNextFSID() { + static int Count = 0; + return Count++; + } + +public: + DummyFileSystem() : FSID(getNextFSID()), FileID(0) {} + + ErrorOr status(const Twine &Path) override { + std::map::iterator I = + FilesAndDirs.find(Path.str()); + if (I == FilesAndDirs.end()) + return make_error_code(llvm::errc::no_such_file_or_directory); + return I->second; + } + ErrorOr> + openFileForRead(const Twine &Path) override { + auto S = status(Path); + if (S) + return std::unique_ptr(new DummyFile{*S}); + return S.getError(); + } + llvm::ErrorOr getCurrentWorkingDirectory() const override { + return std::string(); + } + std::error_code setCurrentWorkingDirectory(const Twine &Path) override { + return std::error_code(); + } + // Map any symlink to "/symlink". + std::error_code getRealPath(const Twine &Path, + SmallVectorImpl &Output) const override { + auto I = FilesAndDirs.find(Path.str()); + if (I == FilesAndDirs.end()) + return make_error_code(llvm::errc::no_such_file_or_directory); + if (I->second.isSymlink()) { + Output.clear(); + Twine("/symlink").toVector(Output); + return std::error_code(); + } + Output.clear(); + Path.toVector(Output); + return std::error_code(); + } + + struct DirIterImpl : public llvm::vfs::detail::DirIterImpl { + std::map &FilesAndDirs; + std::map::iterator I; + std::string Path; + bool isInPath(StringRef S) { + if (Path.size() < S.size() && S.find(Path) == 0) { + auto LastSep = S.find_last_of('/'); + if (LastSep == Path.size() || LastSep == Path.size() - 1) + return true; + } + return false; + } + DirIterImpl(std::map &FilesAndDirs, + const Twine &_Path) + : FilesAndDirs(FilesAndDirs), I(FilesAndDirs.begin()), + Path(_Path.str()) { + for (; I != FilesAndDirs.end(); ++I) { + if (isInPath(I->first)) { + CurrentEntry = + vfs::directory_entry(I->second.getName(), I->second.getType()); + break; + } + } + } + std::error_code increment() override { + ++I; + for (; I != FilesAndDirs.end(); ++I) { + if (isInPath(I->first)) { + CurrentEntry = + vfs::directory_entry(I->second.getName(), I->second.getType()); + break; + } + } + if (I == FilesAndDirs.end()) + CurrentEntry = vfs::directory_entry(); + return std::error_code(); + } + }; + + vfs::directory_iterator dir_begin(const Twine &Dir, + std::error_code &EC) override { + return vfs::directory_iterator( + std::make_shared(FilesAndDirs, Dir)); + } + + void addEntry(StringRef Path, const vfs::Status &Status) { + FilesAndDirs[Path] = Status; + } + + void addRegularFile(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) { + vfs::Status S(Path, UniqueID(FSID, FileID++), + std::chrono::system_clock::now(), 0, 0, 1024, + sys::fs::file_type::regular_file, Perms); + addEntry(Path, S); + } + + void addDirectory(StringRef Path, sys::fs::perms Perms = sys::fs::all_all) { + vfs::Status S(Path, UniqueID(FSID, FileID++), + std::chrono::system_clock::now(), 0, 0, 0, + sys::fs::file_type::directory_file, Perms); + addEntry(Path, S); + } + + void addSymlink(StringRef Path) { + vfs::Status S(Path, UniqueID(FSID, FileID++), + std::chrono::system_clock::now(), 0, 0, 0, + sys::fs::file_type::symlink_file, sys::fs::all_all); + addEntry(Path, S); + } +}; +} // namespace TEST(FileSystemTest, FileAndDirectoryComponents) { using namespace std::chrono; @@ -26,7 +164,47 @@ #endif FileSpec fs2(TestMainArgv0, resolve); - EXPECT_EQ(system_clock::time_point(), FileSystem::GetModificationTime(fs1)); + FileSystem fs; + + EXPECT_EQ(system_clock::time_point(), fs.GetModificationTime(fs1)); EXPECT_LT(system_clock::time_point() + hours(24 * 365 * 20), - FileSystem::GetModificationTime(fs2)); + fs.GetModificationTime(fs2)); +} + +FileSystem::EnumerateDirectoryResult +VFSCallback(void *baton, llvm::sys::fs::file_type file_type, + llvm::StringRef path) { + auto visited = static_cast *>(baton); + visited->push_back(path.str()); + return FileSystem::eEnumerateDirectoryResultNext; +} + +TEST(FileSystemTest, VirtualFileSystem) { + IntrusiveRefCntPtr D(new DummyFileSystem()); + ErrorOr Status((std::error_code())); + D->addRegularFile("/foo"); + D->addDirectory("/bar"); + D->addSymlink("/baz"); + + FileSystem fs; + fs.ChangeFileSystem(D); + + EXPECT_TRUE(fs.Exists("/foo")); + + std::vector visited; + + constexpr bool find_directories = true; + constexpr bool find_files = true; + constexpr bool find_other = true; + + fs.EnumerateDirectory("/", find_directories, find_files, find_other, + VFSCallback, &visited); + + EXPECT_EQ(visited.size(), (size_t)3); + EXPECT_TRUE(std::find(visited.begin(), visited.end(), "/foo") != + visited.end()); + EXPECT_TRUE(std::find(visited.begin(), visited.end(), "/bar") != + visited.end()); + EXPECT_TRUE(std::find(visited.begin(), visited.end(), "/baz") != + visited.end()); } Index: unittests/Process/minidump/MinidumpParserTest.cpp =================================================================== --- unittests/Process/minidump/MinidumpParserTest.cpp +++ unittests/Process/minidump/MinidumpParserTest.cpp @@ -16,11 +16,11 @@ #include "Plugins/Process/minidump/RegisterContextMinidump_x86_64.h" #include "TestingSupport/TestUtilities.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Target/MemoryRegionInfo.h" #include "lldb/Utility/ArchSpec.h" #include "lldb/Utility/DataBufferLLVM.h" #include "lldb/Utility/DataExtractor.h" -#include "lldb/Utility/FileSpec.h" #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/Optional.h" #include "llvm/Support/FileSystem.h" Index: unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp =================================================================== --- unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp +++ unittests/SymbolFile/DWARF/SymbolFileDWARFTests.cpp @@ -22,13 +22,13 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" using namespace lldb_private; Index: unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp =================================================================== --- unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp +++ unittests/SymbolFile/PDB/SymbolFilePDBTests.cpp @@ -22,13 +22,13 @@ #include "lldb/Core/Address.h" #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" +#include "lldb/Host/FileSpec.h" #include "lldb/Host/HostInfo.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" #include "lldb/Symbol/LineTable.h" #include "lldb/Symbol/SymbolVendor.h" #include "lldb/Utility/ArchSpec.h" -#include "lldb/Utility/FileSpec.h" #if defined(_MSC_VER) #include "lldb/Host/windows/windows.h" Index: unittests/Target/PathMappingListTest.cpp =================================================================== --- unittests/Target/PathMappingListTest.cpp +++ unittests/Target/PathMappingListTest.cpp @@ -7,9 +7,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/ADT/ArrayRef.h" #include "lldb/Target/PathMappingList.h" -#include "lldb/Utility/FileSpec.h" +#include "lldb/Host/FileSpec.h" +#include "llvm/ADT/ArrayRef.h" #include "gtest/gtest.h" #include Index: unittests/Utility/CMakeLists.txt =================================================================== --- unittests/Utility/CMakeLists.txt +++ unittests/Utility/CMakeLists.txt @@ -7,7 +7,6 @@ ConstStringTest.cpp CompletionRequestTest.cpp EnvironmentTest.cpp - FileSpecTest.cpp FlagsTest.cpp JSONTest.cpp LogTest.cpp Index: unittests/Utility/StructuredDataTest.cpp =================================================================== --- unittests/Utility/StructuredDataTest.cpp +++ unittests/Utility/StructuredDataTest.cpp @@ -31,18 +31,3 @@ EXPECT_EQ(P.second, S.GetString()); } } - -TEST(StructuredDataTest, ParseJSONFromFile) { - Status status; - auto object_sp = StructuredData::ParseJSONFromFile( - FileSpec("non-existing-file.json", false), status); - EXPECT_EQ(nullptr, object_sp); - - std::string input = GetInputFilePath("StructuredData-basic.json"); - object_sp = StructuredData::ParseJSONFromFile(FileSpec(input, false), status); - ASSERT_NE(nullptr, object_sp); - - StreamString S; - object_sp->Dump(S, false); - EXPECT_EQ("[1,2,3]", S.GetString()); -}