summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/FileSystem.cpp
Commit message (Collapse)AuthorAgeFilesLines
* uint32_t options -> File::OpenOptions optionsLawrence D'Anna2019-10-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch re-types everywhere that passes a File::OpenOptions as a uint32_t so it actually uses File::OpenOptions. It also converts some OpenOptions related functions that fail by returning 0 or NULL into llvm::Expected split off from https://reviews.llvm.org/D68737 Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68853 llvm-svn: 374817
* factor out an abstract base class for FileLawrence D'Anna2019-10-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch factors out File as an abstract base class and moves most of its actual functionality into a subclass called NativeFile. In the next patch, I'm going to be adding subclasses of File that don't necessarily have any connection to actual OS files, so they will not inherit from NativeFile. This patch was split out as a prerequisite for https://reviews.llvm.org/D68188 Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68317 llvm-svn: 373564
* Convert FileSystem::Open() to return Expected<FileUP>Lawrence D'Anna2019-09-261-14/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch converts FileSystem::Open from this prototype: Status Open(File &File, const FileSpec &file_spec, ...); to this one: llvm::Expected<std::unique_ptr<File>> Open(const FileSpec &file_spec, ...); This is beneficial on its own, as llvm::Expected is a more modern and recommended error type than Status. It is also a necessary step towards https://reviews.llvm.org/D67891, and further developments for lldb_private::File. Reviewers: JDevlieghere, jasonmolenda, labath Reviewed By: labath Subscribers: mgorny, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67996 llvm-svn: 373003
* File::SetDescriptor() should require optionsJonas Devlieghere2019-09-231-3/+2
| | | | | | | | | | | | | | | | | | | | | | lvm_private::File::GetStream() can fail if m_options == 0 It's not clear from the header a File created with a descriptor will be not be usable by many parts of LLDB unless SetOptions is also called, but it is. This is because those parts of LLDB rely on GetStream() to use the file, and that in turn relies on calling fdopen on the descriptor. When calling fdopen, GetStream relies on m_options to determine the access mode. If m_options has never been set, GetStream() will fail. This patch adds options as a required argument to File::SetDescriptor and the corresponding constructor. Patch by: Lawrence D'Anna Differential revision: https://reviews.llvm.org/D67792 llvm-svn: 372652
* [Reproducers] Pass FileCollector around as a shared_ptr (NFC)Jonas Devlieghere2019-07-291-1/+1
| | | | | | | | | | | Instead of passing the FileCollector around as a reference or raw pointer, use a shared_ptr. This change's motivation is twofold. First it adds compatibility for the newly added `FileCollectorFileSystem`. Secondly, it addresses a lifetime issue we only see when LLDB is used from Xcode, where a reference to the FileCollector outlives the reproducer instance. llvm-svn: 367258
* [FileCollector] Remove LLDB shim around llvm::FileCollector (NFC)Jonas Devlieghere2019-07-251-2/+2
| | | | | | | | The FileCollector got lifted into LLVM and a shim was introduced in LLDB to keep the old API that takes FileSpecs. This patch removes that shim and converts the arguments in place. llvm-svn: 366975
* [FileSystem] Fix ambiguous symbol on Windows.Jonas Devlieghere2019-07-251-1/+1
| | | | | | | The using declarations make FileCollector ambiguous. Specify that FileSystem takes an lldb_private::FileCollector. llvm-svn: 366974
* [FileCollector] Change coding style from LLDB to LLVM (NFC)Jonas Devlieghere2019-07-251-2/+2
| | | | | | | | This patch changes the coding style of the FileCollector from the LLDB to the LLVM coding style. Alex recently lifted it into LLVM and I volunteered to do the conversion. llvm-svn: 366966
* [Reproducers] Make reproducer relocatableJonas Devlieghere2019-06-181-2/+3
| | | | | | | | | | | | | | Before this patch, reproducers weren't relocatable. The reproducer contained hard coded paths in the VFS mapping, as well in the yaml file listing the different input files for the command interpreter. This patch changes that: - Use relative paths for the DataCollector. - Use an overlay prefix for the FileCollector. Differential revision: https://reviews.llvm.org/D63467 llvm-svn: 363697
* [FileSystem] Fix regression in FileSystem::ResolveJonas Devlieghere2019-05-211-8/+12
| | | | | | | | | | | | | | | | When I moved the resolve code from FileSpec to the FileSystem class, I introduced a regression. If you compare the two implementations, you'll notice that if the path doesn't exist, we should only reverse the effects of makeAbsolute, not the effects of tilde expansion. As a result, the logic to create the ~/.lldb directory broke, because we would resolve the path before creating it. Because the directory didn't exist yet, we'd call create_directories on the unresolved path, which failed. Differential revision: https://reviews.llvm.org/D62219 llvm-svn: 361321
* Make sure FileSystem::Resolve preserves the path/file distinction.Adrian Prantl2019-03-131-1/+4
| | | | | | This should finally fix TestPaths.py. llvm-svn: 356057
* Pass ConstString by value (NFC)Adrian Prantl2019-03-061-2/+2
| | | | | | | | | | | | | | | | | My apologies for the large patch. With the exception of ConstString.h itself it was entirely produced by sed. ConstString has exactly one const char * data member, so passing a ConstString by reference is not any more efficient than copying it by value. In both cases a single pointer is passed. But passing it by value makes it harder to accidentally return the address of a local object. (This fixes rdar://problem/48640859 for the Apple folks) Differential Revision: https://reviews.llvm.org/D59030 llvm-svn: 355553
* [lldb-server] Improve support on WindowsAaron Smith2019-02-071-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | Summary: This commit contains the following changes: - Rewrite vfile close/read/write packet handlers with portable routines from lldb. This removes #if(s) and allows the handlers to work on Windows. - Fix a bug in File::Write. This is intended to write data at an offset to a file but actually writes at the current position of the file. - Add a default boolean argument 'should_close_fd' to FileSystem::Open to let the user decide whether to close the fd or not. Reviewers: zturner, llvm-commits, labath Reviewed By: zturner Subscribers: Hui, labath, abidh, lldb-commits Differential Revision: https://reviews.llvm.org/D56231 llvm-svn: 353446
* [Reproducers] Add file providerJonas Devlieghere2019-01-291-4/+64
| | | | | | | | | | | | | | | | | | | | | | | | | This patch adds the file provider which is responsible for capturing files used by LLDB. When capturing a reproducer, we use a file collector that is very similar to the one used in clang. For every file that we touch, we add an entry with a mapping from its virtual to its real path. When we decide to generate a reproducer we copy over the files and their permission into to reproducer folder. When replaying a reproducer, we load the VFS mapping and instantiate a RedirectingFileSystem. The latter will transparently use the files available in the reproducer. I've tested this on two macOS machines with an artificial example. Still, it is very likely that I missed some places where we (still) use native file system calls. I'm hoping to flesh those out while testing with more advanced examples. However, I will fix those things in separate patches. Differential revision: https://reviews.llvm.org/D54617 llvm-svn: 352538
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [FileSystem] Migrate CommandCompletionsJonas Devlieghere2018-12-041-0/+19
| | | | | | | | Make use of the convenience helpers from FileSystem. Differential revision: https://reviews.llvm.org/D55240 llvm-svn: 348287
* Move time cast to SymbolFileDWARFDebugMapJonas Devlieghere2018-11-271-11/+4
| | | | | | | | | When trying to fix the bots we expected that the cast would be needed in different places. Ultimately it turned out only the SymbolFileDWARFDebugMap was affected so, as Pavel correctly notes, it makes more sense to do the cast just there instead of in teh FS. llvm-svn: 347660
* [FileSystem] Ignore nanoseconds when comparing oso_mod_timeJonas Devlieghere2018-11-261-4/+11
| | | | | | | | | | | After a recent change in LLVM the TimePoint encoding become more precise, exceeding the precision of the TimePoint obtained from the DebugMap. This patch adds a flag to the GetModificationTime helper in the FileSystem to return the modification time with less precision. Thanks to Davide for bisecting this failure on the LLDB bots. llvm-svn: 347615
* Re-land "Extract construction of DataBufferLLVM into FileSystem"Jonas Devlieghere2018-11-121-0/+38
| | | | | | This fixes some UB in isLocal detected by the sanitized bot. llvm-svn: 346707
* Revert "Extract construction of DataBufferLLVM into FileSystem"Davide Italiano2018-11-121-38/+0
| | | | | | It broke the lldb sanitizer bots. llvm-svn: 346694
* Extract construction of DataBufferLLVM into FileSystemJonas Devlieghere2018-11-101-0/+38
| | | | | | | | | | This moves construction of data buffers into the FileSystem class. Like some of the previous refactorings we don't translate the path yet because the functionality hasn't been landed in LLVM yet. Differential revision: https://reviews.llvm.org/D54272 llvm-svn: 346598
* Revert "[FileSystem] Make use of FS in TildeExpressionResolver"Jonas Devlieghere2018-11-091-5/+4
| | | | | | | | The whole point of this change was making it possible to resolve paths without depending on the FileSystem, which is not what I did here. Not sure what I was thinking... llvm-svn: 346466
* [FileSystem] Make use of FS in TildeExpressionResolverJonas Devlieghere2018-11-091-4/+5
| | | | | | | | In order to call real_path from the TildeExpressionResolver we need access to the FileSystem. Since the resolver lives under utility we have to pass in the FS. llvm-svn: 346457
* [FileSystem] Add convenience method to check for directories.Jonas Devlieghere2018-11-081-0/+11
| | | | | | | | | | | Replace calls to LLVM's is_directory with calls to LLDB's FileSytem class. For this I introduced a new convenience method that, like the other methods, takes either a path or filespec. This still uses the LLVM functions under the hood. Differential revision: https://reviews.llvm.org/D54135 llvm-svn: 346375
* [FileSystem] Open File instances through the FileSystem.Jonas Devlieghere2018-11-021-0/+111
| | | | | | | | | | | This patch modifies how we open File instances in LLDB. Rather than passing a path or FileSpec to the constructor, we now go through the virtual file system. This is needed in order to make things work with the VFS in the future. Differential revision: https://reviews.llvm.org/D54020 llvm-svn: 346049
* [FileSystem] Remove `SetFileSystem` method.Jonas Devlieghere2018-11-021-4/+0
| | | | | | | This is no longer relevant with the new way we initialize the FileSystem. llvm-svn: 346003
* [File] Remove static method to get permissions.Jonas Devlieghere2018-11-011-1/+14
| | | | | | | This patch removes the static accessor in File to get a file's permissions. Permissions should be checked through the FileSystem class. llvm-svn: 345901
* [FileSystem] Move path resolution logic out of FileSpecJonas Devlieghere2018-11-011-2/+3
| | | | | | | | | This patch removes the logic for resolving paths out of FileSpec and updates call sites to rely on the FileSystem class instead. Differential revision: https://reviews.llvm.org/D53915 llvm-svn: 345890
* [FileSystem] Remove ResolveExecutableLocation() from FileSpecJonas Devlieghere2018-11-011-0/+35
| | | | | | | | | This patch removes the ResolveExecutableLocation method from FileSpec and updates its uses with calls to the FileSystem. Differential revision: https://reviews.llvm.org/D53834 llvm-svn: 345853
* [FileSystem] Improve assert and add Terminate in unit test.Jonas Devlieghere2018-11-011-3/+4
| | | | | | | | Speculative fix for the Xcode bots where we were seeing the assertion being triggered because we would re-initialize the FileSystem without terminating it. llvm-svn: 345849
* [FileSystem] Re-add EnumerateDirectoryJonas Devlieghere2018-11-011-0/+30
| | | | | | Re-enable EnumerateDirectory now that no_push is available in llvm (r345793). llvm-svn: 345799
* [FileSystem] Remove EnumerateDirectoryJonas Devlieghere2018-10-311-30/+0
| | | | | | | | The new implementation of EnumerateDirectory relies on `::no_push()` being implemented for the VFS recursive directory iterators. However this patch (D53465) hasn't been landed yet. llvm-svn: 345787
* [FileSystem] Extend file system and have it use the VFS.Jonas Devlieghere2018-10-311-7/+158
| | | | | | | | | | | | | | | | This patch extends the FileSystem class with a bunch of functions that are currently implemented as methods of the FileSpec class. These methods will be removed in future commits and replaced by calls to the file system. The new functions are operated in terms of the virtual file system which was recently moved from clang into LLVM so it could be reused in lldb. Because the VFS is stateful, we turned the FileSystem class into a singleton. Differential revision: https://reviews.llvm.org/D53532 llvm-svn: 345783
* Delete LLDB's MD5 code. Use LLVM instead.Zachary Turner2017-03-201-72/+0
| | | | | | Differential Revision: https://reviews.llvm.org/D31108 llvm-svn: 298325
* Add a function to MD5 a file's contents.Zachary Turner2017-03-201-3/+1
| | | | | | | | | | | | | | | In doing so, clean up the MD5 interface a little. Most existing users only care about the lower 8 bytes of an MD5, but for some users that care about the upper and lower, there wasn't a good interface. Furthermore, consumers of the MD5 checksum were required to handle endianness details on their own, so it seems reasonable to abstract this into a nicer interface that just gives you the right value. Differential Revision: https://reviews.llvm.org/D31105 llvm-svn: 298322
* Remove TimeValue usage from FileSpec.hPavel Labath2016-11-011-0/+10
| | | | | | | | | | | | | | | | | | | | | Summary: The only usage there was in GetModificationTime(). I also took the opportunity to move this function from FileSpec to the FileSystem class - since we are using FileSpecs to also represent remote files for which we cannot (easily) retrieve modification time, it makes sense to make the decision to get the modification time more explicit. The new function returns a llvm::sys::TimePoint<>. To aid the transition from TimeValue, I have added a constructor to it which enables implicit conversion from a time_point. Reviewers: zturner, clayborg Subscribers: mehdi_amini, tberghammer, danalbert, beanz, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D25392 llvm-svn: 285702
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-71/+60
| | | | | | | | | | | | | | | | | | | | | | | *** to conform to clang-format’s LLVM style. This kind of mass change has *** two obvious implications: Firstly, merging this particular commit into a downstream fork may be a huge effort. Alternatively, it may be worth merging all changes up to this commit, performing the same reformatting operation locally, and then discarding the merge for this particular commit. The commands used to accomplish this reformatting were as follows (with current working directory as the root of the repository): find . \( -iname "*.c" -or -iname "*.cpp" -or -iname "*.h" -or -iname "*.mm" \) -exec clang-format -i {} + find . -iname "*.py" -exec autopep8 --in-place --aggressive --aggressive {} + ; The version of clang-format used was 3.9.0, and autopep8 was 1.2.4. Secondly, “blame” style tools will generally point to this commit instead of a meaningful prior commit. There are alternatives available that will attempt to look through this change and find the appropriate prior commit. YMMV. llvm-svn: 280751
* Add qModuleInfo request in order to get module information (uuid, triple,..) ↵Oleksiy Vyalov2015-02-251-4/+35
| | | | | | | | by module path from remote platform. http://reviews.llvm.org/D7709 llvm-svn: 230556
* Introduce FileSystem::CalculateMD5AsString that supports any platform and ↵Oleksiy Vyalov2015-02-201-0/+72
make existing FileSystem::CalculateMD5 to use it. http://reviews.llvm.org/D7771 llvm-svn: 230036
OpenPOWER on IntegriCloud