summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/Utility/FileSpecTest.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [lldb] s/FileSpec::Equal/FileSpec::MatchPavel Labath2019-12-041-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The FileSpec class is often used as a sort of a pattern -- one specifies a bare file name to search, and we check if in matches the full file name of an existing module (for example). These comparisons used FileSpec::Equal, which had some support for it (via the full=false argument), but it was not a good fit for this job. For one, it did a symmetric comparison, which makes sense for a function called "equal", but not for typical searches (when searching for "/foo/bar.so", we don't want to find a module whose name is just "bar.so"). This resulted in patterns like: if (FileSpec::Equal(pattern, file, pattern.GetDirectory())) which would request a "full" match only if the pattern really contained a directory. This worked, but the intended behavior was very unobvious. On top of that, a lot of the code wanted to handle the case of an "empty" pattern, and treat it as matching everything. This resulted in conditions like: if (pattern && !FileSpec::Equal(pattern, file, pattern.GetDirectory()) which are nearly impossible to decipher. This patch introduces a FileSpec::Match function, which does exactly what most of FileSpec::Equal callers want, an asymmetric match between a "pattern" FileSpec and a an actual FileSpec. Empty paterns match everything, filename-only patterns match only the filename component. I've tried to update all callers of FileSpec::Equal to use a simpler interface. Those that hardcoded full=true have been changed to use operator==. Those passing full=pattern.GetDirectory() have been changed to use FileSpec::Match. There was also a handful of places which hardcoded full=false. I've changed these to use FileSpec::Match too. This is a slight change in semantics, but it does not look like that was ever intended, and it was more likely a result of a misunderstanding of the "proper" way to use FileSpec::Equal. [In an ideal world a "FileSpec" and a "FileSpec pattern" would be two different types, but given how widespread FileSpec is, it is unlikely we'll get there in one go. This at least provides a good starting point by centralizing all matching behavior.] Reviewers: teemperor, JDevlieghere, jdoerfert Subscribers: emaste, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70851
* [lldb] Add FileSpec::Equal unit testsPavel Labath2019-11-281-0/+20
| | | | this is in preparation of a refactor of this method.
* [lldb] Simplify and improve FileSpecTestPavel Labath2019-11-281-24/+24
| | | | | | | | | | | | | | | | | | Summary: A most of these tests create FileSpecs with a hardcoded style. Add utility functions which create a file spec of a given style to simplify things. While in there add SCOPED_TRACE messages to tests which loop over multiple inputs to ensure it's clear which of the inputs failed. Reviewers: teemperor Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D70814
* Breakpad: auto-detect path style of file entriesPavel Labath2019-02-111-0/+11
| | | | | | | | | | | | | | | | | | | | | | | Summary: This adds support for auto-detection of path style to SymbolFileBreakpad (similar to how r351328 did the same for DWARF). We guess each file entry separately, as we have no idea which file came from which compile units (and different compile units can have different path styles). The breakpad generates should have already converted the paths to absolute ones, so this guess should be reasonable accurate, but as always with these kinds of things, it is hard to give guarantees about anything. In an attempt to bring some unity to the path guessing logic, I move the guessing logic from inside SymbolFileDWARF into the FileSpec class and have both symbol files use it to implent their desired behavior. Reviewers: clayborg, lemo, JDevlieghere Subscribers: aprantl, markmentovai, lldb-commits Differential Revision: https://reviews.llvm.org/D57895 llvm-svn: 353702
* 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] Move path resolution logic out of FileSpecJonas Devlieghere2018-11-011-42/+41
| | | | | | | | | 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
* [FileSpec] Delegate common operations to llvm::sys::pathJonas Devlieghere2018-06-131-1/+10
| | | | | | | | | | | | | | | With the recent changes in FileSpec to use LLVM's path style, it is possible to delegate a bunch of common path operations to LLVM's path helpers. This means we only have to maintain a single implementation and at the same time can benefit from the efforts made by the rest of the LLVM community. This is part one of a set of patches. There was no obvious way to split this so I just worked from top to bottom. Differential revision: https://reviews.llvm.org/D48084 llvm-svn: 334615
* [FileSpec] Re-implmenet removeLastPathComponentJonas Devlieghere2018-05-301-0/+41
| | | | | | | | | | | | | | | | | | | | | When reading DBGSourcePathRemapping from a dSYM, we remove the last two path components to make the source lookup more general. However, when dealing with a relative path that has less than 2 components, we ended up with an invalid (empty) FileSpec. This patch changes the behavior of removeLastPathComponent to remove the last path component, if possible. It does this by checking whether a parent path exists, and if so using that as the new path. We rely entirely on LLVM's path implementation to do the heavy lifting. We now also return a boolean which indicates whether the operator was successful or not. Differential revision: https://reviews.llvm.org/D47495 rdar://37791687 llvm-svn: 333540
* Fix PathMappingList for relative and empty paths after recent FileSpec ↵Greg Clayton2018-05-211-0/+47
| | | | | | | | | | | | | | | | | | normalization changes PathMappingList was broken for relative and empty paths after normalization changes in FileSpec. There were also no tests for PathMappingList so I added those. Changes include: Change PathMappingList::ReverseRemapPath() to take FileSpec objects instead of ConstString. The only client of this was doing work to convert to and from ConstString objects for no reason. Normalize all paths prefix and replacements that are added to the PathMappingList vector so they match the paths that have been already normalized in the debug info Unify code in the two forms of PathMappingList::RemapPath() so only one contains the actual functionality. Prior to this, there were two versions of this code. Use FileSpec::AppendPathComponent() and remove a long standing TODO so paths are correctly appended to each other. Added tests for absolute, relative and empty paths. Differential Revision: https://reviews.llvm.org/D47021 llvm-svn: 332842
* Fix buildbots after it 332618Greg Clayton2018-05-171-2/+0
| | | | llvm-svn: 332633
* FileSpec objects that resolve to "." should have "." in m_filename and ↵Greg Clayton2018-05-171-4/+6
| | | | | | | | | | | | m_directory empty. After switching to LLVM normalization, if we init FileSpec with "." we would end up with m_directory being NULL and m_filename being "". This patch fixes this by allowing the path to be normalized and if it normalized to nothing, set it to m_filename. Differential Revision: https://reviews.llvm.org/D46783 llvm-svn: 332618
* Revert 332511 after reverting llvm revision 332508.Greg Clayton2018-05-161-4/+4
| | | | llvm-svn: 332556
* Fix FileSpecTest after LLVM changes to remove_dots ↵Greg Clayton2018-05-161-4/+4
| | | | | | (https://reviews.llvm.org/D46887) llvm-svn: 332511
* FileSpec: Remove PathSyntax enum and use llvm version insteadPavel Labath2018-05-141-34/+31
| | | | | | | | | | | | | | | | | | | | Summary: The llvm version of the enum has the same enumerators, with stlightly different names, so this is mostly just a search&replace exercise. One concrete benefit of this is that we can remove the function for converting between the two enums. To avoid typing llvm::sys::path::Style::windows everywhere I import the enum into the FileSpec class, so it can be referenced as FileSpec::Style::windows. Reviewers: zturner, clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D46753 llvm-svn: 332247
* Remove custom path manipulation functions from FileSpecPavel Labath2018-05-111-4/+4
| | | | | | | | | | | | | | | | | | | | Summary: now that llvm supports host-agnostic path manipulation functions (and most of their kinks have been ironed out), we can remove our copies of the path parsing functions in favour of the llvm ones. This should be NFC except for the slight difference in handling of the "//" path, which is now normalized to "/" (this only applies to the literal "//" path; "//net" and friends still get to keep the two slashes). Reviewers: zturner, clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D46687 llvm-svn: 332088
* Always normalize FileSpec paths.Greg Clayton2018-04-271-57/+25
| | | | | | | | Always normalizing lldb_private::FileSpec paths will help us get a consistent results from comparisons when setting breakpoints and when looking for source files. This also removes a lot of complexity from the comparison routines. Modified the DWARF line table parser to use the normalized compile unit directory if needed. Differential Revision: https://reviews.llvm.org/D45977 llvm-svn: 331049
* Move FileSpecTest to UtilityPavel Labath2018-04-201-0/+310
FileSpec class was moved to the Utility module a while ago, but the test file was left behind. This corrects that. llvm-svn: 330405
OpenPOWER on IntegriCloud