summaryrefslogtreecommitdiffstats
path: root/lldb/unittests/Process/minidump
Commit message (Collapse)AuthorAgeFilesLines
* [lldb] Add a SubsystemRAII that takes care of calling Initialize and ↵Raphael Isemann2019-12-231-3/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Terminate in the unit tests Summary: Many of our tests need to initialize certain subsystems/plugins of LLDB such as `FileSystem` or `HostInfo` by calling their static `Initialize` functions before the test starts and then calling `::Terminate` after the test is done (in reverse order). This adds a lot of error-prone boilerplate code to our testing code. This patch adds a RAII called SubsystemRAII that ensures that we always call ::Initialize and then call ::Terminate after the test is done (and that the Terminate calls are always in the reverse order of the ::Initialize calls). It also gets rid of all of the boilerplate that we had for these calls. Per-fixture initialization is still not very nice with this approach as it would require some kind of static unique_ptr that gets manually assigned/reseted from the gtest SetUpTestCase/TearDownTestCase functions. Because of that I changed all per-fixture setup to now do per-test setup which can be done by just having the SubsystemRAII as a member of the test fixture. This change doesn't influence our normal test runtime as LIT anyway runs each test case separately (and the Initialize/Terminate calls are anyway not very expensive). It will however make running all tests in a single executable slightly slower. Reviewers: labath, JDevlieghere, martong, espindola, shafik Reviewed By: labath Subscribers: mgorny, rnkovacs, emaste, MaskRay, abidh, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D71630
* lldb/minidump: Refactor memory region computation codePavel Labath2019-10-251-111/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The goal of this refactor is to enable ProcessMinidump to take into account the loaded modules and their sections when computing the permissions of various ranges of memory, as discussed in D66638. This patch moves some of the responsibility for computing the ranges from MinidumpParser into ProcessMinidump. MinidumpParser still does the parsing, but ProcessMinidump becomes responsible for answering the actual queries about memory ranges. This will enable it (in a follow-up patch) to augment the information obtained from the parser with data obtained from actual object files. The changes in the actual code are fairly straight-forward and just involve moving code around. MinidumpParser::GetMemoryRegions is renamed to BuildMemoryRegions to emphasize that it does no caching. The only new thing is the additional bool flag returned from this function. This indicates whether the returned regions describe all memory mapped into the target process. Data obtained from /proc/maps and the MemoryInfoList stream is considered to be exhaustive. Data obtained from Memory(64)List is not. This will be used to determine whether we need to augment the data or not. This reshuffle means that it is no longer possible/easy to test some of this code via unit tests, as constructing a ProcessMinidump instance is hard. Instead, I update the unit tests to only test the parsing of the actual data, and test the answering of queries through a lit test using the "memory region" command. The patch also includes some tweaks to the MemoryRegion class to make the unit tests easier to write. Reviewers: amccarth, clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D69035
* LLDB: Use LLVM's type for minidump ExceptionStream [NFC]Joseph Tremoulet2019-10-181-2/+2
| | | | | | | | | | | | | | | | Summary: The types defined for it in LLDB are now redundant with core types. Reviewers: labath, clayborg Reviewed By: clayborg Subscribers: lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68658 llvm-svn: 375243
* minidump: Use yaml for memory info testsPavel Labath2019-10-144-2/+47
| | | | | | | Also, delete some minidump binary files that are no longer used in any test. llvm-svn: 374776
* minidump: Use llvm memory info list parserPavel Labath2019-10-111-0/+1
| | | | llvm-svn: 374532
* Fix some dangling else warningsPavel Labath2019-10-101-9/+10
| | | | | | | | EXPECT_EQ contains an if-else statement. It also contains some magic to suppress the dangling else warnings, but it seems that some new compilers can see through that... llvm-svn: 374341
* Set eRegisterKindEHFrame register numbers for 32 bit ARM register contexts ↵Greg Clayton2019-10-091-0/+55
| | | | | | | | | | in minidumps Stack unwinding was sometimes failing when trying to unwind stacks in 32 bit ARM. I discovered this was because the EH frame register numbers were not set. This patch fixes this issue and adds a unit test to verify this doesn't regress. Differential Revision: https://reviews.llvm.org/D68088 llvm-svn: 374246
* [lldb] - Update unit tests after lib/ObjectYAML change.George Rimar2019-09-131-3/+5
| | | | | | An update after r371865 llvm-svn: 371866
* Convert minidump unittests to use llvm::yaml::convertYAMLPavel Labath2019-08-201-6/+7
| | | | | | | | previously they used a minidump-specific function for this purpose, but this is no longer needed now that whole of yaml2obj is available as a library. llvm-svn: 369379
* [LLDB] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-2/+2
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368933
* minidump: Remove checked-in files used for testing MemoryList handlingPavel Labath2019-05-206-79/+179
| | | | | | | Now that yaml2obj supports this stream, we can use the yaml form instead. llvm-svn: 361126
* minidump: Use yaml instead of checked-in binaries for ThreadList testsPavel Labath2019-05-135-30/+41
| | | | | | yaml2obj now supports the ThreadList stream. llvm-svn: 360568
* Minidump: use ThreadList parsing code from llvm/ObjectPavel Labath2019-05-101-14/+14
| | | | llvm-svn: 360412
* Minidump: yamlify module-related unit testsPavel Labath2019-04-216-134/+60
| | | | | | | | | | | | | The tests reading the untouched module list are now not using any lldb code (as module list loading lives in llvm now), so they can be removed. The "filtering" of the module list remains (and probably will remain) an lldb concept, so I keep those tests, but replace the checked-in binaries with their yaml equivalents. The binaries which are no longer referenced by any tests have been removed. llvm-svn: 358850
* Minidump: Use llvm parser for reading the ModuleList streamPavel Labath2019-04-101-24/+24
| | | | | | | | In this patch, I just remove the structure definitions for the ModuleList stream and the associated parsing code. The rest of the code is converted to work with the definitions in llvm. NFC. llvm-svn: 358070
* Minidump: use string parsing functionality from llvmPavel Labath2019-04-091-57/+74
| | | | llvm-svn: 357977
* MinidumpParser: parse SystemInfo stream via llvmPavel Labath2019-04-081-3/+56
| | | | | | | I also update the tests for SystemInfo parsing to use the yaml2minidump capabilities in llvm instead of relying on checked-in binaries. llvm-svn: 357896
* MinidumpParser: use minidump parser in llvm/ObjectPavel Labath2019-04-054-22/+22
| | | | | | | | | | | | | | | | | | This patch removes the lower layers of the minidump parsing code from the MinidumpParser class, and replaces it with the minidump parser in llvm. Not all functionality is already avaiable in the llvm class, but it is enough for us to be able to stop enumerating streams manually, and rely on the minidump directory parsing code from the llvm class. This also removes some checked-in binaries which were used to test error handling in the parser, as the error handling is now done (and tested) in llvm. Instead I just add one test that ensures we correctly propagate the errors reported by the llvm parser. The input for this test can be written in yaml instead of a checked-in binary. llvm-svn: 357748
* Avoid two-stage initialization of MinidumpParserPavel Labath2019-02-222-70/+61
| | | | | | | | | remove the Initialize function, move the things that can fail into the static factory function. The factory function now returns Expected<Parser> instead of Optional<Parser> so that it can give a reason why creation failed. llvm-svn: 354668
* Split up minidump register context testsPavel Labath2019-02-223-123/+230
| | | | | | | | | | | | | | | | | The tests were doing two somewhat independent things: - checking that the registers can be retrieved from the minidump file - checking that they can be converted into a form suitable for consumption by lldb The first thing requires a minidump file (but it's independent of other lldb structures), while the second one does not require a minidump file (but it needs lldb register info structures). Splitting this into two tests gives an opportunity to write more detailed tests, and allows the two pieces of functionality to be moved into different packages, if that proves to be necessary. llvm-svn: 354662
* 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
* Fix signed-unsigned comparisons in MinidumpParserTestPavel Labath2018-12-281-5/+5
| | | | llvm-svn: 350122
* Add "dump" command as a custom "process plugin" subcommand when ↵Greg Clayton2018-12-181-0/+0
| | | | | | | | | | | | | | | | | ProcessMinidump is used. Each process plug-in can create its own custom commands. I figured it would be nice to be able to dump things from the minidump file from the lldb command line, so I added the start of the some custom commands. Currently you can dump: minidump stream directory all linux specifc streams, most of which are strings each linux stream individually if desired, or all with --linux The idea is we can expand the command set to dump more things, search for data in the core file, and much more. This patch gets us started. Differential Revision: https://reviews.llvm.org/D55727 llvm-svn: 349429
* Add missing .dmp files to test inputs.Greg Clayton2018-12-141-0/+3
| | | | llvm-svn: 349183
* Cache memory regions in ProcessMinidump and use the linux maps as the source ↵Greg Clayton2018-12-144-17/+109
| | | | | | | | | | | | | | | | | | | | | | | of the information if available Breakpad creates minidump files that sometimes have: - linux maps textual content - no MemoryInfoList Right now unless the file has a MemoryInfoList we get no region information. This patch: - reads and caches the memory region info one time and sorts it for easy subsequent access - get the region info from the best source in this order: - linux maps info (if available) - MemoryInfoList (if available) - MemoryList or Memory64List - returns memory region info for the gaps between regions (before the first and after the last) Differential Revision: https://reviews.llvm.org/D55522 llvm-svn: 349182
* Fix minidump unit test failures from r349062Pavel Labath2018-12-141-9/+12
| | | | | | | | | This commit added new test inputs, but it did not add them to the cmake files. This caused the test to fail at runtime. While in there, I also sorted the list of minidump test inputs. llvm-svn: 349154
* Fix MinidumpParser::GetFilteredModuleList() and test itGreg Clayton2018-12-133-0/+38
| | | | | | | | | | The MinidumpParser::GetFilteredModuleList() code was attempting to iterate through the entire module list and if it found more than one entry for a given module name, it wanted to pick the MinidumpModule with the lowest address. A bug existed where it wasn't doing that due to "exists" variable being inverted. "exists" was set to true if it was inserted, not if it existed. Furthermore, the order of the modules would be modified by sorting all modules from low address to high address (using MinidumpModule::base_of_image). This fix also maintains the original order which means your executable is at index 0 as intended instead of some random shared library. Tests were added to ensure this functionality doesn't regress. Differential Revision: https://reviews.llvm.org/D55614 llvm-svn: 349062
* Re-land "Extract construction of DataBufferLLVM into FileSystem"Jonas Devlieghere2018-11-121-4/+8
| | | | | | 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-8/+4
| | | | | | It broke the lldb sanitizer bots. llvm-svn: 346694
* Remove header grouping comments.Jonas Devlieghere2018-11-111-1/+0
| | | | | | | | This patch removes the comments grouping header includes. They were added after running IWYU over the LLDB codebase. However they add little value, are often outdates and burdensome to maintain. llvm-svn: 346626
* Extract construction of DataBufferLLVM into FileSystemJonas Devlieghere2018-11-101-4/+8
| | | | | | | | | | 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
* 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
* 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
* Fix memory leaks in MinidumpParserTestRaphael Isemann2018-01-221-6/+6
| | | | | | | | | | | | | | Summary: We never delete the allocated RegisterContext objects, causing those tests to fail with enabled memory sanitizer. Reviewers: dvlahovski, zturner Reviewed By: zturner Subscribers: zturner, lldb-commits Differential Revision: https://reviews.llvm.org/D42347 llvm-svn: 323085
* Move ArchSpec to the Utility modulePavel Labath2017-11-131-5/+3
| | | | | | | | | | | | | The rationale here is that ArchSpec is used throughout the codebase, including in places which should not depend on the rest of the code in the Core module. This commit touches many files, but most of it is just renaming of #include lines. In a couple of cases, I removed the #include ArchSpec line altogether, as the file was not using it. In one or two places, this necessitated adding other #includes like lldb-private-defines.h. llvm-svn: 318048
* cmake + xcode: prevent gtests from using includes from project rootTim Hammerquist2017-10-031-1/+1
| | | | | | | | | | | | | | | | | | | | | Summary: At present, several gtests in the lldb open source codebase are using #include statements rooted at $(SOURCE_ROOT)/${LLDB_PROJECT_ROOT}. This patch cleans up this directory/include structure for both CMake and Xcode build systems. rdar://problem/33835795 Reviewers: zturner, jingham, beanz Reviewed By: beanz Subscribers: emaste, lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D36598 llvm-svn: 314849
* [unittests] Add a helper function for getting an input filePavel Labath2017-06-292-13/+3
| | | | | | | | | | | | | | | | | Summary: Fetching an input file required about five lines of code, and this was repeated in multiple unit tests, with slight variations. Add a helper function for doing that into the lldbUtilityMocks module (which I rename to lldbUtilityHelpers to commemorate the fact it includes more than mocks) Reviewers: zturner, eugene Subscribers: emaste, mgorny, lldb-commits Differential Revision: https://reviews.llvm.org/D34683 llvm-svn: 306668
* Move FileSpec from Host -> Utility.Zachary Turner2017-03-221-1/+1
| | | | llvm-svn: 298536
* Remove FileSpec::ReadFileContents.Zachary Turner2017-03-061-1/+1
| | | | | | | | | | | | | | | | 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-2/+2
| | | | llvm-svn: 296943
* Fix MinidumpParserTest on 32-bit archesPavel Labath2017-02-271-2/+3
| | | | | | | | load_size should be 64-bit unconditionally to match the underlying API. This makes sure the MAX value correctly signals to auto-detect the file size when mmap()ing. llvm-svn: 296334
* Delete DataBufferMemoryMap.Zachary Turner2017-02-241-4/+6
| | | | | | | | | | | | | | | 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
* [CMake] Update unit tests with accurate dependenciesChris Bieneman2017-02-011-0/+9
| | | | | | This is extending the updates from r293696 to the LLDB unit tests. llvm-svn: 293821
* Minidump plugin: Adding ProcessMinidump, ThreadMinidump and register the ↵Dimitar Vlahovski2016-10-311-3/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | plugin in SystemInitializerFull Summary: This plugin resembles the already existing Windows-only Minidump plugin. The WinMinidumpPlugin uses the Windows API for parsing Minidumps while this plugin is cross-platform because it includes a Minidump parser (which is already commited) It is able to produce a backtrace, to read the general puprose regiters, inspect local variables, show image list, do memory reads, etc. For now the only arches that this supports are x86_32 and x86_64. This is because I have only written register contexts for those. Others will come in next CLs. I copied the WinMinidump tests and adapted them a little bit for them to work with the new plugin (and they pass) I will add more tests, aiming for better code coverage. There is still functionality to be added, see TODOs in code. Reviewers: labath, zturner Subscribers: beanz, mgorny, modocache, lldb-commits, amccarth Differential Revision: https://reviews.llvm.org/D25905 llvm-svn: 285587
* Minidump plugin: Adding x86_32 register context converterDimitar Vlahovski2016-10-313-34/+76
| | | | | | | | | | | | | | | | | Summary: This, like the x86_64 case, reads the register values from the minidump file, and emits a binary buffer that is ordered using the offsets from the RegisterInfoInterface argument. That way we can reuse an existing register context. Added unit tests. Reviewers: labath, zturner Subscribers: beanz, mgorny, modocache, amccarth, lldb-commits Differential Revision: https://reviews.llvm.org/D25832 llvm-svn: 285584
* Minidump plugin: functions parsing memory structures and filtering module listDimitar Vlahovski2016-10-194-2/+106
| | | | | | | | | | | | | | | | | | | | | | | | Summary: Now the Minidump parser can parse the: 1) MemoryInfoList - containing region info about memory ranges (readable, writable, executable) 2) Memory64List - this is the stuct used when the Minidump is a full-memory one. 3) Adding filtering of the module list (shared libraries list) - there can be mutliple records in the module list under the same name but with different load address (e.g. when the binary has non contigious sections). FilterModuleList eliminates the duplicated modules, leaving the one with the lowest load addr. Added unit tests for everything. Reviewers: labath, zturner Subscribers: beanz, mgorny, modocache, lldb-commits, amccarth Differential Revision: https://reviews.llvm.org/D25569 llvm-svn: 284593
* Removing the new Minidump pluginDimitar Vlahovski2016-10-051-23/+3
| | | | | | | | | | | | | | | | | | | | | | | Tests are failing and build is failing on windows and darwin. Will fix and commit it later ------------------------------------------------------------- Revert "xfailing minidump tests again ... :(" This reverts commit 97eade002c9e43c1e0d11475a4888083a8965044. Revert "Fixing new Minidump plugin tests" This reverts commit 0dd93b3ab39c8288696001dd50b9a093b813b09c. Revert "Add the new minidump files to the Xcode project." This reverts commit 2f638a1d046b8a88e61e212220edc40aecd2ce44. Revert "xfailing tests for Minidump plugin" This reverts commit 99311c0b22338a83e6a00c4fbddfd3577914c003. Revert "Adding a new Minidump post-mortem debugging plugin" This reverts commit b09a7e4dae231663095a84dac4be3da00b03a021. llvm-svn: 283352
* Adding a new Minidump post-mortem debugging pluginDimitar Vlahovski2016-10-041-3/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This plugin resembles the already existing Windows-only Minidump plugin. The WinMinidumpPlugin uses the Windows API for parsing Minidumps while this plugin is cross-platform because it includes a Minidump parser (which is already commited) It is able to produce a backtrace, to read the general puprose regiters, inspect local variables, show image list, do memory reads, etc. For now the only arch that this supports is x86 64 bit This is because I have only written a register context for that arch. Others will come in next CLs. I copied the WinMinidump tests and adapted them a little bit for them to work with the new plugin (and they pass) I will add more tests, aiming for better code coverage. There is still functionality to be added, see TODOs in code. Reviewers: labath, zturner Subscribers: beanz, mgorny, amccarth, lldb-commits, modocache Differential Revision: https://reviews.llvm.org/D25196 llvm-svn: 283259
* Adding a RegisterContextMinidump_x86_64 converterDimitar Vlahovski2016-09-271-1/+62
| | | | | | | | | | | | | | | | | | Summary: This is a register context converter from Minidump to Linux reg context. This knows the layout of the register context in the Minidump file (which is the same as in Windows FYI) and as a result emits a binary data buffer that matches the Linux register context binary layout. This way we can reuse the existing RegisterContextLinux_x86_64 and RegisterContextCorePOSIX_x86_64 classes. Reviewers: labath, zturner Subscribers: beanz, mgorny, lldb-commits, amccarth Differential Revision: https://reviews.llvm.org/D24919 llvm-svn: 282529
* MinidumpParsing: pid, modules, exceptions, stringsDimitar Vlahovski2016-09-133-10/+89
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Added parsing of the MiscInfo data stream. The main member of it that we care about is the process_id On Linux generated Minidump (from breakpad) we don't have the MiscInfo, we have the /proc/$pid/status from where we can get the pid. Also parsing the module list - the list of all of the loaded modules/shared libraries. Parsing the exception stream. Parsing MinidumpStrings. I have unit tests for all of that. Also added some tests using a Minidump generated from Windows tools (not from breakpad) Reviewers: labath, zturner Subscribers: beanz, lldb-commits Differential Revision: https://reviews.llvm.org/D24385 llvm-svn: 281348
OpenPOWER on IntegriCloud