summaryrefslogtreecommitdiffstats
path: root/lldb/unittests
Commit message (Collapse)AuthorAgeFilesLines
...
* Use LLVM's new ItaniumPartialDemangler in LLDBStefan Granitz2018-07-252-0/+39
| | | | | | | | | | | | | | | Summary: Replace the existing combination of FastDemangle and the fallback to llvm::itaniumDemangle() with LLVM's new ItaniumPartialDemangler. It slightly reduces complexity and slightly improves performance, but doesn't introduce conceptual changes. This patch is preparing for more fundamental improvements on LLDB's demangling approach. Reviewers: friss, jingham, erik.pilkington, labath, clayborg, mgorny, davide, JDevlieghere Reviewed By: JDevlieghere Subscribers: teemperor, JDevlieghere, labath, clayborg, davide, lldb-commits, mgorny, erik.pilkington Differential Revision: https://reviews.llvm.org/D49612 llvm-svn: 337931
* Add unit tests for VMRangeRaphael Isemann2018-07-242-0/+153
| | | | | | | | Subscribers: clayborg, labath, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49415 llvm-svn: 337873
* Reimplement EventDataBytes::Dump to avoid DumpDataExtractorPavel Labath2018-07-242-0/+26
| | | | | | This is the only external non-trivial dependency of the Event classes. llvm-svn: 337819
* Added unit test for StreamTeeRaphael Isemann2018-07-242-0/+198
| | | | | | | | | | | | Reviewers: davide Reviewed By: davide Subscribers: davide, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49708 llvm-svn: 337778
* Add support for parsing Breakpad minidump files that can have extra padding ↵Greg Clayton2018-07-238-1/+77
| | | | | | | | in the module, thread and memory lists. Differential Revision: https://reviews.llvm.org/D49579 llvm-svn: 337694
* Added unit tests for FlagsRaphael Isemann2018-07-192-0/+200
| | | | | | | | | | | | Reviewers: labath Reviewed By: labath Subscribers: labath, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49435 llvm-svn: 337475
* ELF: Replace the header-extension unit test with a lit onePavel Labath2018-07-192-63/+0
| | | | | | | | | The new test checks that we are actually able to read data from these kinds of elf headers correctly instead of just that we read the section number correctly. It is also easier to figure out what's going on in the test. llvm-svn: 337459
* Fix some crashes and deadlocks in FormatAnsiTerminalCodesRaphael Isemann2018-07-162-0/+56
| | | | | | | | | | | | | | | | | | | | | Summary: This patch fixes a few problems with the FormatAnsiTerminalCodes function: * It does an infinite loop on an unknown color value. * It crashes when the color value is at the end of the string. * It deletes the first character behind the color token. Also added a few tests that reproduce those problems (and test some other corner cases). Reviewers: davide, labath Reviewed By: labath Subscribers: labath, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D49307 llvm-svn: 337189
* Replaced more boilerplate code with CompletionRequest (NFC)Raphael Isemann2018-07-131-9/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: As suggested in D48796, this patch replaces even more internal calls that were using the old completion API style with a single CompletionRequest. In some cases we also pass an option vector/index, but as we don't always have this information, it currently is not part of the CompletionRequest class. The constructor of the CompletionRequest is now also more sensible. You only pass the user input, cursor position and your list of matches to the request and the rest will be inferred (using the same code we used before to calculate this). You also have to pass these match window parameters to it, even though they are unused right now. The patch shouldn't change any behavior. Reviewers: jingham Reviewed By: jingham Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48976 llvm-svn: 337031
* Restructure the minidump loading path and add early & explicit consistency ↵Leonard Mosescu2018-07-124-9/+30
| | | | | | | | | | | | | | | | | | | | | checks Corrupted minidumps was leading to unpredictable behavior. This change adds explicit consistency checks for the minidump early on. The checks are not comprehensive but they should catch obvious structural violations: streams with type == 0 duplicate streams (same type) overlapping streams truncated minidumps Another early check is to make sure we actually support the minidump architecture instead of crashing at a random place deep inside LLDB. Differential Revision: https://reviews.llvm.org/D49202 llvm-svn: 336918
* Remove the unused m_signal member variable, but leave the code that gets it ↵Eric Christopher2018-07-122-3/+2
| | | | | | out of the json. llvm-svn: 336885
* Refactor parsing of option lists with a raw string suffix.Raphael Isemann2018-07-102-0/+184
| | | | | | | | | | | | | | | | | | | | | | Summary: A subset of the LLDB commands follows this command line interface style: <command name> [arguments] -- <string suffix> The parsing code for this interface has been so far been duplicated into the different command objects which makes it hard to maintain and reuse elsewhere. This patches improves the situation by adding a OptionsWithRaw class that centralizes the parsing logic and allows easier testing. The different commands now just call this class to extract the arguments and the raw suffix from the provided user input. Reviewers: jingham Reviewed By: jingham Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D49106 llvm-svn: 336723
* Refactoring for for the internal command line completion API (NFC)Raphael Isemann2018-07-022-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch refactors the internal completion API. It now takes (as far as possible) a single CompletionRequest object instead o half a dozen in/out/in-out parameters. The CompletionRequest contains a common superset of the different parameters as far as it makes sense. This includes the raw command line string and raw cursor position, which should make the `expr` command possible to implement (at least without hacks that reconstruct the command line from the args). This patch is not intended to change the observable behavior of lldb in any way. It's also as minimal as possible and doesn't attempt to fix all the problems the API has. Some Q&A: Q: Why is this not fixing all the problems in the completion API? A: Because is a blocker for the expr command completion which I want to get in ASAP. This is the smallest patch that unblocks the expr completion patch and which allows trivial refactoring in the future. The patch also doesn't really change the internal information flow in the API, so that hopefully saves us from ever having to revert and resubmit this humongous patch. Q: Can we merge all the copy-pasted code in the completion methods (like computing the current incomplete arg) into CompletionRequest class? A: Yes, but it's out of scope for this patch. Q: Why the `word_complete = request.GetWordComplete(); ... ` pattern? A: I don't want to add a getter that returns a reference to the internal integer. So we have to use a temporary variable and the Getter/Setter instead. We don't throw exceptions from what I can tell, so the behavior doesn't change. Q: Why are we not owning the list of matches? A: Because that's how the previous API works. But that should be fixed too (in another patch). Q: Can we make the constructor simpler and compute some of the values from the plain command? A: I think this works, but I rather want to have this in a follow up commit. Especially when making nested request it's a bit awkward that the parsed arguments behave as both input/output (as we should in theory propagate the changes on the nested request back to the parent request if we don't want to change the behavior too much). Q: Can't we pass one const request object and then just return another result object instead of mixing them together in one in/out parameter? A: It's hard to get keep the same behavior with that pattern, but I think we can also get a nice API with just a single request object. If we make all input parameters read-only, we have a clear separation between what is actually an input and what an output parameter (and hopefully we get rid of the in-out parameters). Q: Can we throw out the 'match' variables that are not implemented according to the comment? A: We currently just forward them as in the old code to the different methods, even though I think they are really not used. We can easily remove and readd them once every single completion method just takes a CompletionRequest, but for now I prefer NFC behavior from the perspective of the API user. Reviewers: davide, jingham, labath Reviewed By: jingham Subscribers: mgorny, friss, lldb-commits Differential Revision: https://reviews.llvm.org/D48796 llvm-svn: 336146
* UUID: Add support for arbitrary-sized module IDsPavel Labath2018-06-291-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: The data structure is optimized for the case where the UUID size is <= 20 bytes (standard length emitted by the GNU linkers), but larger sizes are also possible. I've modified the string conversion function to support the new sizes as well. For standard UUIDs it maintains the traditional formatting (4-2-2-2-6). If a UUID is shorter, we just cut this sequence short, and for longer UUIDs it will just repeat the last 6-byte block as long as necessary. I've also modified ObjectFileELF to take advantage of the new UUIDs and avoid manually padding the UUID to 16 bytes. While there, I also made sure the computed UUID does not depend on host endianness. Reviewers: clayborg, lemo, sas, davide, espindola Subscribers: emaste, arichardson, lldb-commits Differential Revision: https://reviews.llvm.org/D48633 llvm-svn: 335963
* Modernize completion testsPavel Labath2018-06-291-53/+32
| | | | | | | | | Now that we have gmock, we can use its matchers to better express the test assertions. The main advantage of this is that when things fail, the test will now print the expected and actual lists of completed strings instead of just a not-very-helpful "false is not true" message. llvm-svn: 335955
* Fix path completion test case added in rL335905 on WindowsRaphael Isemann2018-06-281-4/+2
| | | | | | | | | | | | | | | | | | Summary: The test fails because we don't rewrite the slash behind `foo` to the OS specific separator (as the completion API doesn't support this kind of rewriting). However, we assume that this part of the string is rewritten in the test case, which broke on Windows. Reviewers: stella.stamenova Reviewed By: stella.stamenova Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48746 llvm-svn: 335934
* Added test case for: r334978 - Fixed file completion for paths that start ↵Raphael Isemann2018-06-281-5/+21
| | | | | | | | | | | | | | with '~' Reviewers: labath Reviewed By: labath Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48665 llvm-svn: 335905
* Represent invalid UUIDs as UUIDs with length zeroPavel Labath2018-06-262-6/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: During the previous attempt to generalize the UUID class, it was suggested that we represent invalid UUIDs as length zero (previously, we used an all-zero UUID for that). This meant that some valid build-ids could not be represented (it's possible however unlikely that a checksum of some file would be zero) and complicated adding support for variable length build-ids (should a 16-byte empty UUID compare equal to a 20-byte empty UUID?). This patch resolves these issues by introducing a canonical representation for an invalid UUID. The slight complication here is that some clients (MachO) actually use the all-zero notation to mean "no UUID has been set". To keep this use case working (while making it very explicit about which construction semantices are wanted), replaced the UUID constructors and the SetBytes functions with named factory methods. - "fromData" creates a UUID from the given data, and it treats all bytes equally. - "fromOptionalData" first checks the data contents - if all bytes are zero, it treats this as an invalid/empty UUID. Reviewers: clayborg, sas, lemo, davide, espindola Subscribers: emaste, lldb-commits, arichardson Differential Revision: https://reviews.llvm.org/D48479 llvm-svn: 335612
* Remove UUID::SetFromCStringPavel Labath2018-06-211-1/+1
| | | | | | Replace uses with SetFromStringRef. NFC. llvm-svn: 335246
* Modernize UUID classPavel Labath2018-06-212-0/+37
| | | | | | | | | | | Instead of a separate GetBytes + GetByteSize methods I introduce a single GetBytes method returning an ArrayRef. This is NFC cleanup now, but it should make handling arbitrarily-sized UUIDs cleaner, should we choose to go that way. I also took the opportunity to add some unit tests for this class. llvm-svn: 335244
* Scalar: Use llvm integer conversion functionsPavel Labath2018-06-192-0/+34
| | | | | | | | | | StringConvert was the only non-Utility dependency of this class. Getting rid of it means it will be easy to move this class to a lower layer. While I was in there, I also added a couple of unit tests for the Scalar string conversion function. llvm-svn: 335060
* Replace HostInfo::GetLLDBPath with specific functionsPavel Labath2018-06-191-2/+1
| | | | | | | | | | | | | | | | | | | | | Summary: Instead of a function taking an enum value determining which path to return, we now have a suite of functions, each returning a single path kind. This makes it easy to move the python-path function into a specific plugin in a follow-up commit. All the users of GetLLDBPath were converted to call specific functions instead. Most of them were hard-coding the enum value anyway, so this conversion was simple. The only exception was SBHostOS, which I've changed to use a switch on the incoming enum value. Reviewers: clayborg, zturner Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D48272 llvm-svn: 335052
* Use llvm::VersionTuple instead of manual version marshallingPavel Labath2018-06-181-22/+13
| | | | | | | | | | | | | | | | | | Summary: This has multiple advantages: - we need only one function argument/instance variable instead of three - no need to default initialize variables - no custom parsing code - VersionTuple has comparison operators, which makes version comparisons much simpler Reviewers: zturner, friss, clayborg, jingham Subscribers: emaste, lldb-commits Differential Revision: https://reviews.llvm.org/D47889 llvm-svn: 334950
* Fix PathMappingListTest on windowsPavel Labath2018-06-141-3/+11
| | | | | | | | | | | | | r334615 changed the the value of FileSpec.IsRelative("/") for windows path syntax. We previously considered it absolute but now it is considered relative (I guess because it's interpretation depends on the current drive). This cause a failure in PathMappingList test, which assumed that "/" will not get remapped as it is an absolute path. As this is no longer true on windows, I replace "/" with a really absolute path. llvm-svn: 334702
* [FileSpec] Make style argument mandatory for SetFile. NFCJonas Devlieghere2018-06-132-2/+3
| | | | | | Update SetFile uses in the unittests. llvm-svn: 334668
* [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
* Refactor ExecuteAndWait to take StringRefs.Zachary Turner2018-06-122-4/+6
| | | | | | | | | | | | | | | | | | | This simplifies some code which had StringRefs to begin with, and makes other code more complicated which had const char* to begin with. In the end, I think this makes for a more idiomatic and platform agnostic API. Not all platforms launch process with null terminated c-string arrays for the environment pointer and argv, but the api was designed that way because it allowed easy pass-through for posix-based platforms. There's a little additional overhead now since on posix based platforms we'll be takign StringRefs which were constructed from null terminated strings and then copying them to null terminate them again, but from a readability and usability standpoint of the API user, I think this API signature is strictly better. llvm-svn: 334518
* [LLDB] Unit tests / typo fixDavid Carlier2018-06-071-1/+1
| | | | | | removing unnecessary comma. llvm-svn: 334177
* Revert "PDB support of function-level linking and splitted functions"Pavel Labath2018-06-068-104/+0
| | | | | | This reverts commit r334030 because it adds a broken test. llvm-svn: 334076
* PDB support of function-level linking and splitted functionsAaron Smith2018-06-058-0/+104
| | | | | | | | | | | | | | | | | | | Summary: The patch adds support of splitted functions (when MSVC is used with PGO) and function-level linking feature. SymbolFilePDB::ParseCompileUnitLineTable function relies on fact that ranges of compiled source files in the binary are continuous and don't intersect each other. The function creates LineSequence for each file and inserts it into LineTable, and implementation of last one relies on continuity of the sequence. But it's not always true when function-level linking enabled, e.g. in added input test file test-pdb-function-level-linking.exe there is xstring's std__basic_string_char_std__char_traits_char__std__allocator_char_____max_size (.00454820) between test-pdb-function-level-linking.cpp's foo (.00454770) and main (.004548F0). To fix the problem this patch renews the sequence on each address gap. Reviewers: asmith, zturner Reviewed By: asmith Subscribers: mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D47708 llvm-svn: 334030
* Really fix ClangParserTestPavel Labath2018-06-051-1/+9
| | | | | | | It turns out the test needs a fixture after all (to initialize HostInfo), so provide one that does that. llvm-svn: 334003
* Fix ClangParserTest.cppPavel Labath2018-06-051-1/+1
| | | | | | | The test does not use a test fixture, so it needs to be declared with the TEST macro. llvm-svn: 333992
* Fix Expression unittests on DarwinJonas Devlieghere2018-06-052-1/+4
| | | | | | Fixes the Expression unittests on Darwin after r333933 was landed. llvm-svn: 333974
* Remove dependency from Host to clang.Zachary Turner2018-06-043-60/+67
| | | | | | | | | | Host depended on clang because HostInfo had a function to get the directory where clang was installed. We move this over to the clang expression parser plugin where it's more at home. Differential Revision: https://reviews.llvm.org/D47384 llvm-svn: 333933
* [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
* HostInfoMacOSX: Support finding the clang resource directory within CLTools.Adrian Prantl2018-05-251-0/+8
| | | | | | rdar://problem/40537961 llvm-svn: 333248
* Remove spurious dependency on Process/elf-core from Process/Utility.James Y Knight2018-05-231-0/+1
| | | | | | | These checks do absolutely nothing other than cause a library layering violation in the code. llvm-svn: 333134
* Fix PathMappingList tests on windowsPavel Labath2018-05-231-25/+24
| | | | | | | | | | The tests added in r332842 don't work on windows, because they do path comparisons on strings, and on windows, the paths coming out of the mappings had backslashes in them. This switches comparisons to FileSpecs, so the results come out right. llvm-svn: 333074
* Avoid using header from Host/macosx when not testing an apple build.James Y Knight2018-05-221-2/+6
| | | | llvm-svn: 333032
* Fix PathMappingList for relative and empty paths after recent FileSpec ↵Greg Clayton2018-05-213-0/+157
| | | | | | | | | | | | | | | | | | 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
* Reapply "Remove Process references from the Host module"Pavel Labath2018-05-151-0/+5
| | | | | | This re-lands r332250/D46395, after fixing Mac build errors. llvm-svn: 332353
* [lit] Fix several tests that fail when using Python 3 or on WindowsStella Stamenova2018-05-141-6/+11
| | | | | | | | | | | | | | | | Summary: 1) In logtest.cpp, the name of the file that is reported is not always capitalized, so split the comparison to validate the file (case insensitive) and function (case sensitive) separately 2) Update the gdb remote client tests to work with Python 3. In Python 3, socket sends/receives data as bytes rather than byte strings. This also updates the usage of .hex() - this is no longer available in Python 3, so use hexlify instead Reviewers: asmith, labath, zturner Reviewed By: labath Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46773 llvm-svn: 332293
* Revert "Remove Process references from the Host module"Pavel Labath2018-05-141-5/+0
| | | | | | | | | | The first fix wasn't enough, there is still a missing ProcessInstanceInfo include in Host.mm. I won't be able to test a fix before leaving work, so I am reverting both commits. This reverts commit r332250 and the subsequent fix attempt. llvm-svn: 332261
* Remove Process references from the Host modulePavel Labath2018-05-141-0/+5
| | | | | | | | | | | | | | | | | | | | | The Process class was only being referenced because of the last-ditch effort in the process launchers to set a process death callback in case one isn't set already. Although launching a process for debugging is the most important kind of "launch" we are doing, it is by far not the only one, so assuming this particular callback is the one to be used is not a good idea (besides breaking layering). Instead of assuming a particular exit callback, I change the launcher code to require the callback to be set by the user (and fix up the two call sites which did not set the callback already). Reviewers: jingham, davide Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D46395 llvm-svn: 332250
* FileSpec: Remove PathSyntax enum and use llvm version insteadPavel Labath2018-05-143-40/+37
| | | | | | | | | | | | | | | | | | | | 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
* Conditionally compile a Darwin-only test.Adrian Prantl2018-05-111-0/+2
| | | | llvm-svn: 332140
OpenPOWER on IntegriCloud