summaryrefslogtreecommitdiffstats
path: root/lldb/source/Host/common/FileSpec.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Move FileSpec from Host -> Utility.Zachary Turner2017-03-221-931/+0
| | | | llvm-svn: 298536
* Resubmit "Delete the remainder of platform specific code in FileSpec."Zachary Turner2017-03-221-114/+4
| | | | | | | | | | | | | | This was causing a test failure in one of LLDB's tests which specifically dealt with a limitation in LLVM's implementation of home_directory() that LLDB's own implementation had worked around. This limitation has been addressed in r298513 on the LLVM side, so the failing test (which is now unnecessary as the limitation no longer exists) was removed in r298519, allowing this patch to be re-submitted without modification. llvm-svn: 298526
* Revert "Delete the remainder of platform specific code in FileSpec."Pavel Labath2017-03-221-4/+114
| | | | | | | This reverts commit r298465 as it breaks TestLLVM.TestHomeDirectory.test_tilde_home_directory. llvm-svn: 298509
* Delete the remainder of platform specific code in FileSpec.Zachary Turner2017-03-221-114/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D31129 llvm-svn: 298465
* Move StringList from Core -> Utility.Zachary Turner2017-03-211-1/+1
| | | | llvm-svn: 298412
* Fix windows build broken by r297612Pavel Labath2017-03-131-1/+1
| | | | | | I have got my boolean logic incorrect. Sorry about the spam. llvm-svn: 297615
* Fix android buildPavel Labath2017-03-131-1/+1
| | | | | | | | | | | | | | getpwent is not available on android until API level 21, and even then it is only available when doing a non-static link. Since android's concept of users is very different from linux, it's doubtful the home directory resolution would be useful, so I approximate this state by just not using getpwent on android. We've had another getpwent occurance in FileSpec for a while -- it wasn't causing problems because it was stripped out by the linker, but I disable that also, for consistency's sake. llvm-svn: 297612
* Fix Linux build for the FileSpec changesPavel Labath2017-03-131-5/+2
| | | | | | | Propagate changes that were made during review, and fix a couple of warnings while I'm in there. llvm-svn: 297609
* Use LLVM for file / directory enumeration.Zachary Turner2017-03-131-243/+36
| | | | | | | | | | FileSpec::EnumerateDirectory has a bunch of platform-specific gunk in it for posix and non-posix platforms. We can get rid of all this by using LLVM's easy-to-use directory iterators. Differential Revision: https://reviews.llvm.org/D30807 llvm-svn: 297598
* Resubmit FileSystem changes.Zachary Turner2017-03-081-98/+45
| | | | | | | | | | This was originall reverted due to some test failures in ModuleCache and TestCompDirSymlink. These issues have all been resolved and the code now passes all tests. Differential Revision: https://reviews.llvm.org/D30698 llvm-svn: 297300
* Revert "Use LLVM for all stat-related functionality."Pavel Labath2017-03-071-45/+98
| | | | | | | | | | | | | | | this reverts r297116 because it breaks the unittests and TestCompDirSymlink. The ModuleCache unit test is trivially fixable, but the CompDirSymlink failure is a symptom of a deeper problem: llvm's stat functionality is not a drop-in replacement for lldb's. The former is based on stat(2) (which does symlink resolution), while the latter is based on lstat(2) (which does not). This also reverts subsequent build fixes (r297128, r297120, 297117) and r297119 (Remove FileSpec dependency on FileSystem) which builds on top of this. llvm-svn: 297139
* Remove FileSpec dependency on FileSystem.Zachary Turner2017-03-071-29/+23
| | | | llvm-svn: 297119
* Fix linux build.Zachary Turner2017-03-071-2/+2
| | | | llvm-svn: 297117
* Use LLVM for all stat-related functionality.Zachary Turner2017-03-071-69/+22
| | | | | | | | | | This deletes LLDB's FileType enumeration and replaces all users, and all calls to functions that check whether a file exists etc with corresponding calls to LLVM. Differential Revision: https://reviews.llvm.org/D30624 llvm-svn: 297116
* Add missing include in FileSpec.Zachary Turner2017-03-061-0/+1
| | | | llvm-svn: 297102
* Remove dependency from FileSpec to ArchSpec.Zachary Turner2017-03-061-9/+8
| | | | | | | All it really needs is the llvm::Triple, so make FileSpec take the Triple directly instead of the ArchSpec. llvm-svn: 297096
* Remove FileSpec::ReadFileContents.Zachary Turner2017-03-061-76/+0
| | | | | | | | | | | | | | | | This functionality is subsumed by DataBufferLLVM, which is also more efficient since it will try to mmap. However, we don't yet support mmaping writable private sections, and in some cases we were using ReadFileContents and then modifying the buffer. To address that I've added a flag to the DataBufferLLVM methods that allow you to map privately, which disables the mmaping path entirely. Eventually we should teach DataBufferLLVM to use mmap with writable private, but that is orthogonal to this effort. Differential Revision: https://reviews.llvm.org/D30622 llvm-svn: 297095
* Move DataBuffer / DataExtractor and friends from Core -> Utility.Zachary Turner2017-03-041-1/+1
| | | | llvm-svn: 296943
* Remove some dead code in FileSpec.Zachary Turner2017-03-031-15/+0
| | | | | | | | This in turn triggered some fallout where other files had been transitively picking up includes that they needed from FileSpec.h, so I've fixed those up as well. llvm-svn: 296855
* Delete DataBufferMemoryMap.Zachary Turner2017-02-241-34/+0
| | | | | | | | | | | | | | | After a series of patches on the LLVM side to get the mmaping code up to compatibility with LLDB's needs, it is now ready to go, which means LLDB's custom mmapping code is redundant. So this patch deletes it all and uses LLVM's code instead. In the future, we could take this one step further and delete even the lldb DataBuffer base class and rely entirely on LLVM's facilities, but this is a job for another day. Differential Revision: https://reviews.llvm.org/D30054 llvm-svn: 296159
* Reindent the code to avoid an error with gcc:Sylvestre Ledru2017-02-161-35/+35
| | | | | | error: this ‘else’ clause does not guard... [-Werror=misleading-indentation] llvm-svn: 295352
* Move classes from Core -> Utility.Zachary Turner2017-02-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | This moves the following classes from Core -> Utility. ConstString Error RegularExpression Stream StreamString The goal here is to get lldbUtility into a state where it has no dependendencies except on itself and LLVM, so it can be the starting point at which to start untangling LLDB's dependencies. These are all low level and very widely used classes, and previously lldbUtility had dependencies up to lldbCore in order to use these classes. So moving then down to lldbUtility makes sense from both the short term and long term perspective in solving this problem. Differential Revision: https://reviews.llvm.org/D29427 llvm-svn: 293941
* Fix windows unit testsPavel Labath2017-01-161-1/+1
| | | | | | | | | The unit test I added in the previous commit discovered a bug in PrependPathComponent on windows -- it was calling SetFile with the host native path syntax, whereas it should be explicitly specifying the path syntax (as AppendPathComponent does). This fixes it. llvm-svn: 292106
* FileSpec: Fix PrependPathComponent("/")Pavel Labath2017-01-161-24/+22
| | | | | | | | | | | | | | | | Summary: PrependPathComponent was unconditionally inserting path separators between the path components. This is not correct if the prepended path is "/", which caused problems down the line. Fix the function to use the same algorithm as AppendPathComponent and add a test. This fixes one part of llvm.org/pr31611. Reviewers: clayborg, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D28677 llvm-svn: 292100
* Add methods to enable using formatv syntax in LLDB.Zachary Turner2016-12-161-4/+47
| | | | | | | | | | | | | This adds formatv-backed formatting functions in various places in LLDB such as StreamString, logging, constructing error messages, etc. A couple of callsites are changed from Printf style syntax to formatv style syntax to illustrate its usage. Additionally, a FileSpec formatter is introduced so that FileSpecs can be formatted natively. Differential Revision: https://reviews.llvm.org/D27632 llvm-svn: 289922
* Fix handling of consecutive slashes in FileSpec::GetNormalizedPath()Pavel Labath2016-11-301-1/+2
| | | | | | | | | | The core of the function was actually handling them correctly. However, the early exit was being too optimistic and did not give the function a chance to fire if the path did not contain dots as well. Fix that and add a couple of unit tests. llvm-svn: 288247
* Fix uninitialized members.Sam McCall2016-11-151-4/+2
| | | | | | | | | | | | Summary: Fix uninitialized members. Reviewers: jingham Subscribers: jingham, lldb-commits Differential Revision: https://reviews.llvm.org/D26528 llvm-svn: 286947
* Fix Clang-tidy readability-redundant-string-cstr warningsMalcolm Parsons2016-11-021-1/+1
| | | | | | | | | | Reviewers: zturner, labath Subscribers: tberghammer, danalbert, lldb-commits Differential Revision: https://reviews.llvm.org/D26233 llvm-svn: 285855
* Remove TimeValue usage from FileSpec.hPavel Labath2016-11-011-8/+0
| | | | | | | | | | | | | | | | | | | | | 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
* Improve ".." handling in FileSpec normalizationPavel Labath2016-10-311-99/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: .. handling for windows path was completely broken because the function was expecting \ as path separators, but we were passing it normalized file paths, where these have been replaced by forward slashes. Apart from this, the function was incorrect for posix paths as well in some corner cases, as well as being generally hard to follow. The corner cases were: - /../bar -> should be same as /bar - /bar/.. -> should be same as / (slightly dodgy as the former depends on /bar actually existing, but since we're doing it in an abstract way, I think the transformation is reasonable) I rewrite the function to fix these corner cases and handle windows paths more correctly. The function should now handle the posix paths (modulo symlinks, but we cannot really do anything about that without a real filesystem). For windows paths, there are a couple of corner cases left, mostly to do with drive letter handling, which cannot be fixed until the rest of the class understands drive letters better. Reviewers: clayborg, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D26081 llvm-svn: 285593
* Update FileSpec's interface to use StringRefs.Zachary Turner2016-09-271-120/+100
| | | | | | Differential Revision: https://reviews.llvm.org/D24936 llvm-svn: 282537
* Make lldb::Regex use StringRef.Zachary Turner2016-09-211-9/+9
| | | | | | | | | | This updates getters and setters to use StringRef instead of const char *. I tested the build on Linux, Windows, and OSX and saw no build or test failures. I cannot test any BSD or Android variants, however I expect the required changes to be minimal or non-existant. llvm-svn: 282079
* *** This commit represents a complete reformatting of the LLDB source codeKate Stone2016-09-061-1302/+1091
| | | | | | | | | | | | | | | | | | | | | | | *** 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
* Change the PathMappingList::FindFile to use FileSpec API'sJim Ingham2016-08-231-0/+3
| | | | | | Also, when appending path components, collapse multiple "/" into one at the join. llvm-svn: 279533
* llvm::sys::path::home_directory() relies on having "HOME" set in the ↵Greg Clayton2016-04-191-1/+15
| | | | | | | | | | environment and that might not always be set. Our FileSpec class uses this function to resolve any paths that start with "~/" on systems that support home directories as '~'. I have modified FileSpec::ResolveUsername (llvm::SmallVectorImpl<char> &path) to deal with the cases where llvm::sys::path::home_directory() returns false by digging a little further on unix systems and setting "HOME" in the environment so that subsequent calls to llvm::sys::path::home_directory() will succeed. I also added a test to ensure we don't regress. <rdar://problem/25342377> llvm-svn: 266832
* FileSpec: make matching separator-agnostic againPavel Labath2016-04-141-0/+2
| | | | | | | | | | | | | | | | | | | | | Summary: In D18689, I removed the call to Normalize() in FileSpec::SetFile, because it no longer seemed needed, and it resolved a quirk in the FileSpec API (spec.GetCString() returnes a path with backslashes, but spec.GetDirectory().GetCString() has forward slashes). This turned out to be a problem because we would consider paths with different separators as different (which led to unresolved breakpoints for instance). Here, I am putting back in the call to Normalize() and adding a unittest for FileSpec::Equal. I am commenting out the GetDirectory unittests until we figure out the what is the expected behaviour here. Reviewers: zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D19060 llvm-svn: 266286
* Make FileSpec handling platform-independentPavel Labath2016-04-041-26/+100
| | | | | | | | | | | | | | | | | Summary: Even though FileSpec attempted to handle both kinds of path syntaxes (posix and windows) on both platforms, it relied on the llvm path library to do its work, whose behavior differed on different platforms. This led to subtle differences in FileSpec behavior between platforms. This replaces the pieces of the llvm library with our own implementations. The functions are simply copied from llvm, with #ifdefs replaced by runtime checks for ePathSyntaxWindows. Reviewers: zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D18689 llvm-svn: 265299
* Unicode support on Win32.Zachary Turner2016-03-221-22/+34
| | | | | | | | | | | | | Win32 API calls that are Unicode aware require wide character strings, but LLDB uses UTF8 everywhere. This patch does conversions wherever necessary when passing strings into and out of Win32 API calls. Patch by Cameron Differential Revision: http://reviews.llvm.org/D17107 Reviewed By: zturner, amccarth llvm-svn: 264074
* Fix a couple of cornercases in FileSpec + testsPavel Labath2016-03-111-24/+22
| | | | | | | | | | | | | | | | | | | Summary: This fixes a couple of corner cases in FileSpec, related to AppendPathComponent and handling of root directory (/) file spec. I add a bunch of unit tests for the new behavior. Summary of changes: FileSpec("/bar").GetCString(): before "//bar", after "/bar". FileSpec("/").CopyByAppendingPathComponent("bar").GetCString(): before "//bar", after "/bar". FileSpec("C:", ePathSyntaxWindows).CopyByAppendingPathComponent("bar").GetCString(): before "C:/bar", after "C:\bar". Reviewers: clayborg, zturner Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D18044 llvm-svn: 263207
* Add support for reading line tables from PDB files.Zachary Turner2016-03-021-7/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | PDB is Microsoft's debug information format, and although we cannot yet generate it, we still must be able to consume it. Reason for this is that debug information for system libraries (e.g. kernel32, C Runtime Library, etc) only have debug info in PDB format, so in order to be able to support debugging of system code, we must support it. Currently this code should compile on every platform, but on non-Windows platforms the PDB plugin will return 0 capabilities, meaning that for now PDB is only supported on Windows. This may change in the future, but the API is designed in such a way that this will require few (if any) changes on the LLDB side. In the future we can just flip a switch and everything will work. This patch only adds support for line tables. It does not return information about functions, types, global variables, or anything else. This functionality will be added in a followup patch. Differential Revision: http://reviews.llvm.org/D17363 Reviewed by: Greg Clayton llvm-svn: 262528
* Some fixes for case insensitive paths on Windows.Zachary Turner2016-02-241-53/+61
| | | | | | | | | | | | | | | | | | | Paths on Windows are not case-sensitive. Because of this, if a file is called main.cpp, you should be able to set a breakpoint on it by using the name Main.cpp. In an ideal world, you could just tell people to match the case, but in practice this can be a real problem as it requires you to know whether the person who compiled the program ran "clang++ main.cpp" or "clang++ Main.cpp", both of which would work, regardless of what the file was actually called. This fixes http://llvm.org/pr22667 Patch by Petr Hons Differential Revision: http://reviews.llvm.org/D17492 Reviewed by: zturner llvm-svn: 261771
* When calling FileSpec::AppendPathComponent() we don't need to include "." in ↵Greg Clayton2015-10-201-1/+1
| | | | | | | | | | | | | | | | | | | the path if m_filename is set to exactly '.'. Previously this would cause a FileSpec object that looked like: m_directory = "/tmp" m_filename = "." To look like: m_directory = "/tmp/." m_filename = "foo.txt" if "foo.txt" was appended to it. With this fix it will be: m_directory = "/tmp" m_filename = "foo.txt" llvm-svn: 250770
* Moved ResolveSymbolicLink() to the FileSystem where it belongs, thanksSean Callanan2015-09-181-26/+0
| | | | | | | | zturner! http://reviews.llvm.org/D12984 llvm-svn: 248055
* Added support for resolving symbolic links to FileSpec.Sean Callanan2015-09-181-0/+26
| | | | | | | | | | | | | | | We use the symbolic link to resolver to find the target of the LLDB shlib symlink if there is a symlink. This allows us to find shlib-relative resources even when running under the testsuite, where _lldb.so is a symlink in the Python resource directory. Also changed a comment to be slightly more clear about what resolve_path in the constructor for FileSpec means, since if we were actually using realpath() this code wouldn't have been necessary. http://reviews.llvm.org/D12984 llvm-svn: 248048
* Simplify find_first_of & find_last_of on single char.Bruce Mitchener2015-09-011-1/+1
| | | | | | | | | | | | | | | Summary: When calling find_first_of and find_last_of on a single character, we can instead just call find / rfind and make our intent more clear. Reviewers: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D12518 llvm-svn: 246609
* Fix FileSpec::IsSymlink implementation.Oleksiy Vyalov2015-07-211-0/+22
| | | | | | http://reviews.llvm.org/D11356 llvm-svn: 242753
* Fix windows build.Ewan Crawford2015-06-301-34/+28
| | | | | | Windows build was broken in either r240983 or r240978 in the changes to FileSpec.cpp llvm-svn: 241071
* Rewrite FileSpec::EnumerateDirectory to avoid code duplication.Chaoren Lin2015-06-291-197/+16
| | | | | | | | | | | | Reviewers: clayborg Reviewed By: clayborg Subscribers: lldb-commits Differential Revision: http://reviews.llvm.org/D10811 llvm-svn: 240983
* Avoid a recursive function call that could run LLDB out of file descriptors ↵Greg Clayton2015-06-291-0/+192
| | | | | | | | | | | | | | | | | in FileSystem::DeleteDirectory(...). Fixes include: - use FileSystem::Unlink() instead of a direct call to ::unlink(...) when deleting files when iterating through the current directory - save directories from current directory in a list and iterate through those _after_ the current directory has been iterated - Use new FileSpec::ForEachItemInDirectory() instead of manually iterating across directories with opendir()/readdir()/closedir() We should switch all code over to using FileSpec::ForEachItemInDirectory(...) in the near future and get rid of FileSpec::EnumerateDirectory(). This is a follow up patch to: http://reviews.llvm.org/D10787 llvm-svn: 240978
* Rename `FileSpec::IsRelativeToCurrentWorkingDirectory` to `IsRelative`.Chaoren Lin2015-06-091-1/+7
| | | | | | | | | | | | | | | | | Summary: `IsRelativeToCurrentWorkingDirectory` was misleading, because relative paths are sometimes appended to other directories, not just the cwd. Plus, the new name is shorter. Also added `IsAbsolute` for completeness. Reviewers: clayborg, ovyalov Reviewed By: ovyalov Subscribers: tberghammer, lldb-commits Differential Revision: http://reviews.llvm.org/D10262 llvm-svn: 239419
OpenPOWER on IntegriCloud