aboutsummaryrefslogtreecommitdiff
path: root/lldb/unittests/ObjectFile
AgeCommit message (Collapse)AuthorFilesLines
2026-02-05[lldb] Add a new way of loading files from a shared cache (#179881)Jason Molenda2-6/+14
Taking advantage of a few new SPI in macOS 26.4 libdyld, it is possible for lldb to load binaries out of a shared cache binary blob, instead of needing discrete files on disk. lldb has had one special case where it has done this for years -- if the debugee process and lldb itself are using the same shared cache, it could create ObjectFiles based on its own memory contents. This new method requires only the shared cache on disk, not depending on it being mapped into lldb's address space already. In HostInfoMacOSX.mm, we create an array of binaries in lldb's shared cache, by one of two methods depending on the availability of SPI/SDKs. This PR adds a new third method for loading lldb's shared cache off disk as a proof of concept. It will prefer this new method when the needed SPI are available at runtime. There is also a user setting to disable this new method in case we uncover a problem as it is deployed. I did change the internal store of the shared cache files from a single array, to being organized by shared cache UUIDs, so we can have multiple shared caches indexed in the future. In HostInfoBase.h's SharedCacheImageInfo class, you can now create an ImageInfo with a DataExtractorSP or a void* baton. I added GetUUID and GetExtractor methods, and the latter will use the libdyld SPI to map the segments for a specific binary into lldb's memory and return a DataExtractorSP. The setting is currently called symbols.shared-cache-binary-loading. In DynamicLoaderDarwin::FindTargetModuleForImageInfo there was an ordering mistake where we would always consult the HostInfoMacOSX.mm shared cache provider, instead of checking lldb's own global module cache first when looking for a binary, resulting in creating a new Module repeatedly for shared cache binaries with the new method, parsing the symbol table repeatedly. I fixed the ordering so we look at existing Modules before we check the shared cache for one. In ObjectFileMachOTest, it tests a TEXT and a DATA symbol, checking that the contents of the function/data object match the bytes we got from the shared cache. The test was using a DATA_DIRTY symbol, which was fine when using lldb's own shared cache memory, but when we worked on the shared cache binary on-disk directly, we were seeing different values for the bytes because of relocations in there. I changed this to a constant DATA symbol. rdar://148939795 --------- Co-authored-by: Jonas Devlieghere <jonas@devlieghere.com> Co-authored-by: Alex Langford <nirvashtzero@gmail.com>
2026-01-29[lldb][NFC] Module, ModuleSpec, GetSectionData use DataExtractorSP (#178347)Jason Molenda1-3/+3
In a PR last month I changed the ObjectFile CreateInstance etc methods to accept an optional DataExtractorSP instead of a DataBufferSP, and retain the extractor in a shared pointer internally in all of the ObjectFile subclasses. This is laying the groundwork for using a VirtualDataExtractor for some Mach-O binaries on macOS, where the segments of the binary are out-of-order in actual memory, and we add a lookup table to make it appear that the TEXT segment is at offset 0 in the Extractor, etc. Working on the actual implementation, I realized we were still using DataBufferSP's in ModuleSpec and Module, as well as in ObjectFile::GetModuleSpecifications. I originally was making a much larger NFC change where I had all ObjectFile subclasses operating on DataExtractors throughout their implementation, as well as in the DWARF parser. It was a very large patchset. Many subclasses start with their DataExtractor, then create smaller DataExtractors for parts of the binary image - the string table, the symbol table, etc., for processing. After consideration and discussion with Jonas, we agreed that a segment/section of a binary will never require a lookup table to access the bytes within it, so I changed VirtualDataExtractor::GetSubsetExtractorSP to (1) require that the Subset be contained within a single lookup table entry, and (2) return a simple DataExtractor bounded on that byte range. By doing this, I was able to remove all of my very-invasive changes to the ObjectFile subclass internals; it's only when they are operating on the entire binary image that care is needed. One pattern that subclasses like ObjectFileBreakpad use is to take an ArrayRef of the DataBuffer for a binary, then create a StringRef of that, then look for strings in it. With a VirtualDataExtractor and out-of-order binary segments, with gaps between them, this allows us to search the entire buffer looking for a string, and segfault when it gets to an unmapped region of the buffer. I added a VirtualDataExtractor::GetSubsetExtractorSP(0) which gets the largest contiguous memory region starting at offset 0 for this use case, and I added a comment about what was being done there because I know it is not obvious, and people not working on macOS wouldn't be familiar with the requirement. (when we have a ModuleSpec with a DataExtractor, any of the ObjectFile subclasses get a shot at Creating, so they all have to be able to iterate on these) rdar://148939795
2026-01-27[lldb][NFC] Mark Symbol pointers as const where easily possible (#177472)Alex Langford1-1/+1
These are the places that required no modifications to surrounding code.
2025-08-27[LLDB] Omit loading local symbols in LLDB symbol table (#154809)barsolo20001-0/+81
https://discourse.llvm.org/t/rfc-should-we-omit-local-symbols-in-eekciihgtfvflvnbieicunjlrtnufhuelf-files-from-the-lldb-symbol-table/87384 Improving symbolication by excluding local symbols that are typically not useful for debugging or symbol lookups. This aligns with the discussion that local symbols, especially those with STB_LOCAL binding and STT_NOTYPE type (including .L-prefixed symbols), often interfere with symbol resolution and can be safely omitted. --------- Co-authored-by: Bar Soloveychik <barsolo@fb.com>
2025-06-05Revert "[lldb] Set default object format to `MachO` in `ObjectFileMachO` ↵Jason Molenda1-55/+0
(#142704)" This reverts commit d4d2f069dec4fb8b13447f52752d4ecd08d976d6. Temporarily reverting until we can find a way to get the correct ObjectFile set in Module's Triples without adding "-macho" to the triple string for each Module. This is breaking TestUniversal.py on the x86_64 macOS CI bots.
2025-06-04[lldb] Set default object format to `MachO` in `ObjectFileMachO` (#142704)royitaqi1-0/+55
# The Change This patch sets the **default** object format of `ObjectFileMachO` to be `MachO` (instead of what currently ends up to be `ELF`, see below). This should be **the correct thing to do**, because the code before the line of change has already verified the Mach-O header. The existing logic: * In `ObjectFileMachO`, the object format is unassigned by default. So it's `UnknownObjectFormat` (see [code](https://github.com/llvm/llvm-project/blob/54d544b83141dc0b20727673f68793728ed54793/llvm/lib/TargetParser/Triple.cpp#L1024)). * The code then looks at load commands like `LC_VERSION_MIN_*` ([code](https://github.com/llvm/llvm-project/blob/54d544b83141dc0b20727673f68793728ed54793/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp#L5180-L5217)) and `LC_BUILD_VERSION` ([code](https://github.com/llvm/llvm-project/blob/54d544b83141dc0b20727673f68793728ed54793/lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp#L5231-L5252)) and assign the Triple's OS and Environment if they exist. * If the above sets the Triple's OS to macOS, then the object format defaults to `MachO`; otherwise it is `ELF` ([code](https://github.com/llvm/llvm-project/blob/54d544b83141dc0b20727673f68793728ed54793/llvm/lib/TargetParser/Triple.cpp#L936-L937)) # Impact For **production usage** where Mach-O files have the said load commands (which is [expected](https://www.google.com/search?q=Are+mach-o+files+expected+to+have+the+LC_BUILD_VERSION+load+command%3F)), this patch won't change anything. * **Important note**: It's not clear if there are legitimate production use cases where the Mach-O files don't have said load commands. If there is, the exiting code think they are `ELF`. This patch changes it to `MachO`. This is considered a fix for such files. For **unit tests**, this patch will simplify the yaml data by not requiring the said load commands. # Test See PR.
2025-05-22[lldb] Disable some unwind plans for discontinuous functions (#140927)Pavel Labath1-16/+28
Basically, disable everything except the eh_frame unwind plan, as that's the only one which supports this right now. The other plans are working with now trying the interpret everything in between the function parts as a part of the function, which is more likely to produce wrong results than correct ones. I changed the interface for object file plans, to give the implementations a chance to implement this correctly, but I haven't actually converted PECallFrameInfo (its only implementation) to handle that. (from the looks of things, it should be relatively easy to do, if it becomes necessary) I'm also deleting UnwindPlan::GetFirstNonPrologueInsn, as it's not used, and it doesn't work for discontinuous functions.
2023-08-05[lldb] Fix -Wsign-compare in TestSectionSize.cpp (NFC)Jie Fu1-2/+2
In file included from /data/workspace/llvm-project/lldb/unittests/ObjectFile/PECOFF/TestSectionSize.cpp:10: /data/workspace/llvm-project/third-party/unittest/googletest/include/gtest/gtest.h:1620:28: error: comparison of integers of different signs: 'c onst unsigned long' and 'const int' [-Werror,-Wsign-compare] GTEST_IMPL_CMP_HELPER_(NE, !=); ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~
2023-08-04[lldb][PECOFF] Exclude alignment padding when reading section dataHiroshi Yamauchi2-0/+79
There can be zero padding bytes at a section end for file alignment in PECOFF. Exclude those padding bytes when reading the section data. Differential Revision: https://reviews.llvm.org/D157059
2023-06-20[lldb][ObjectFileELF] Set ModuleSpec file offset and sizeKazuki Sakamoto4-0/+35
In Android API level 23 and above, dynamic loader is able to load .so file directly from APK. https://android.googlesource.com/platform/bionic/+/master/ android-changes-for-ndk-developers.md# opening-shared-libraries-directly-from-an-apk ObjectFileELF::GetModuleSpecifications will load a .so file, which is page aligned and uncompressed, directly from a zip file. However it does not set the .so file offset and size to the ModuleSpec. Also crc32 calculation uses more data than the .so file size. Set the .so file offset and size to the ModuleSpec, and set the size to MapFileData length argument. For normal file, file_offset should be zero, and length should be the size of the file. Differential Revision: https://reviews.llvm.org/D152757
2022-12-05Remove unused #include "llvm/ADT/Optional.h"Fangrui Song1-1/+0
2022-12-04[lldb/unittests] Use std::nullopt instead of None (NFC)Kazu Hirata1-65/+66
This patch mechanically replaces None with std::nullopt where the compiler would warn if None were deprecated. The intent is to reduce the amount of manual work required in migrating from Optional to std::optional. This is part of an effort to migrate from llvm::Optional to std::optional: https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-08-30Change the meaning of a UUID with all zeros for data.Jim Ingham1-2/+2
Previously, depending on how you constructed a UUID from data or a StringRef, an input value of all zeros was valid (e.g. setFromData) or not (e.g. setFromOptionalData). Since there was no way to tell which interpretation to use, it was done somewhat inconsistently. This standardizes the meaning of a UUID of all zeros to Not Valid, and removes all the Optional methods and their uses, as well as the static factories that supported them. Differential Revision: https://reviews.llvm.org/D132191
2022-03-23[lldb] Test parsing the symtab with indirect symbols from the shared cacheJonas Devlieghere1-0/+18
This patch adds a test for b0dc2fae6025. That commit fixed a bug where we could increment the indirect symbol offset every time we parsed the symbol table.
2021-11-10[LLDB][Breakpad] Make lldb understand INLINE and INLINE_ORIGIN records in ↵Zequan Wu1-0/+23
breakpad. Teach LLDB to understand INLINE and INLINE_ORIGIN records in breakpad. They have the following formats: ``` INLINE inline_nest_level call_site_line call_site_file_num origin_num [address size]+ INLINE_ORIGIN origin_num name ``` `INLNIE_ORIGIN` is simply a string pool for INLINE so that we won't have duplicated names for inlined functions and can show up anywhere in the symbol file. `INLINE` follows immediately after `FUNC` represents the ranges of momery address that has functions inlined inside the function. Differential Revision: https://reviews.llvm.org/D113330
2020-07-16[lldb/ObjectFileMachO] Fetch shared cache images from our own shared cacheFred Riss3-0/+90
Summary: On macOS 11, the libraries that have been integrated in the system shared cache are not present on the filesystem anymore. LLDB was using those files to get access to the symbols of those libraries. LLDB can get the images from the target process memory though. This has 2 consequences: - LLDB cannot load the images before the process starts, reporting an error if someone tries to break on a system symbol. - Loading the symbols by downloading the data from the inferior is super slow. It takes tens of seconds at the start of the debug session to populate the Module list. To fix this, we can use the library images LLDB has in its own mapping of the shared cache. Shared cache images are somewhat special as their LINKEDIT segment is moved to the end of the cache and thus the images are not contiguous in memory. All of this can hidden in ObjectFileMachO. This patch fixes a number of test failures on macOS 11 due to the first problem described above and adds some specific unittesting for the new SharedCache Host utilities. Reviewers: jasonmolenda, labath Subscribers: llvm-commits, lldb-commits Tags: #lldb, #llvm Differential Revision: https://reviews.llvm.org/D83023
2020-07-14[lldb/Module] Allow for the creation of memory-only modulesFred Riss2-13/+4
Summary: This patch extends the ModuleSpec class to include a DataBufferSP which contains the module data. If this data is provided, LLDB won't try to hit the filesystem to create the Module, but use only the data stored in the ModuleSpec. Reviewers: labath, espindola Subscribers: emaste, MaskRay, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D83512
2020-06-07Support build-ids of other sizes than 16 in UUID::SetFromStringRefJaroslav Sevcik1-2/+2
SBTarget::AddModule currently handles the UUID parameter in a very weird way: UUIDs with more than 16 bytes are trimmed to 16 bytes. On the other hand, shorter-than-16-bytes UUIDs are completely ignored. In this patch, we change the parsing code to handle UUIDs of arbitrary size. To support arbitrary size UUIDs in SBTarget::AddModule, this patch changes UUID::SetFromStringRef to parse UUIDs of arbitrary length. We subtly change the semantics of SetFromStringRef - SetFromStringRef now only succeeds if the entire input is consumed to prevent some prefix-parsing confusion. This is up for discussion, but I believe this is more consistent - we always return false for invalid UUIDs rather than sometimes truncating to a valid prefix. Also, all the call-sites except the API and interpreter seem to expect to consume the entire input. This also adds tests for adding existing modules 4-, 16-, and 20-byte build-ids. Finally, we took the liberty of testing the minidump scenario we care about - removing placeholder module from minidump and replacing it with the real module. Reviewed By: labath, friss Differential Revision: https://reviews.llvm.org/D80755
2020-01-24[lldb][NFC] Fix all formatting errors in .cpp file headersRaphael Isemann3-20/+20
Summary: A *.cpp file header in LLDB (and in LLDB) should like this: ``` //===-- TestUtilities.cpp -------------------------------------------------===// ``` However in LLDB most of our source files have arbitrary changes to this format and these changes are spreading through LLDB as folks usually just use the existing source files as templates for their new files (most notably the unnecessary editor language indicator `-*- C++ -*-` is spreading and in every review someone is pointing out that this is wrong, resulting in people pointing out that this is done in the same way in other files). This patch removes most of these inconsistencies including the editor language indicators, all the different missing/additional '-' characters, files that center the file name, missing trailing `===//` (mostly caused by clang-format breaking the line). Reviewers: aprantl, espindola, jfb, shafik, JDevlieghere Reviewed By: JDevlieghere Subscribers: dexonsmith, wuzish, emaste, sdardis, nemanjai, kbarton, MaskRay, atanasyan, arphaman, jfb, abidh, jsji, JDevlieghere, usaxena95, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D73258
2019-12-23[lldb] Add a SubsystemRAII that takes care of calling Initialize and ↵Raphael Isemann2-26/+5
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
2019-10-11[Windows] Use information from the PE32 exceptions directory to construct ↵Aleksandr Urakov3-0/+345
unwind plans This patch adds an implementation of unwinding using PE EH info. It allows to get almost ideal call stacks on 64-bit Windows systems (except some epilogue cases, but I believe that they can be fixed with unwind plan disassembly augmentation in the future). To achieve the goal the CallFrameInfo abstraction was made. It is based on the DWARFCallFrameInfo class interface with a few changes to make it less DWARF-specific. To implement the new interface for PECOFF object files the class PECallFrameInfo was written. It uses the next helper classes: - UnwindCodesIterator helps to iterate through UnwindCode structures (and processes chained infos transparently); - EHProgramBuilder with the use of UnwindCodesIterator constructs EHProgram; - EHProgram is, by fact, a vector of EHInstructions. It creates an abstraction over the low-level unwind codes and simplifies work with them. It contains only the information that is relevant to unwinding in the unified form. Also the required unwind codes are read from the object file only once with it; - EHProgramRange allows to take a range of EHProgram and to build an unwind row for it. So, PECallFrameInfo builds the EHProgram with EHProgramBuilder, takes the ranges corresponding to every offset in prologue and builds the rows of the resulted unwind plan. The resulted plan covers the whole range of the function except the epilogue. Reviewers: jasonmolenda, asmith, amccarth, clayborg, JDevlieghere, stella.stamenova, labath, espindola Reviewed By: jasonmolenda Subscribers: leonid.mashinskiy, emaste, mgorny, aprantl, arichardson, MaskRay, lldb-commits, llvm-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D67347 llvm-svn: 374528
2019-10-08Explicitly set entry point arch when it's thumb [Second Try]Antonio Afonso1-0/+126
Summary: This is a redo of D68069 because I reverted it due to some concerns that were now addressed along with the new comments that @labath added. I found a case where the main android binary (app_process32) had thumb code at its entry point but no entry in the symbol table indicating this. This made lldb set a 4 byte breakpoint at that address (we default to arm code) instead of a 2 byte one (like we should for thumb). The big deal with this is that the expression evaluator uses the entry point as a way to know when a JITed expression has finished executing by putting a breakpoint there. Because of this, evaluating expressions on certain android devices (Google Pixel something) made the process crash. This was fixed by checking this specific situation when we parse the symbol table and add an artificial symbol for this 2 byte range and indicating that it's arm thumb. I created 2 unit tests for this, one to check that now we know that the entry point is arm thumb, and the other to make sure we didn't change the behaviour for arm code. I also run the following on the command line with the `app_process32` where I found the issue: **Before:** ``` (lldb) dis -s 0x1640 -e 0x1644 app_process32[0x1640]: .long 0xf0004668 ; unknown opcode ``` **After:** ``` (lldb) dis -s 0x1640 -e 0x1644 app_process32`: app_process32[0x1640] <+0>: mov r0, sp app_process32[0x1642]: andeq r0, r0, r0 ``` Reviewers: clayborg, labath, wallace, espindola Reviewed By: labath Subscribers: labath, lldb-commits, MaskRay, kristof.beyls, arichardson, emaste, srhines Tags: #lldb Differential Revision: https://reviews.llvm.org/D68533 llvm-svn: 374132
2019-10-04Revert "Explicitly set entry point arch when it's thumb"Antonio Afonso1-126/+0
Backing out because SymbolFile/Breakpad/symtab.test is failing and it seems to be a legit issue. Will investigate. This reverts commit 72153f95ee4c1b52d2f4f483f0ea4f650ec863be. llvm-svn: 373687
2019-10-04Explicitly set entry point arch when it's thumbAntonio Afonso1-0/+126
Summary: I found a case where the main android binary (app_process32) had thumb code at its entry point but no entry in the symbol table indicating this. This made lldb set a 4 byte breakpoint at that address (we default to arm code) instead of a 2 byte one (like we should for thumb). The big deal with this is that the expression evaluator uses the entry point as a way to know when a JITed expression has finished executing by putting a breakpoint there. Because of this, evaluating expressions on certain android devices (Google Pixel something) made the process crash. This was fixed by checking this specific situation when we parse the symbol table and add an artificial symbol for this 2 byte range and indicating that it's arm thumb. I created 2 unit tests for this, one to check that now we know that the entry point is arm thumb, and the other to make sure we didn't change the behaviour for arm code. I also run the following on the command line with the `app_process32` where I found the issue: **Before:** ``` (lldb) dis -s 0x1640 -e 0x1644 app_process32[0x1640]: .long 0xf0004668 ; unknown opcode ``` **After:** ``` (lldb) dis -s 0x1640 -e 0x1644 app_process32`: app_process32[0x1640] <+0>: mov r0, sp app_process32[0x1642]: andeq r0, r0, r0 ``` Reviewers: clayborg, labath, wallace, espindola Subscribers: srhines, emaste, arichardson, kristof.beyls, MaskRay, lldb-commits Tags: #lldb Differential Revision: https://reviews.llvm.org/D68069 llvm-svn: 373680
2019-08-26Breakpad: Add support for parsing STACK WIN recordsPavel Labath1-0/+32
Summary: The fields that aren't useful for us right now are simply ignored. Reviewers: amccarth, markmentovai Subscribers: rnk, lldb-commits Differential Revision: https://reviews.llvm.org/D66633 llvm-svn: 369892
2019-08-20unittests: Use yaml2obj as a library instead of an external processPavel Labath3-62/+58
Summary: Recently, yaml2obj has been turned into a library. This means we can use it from our unit tests directly, instead of shelling out to an external process. This patch does just that. Reviewers: JDevlieghere, aadsm, espindola, jdoerfert Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits Differential Revision: https://reviews.llvm.org/D65949 llvm-svn: 369374
2019-08-08ObjectFileELF: Convert a unit test to a lit testPavel Labath3-242/+0
It is much easier to test this functionality via lldb-test. llvm-svn: 368289
2019-07-26SymbolVendor: Move Symtab construction into the SymbolFilePavel Labath2-4/+4
Summary: Instead of having SymbolVendor coordinate Symtab construction between Symbol and Object files, make the SymbolVendor function a passthrough, and put all of the logic into the SymbolFile. Reviewers: clayborg, JDevlieghere, jingham, espindola Subscribers: emaste, mgorny, arichardson, MaskRay, lldb-commits Differential Revision: https://reviews.llvm.org/D65208 llvm-svn: 367086
2019-05-06Include inlined functions when figuring out a contiguous address rangeGreg Clayton2-36/+7
Checking this in for Antonio Afonso: This diff changes the function LineEntry::GetSameLineContiguousAddressRange so that it also includes function calls that were inlined at the same line of code. My motivation is to decrease the step over time of lines that heavly rely on inlined functions. I have multiple examples in the code base I work that makes a step over stop 20 or mote times internally. This can easly had up to step overs that take >500ms which I was able to lower to 25ms with this new strategy. The reason the current code is not extending the address range beyond an inlined function is because when we resolve the symbol at the next address of the line entry we will get the entry line corresponding to where the original code for the inline function lives, making us barely extend the range. This then will end up on a step over having to stop multiple times everytime there's an inlined function. To check if the range is an inlined function at that line I also get the block associated with the next address and check if there is a parent block with a call site at the line we're trying to extend. To check this I created a new function in Block called GetContainingInlinedBlockWithCallSite that does exactly that. I also added a new function to Declaration for convinence of checking file/line named CompareFileAndLine. To avoid potential issues when extending an address range I added an Extend function that extends the range by the AddressRange given as an argument. This function returns true to indicate sucess when the rage was agumented, false otherwise (e.g.: the ranges are not connected). The reason I do is to make sure that we're not just blindly extending complete_line_range by whatever GetByteSize() we got. If for some reason the ranges are not connected or overlap, or even 0, this could be an issue. I also added a unit tests for this change and include the instructions on the test itself on how to generate the yaml file I use for testing. Differential Revision: https://reviews.llvm.org/D61292 llvm-svn: 360071
2019-04-16Breakpad: Match the new UUID algorithm in minidumpsPavel Labath1-1/+1
D59433 and D60501 changed the way UUIDs are computed from minidump files. This was done to synchronize the U(G)UID representation with the native tools of given platforms, but it created a mismatch between minidumps and breakpad files. This updates the breakpad algorithm to match the one found in minidumps, and also adds a couple of tests which should fail if these two ever get out of sync. Incidentally, this means that the module id in the breakpad files is almost identical to our notion of UUIDs, so the computation algorithm can be somewhat simplified. llvm-svn: 358500
2019-04-09Breakpad: Parse Stack CFI recordsPavel Labath1-1/+23
Summary: This patch adds support for parsing STACK CFI records from breakpad files. The expressions specifying the values of registers are not parsed.The idea is that these will be handed off to the postfix expression -> dwarf compiler, once it is extracted from the internals of the NativePDB plugin. Reviewers: clayborg, amccarth, markmentovai Subscribers: aprantl, lldb-commits Differential Revision: https://reviews.llvm.org/D60268 llvm-svn: 357975
2019-04-04Breakpad: Refine record classification codePavel Labath1-2/+7
Previously we would classify all STACK records into a single bucket. This is not really helpful, because there are three distinct types of records beginning with the token "STACK" (STACK CFI INIT, STACK CFI, STACK WIN). To be consistent with how we're treating other records, we should classify these as three different record types. It also implements the logic to put "STACK CFI INIT" and "STACK CFI" records into the same "section" of the breakpad file, as they are meant to be read together (similar to how FUNC and LINE records are treated). The code which performs actual parsing of these records will come in a separate patch. llvm-svn: 357691
2019-04-03[LLDB] - Update the test cases after yaml2obj change.George Rimar2-62/+63
https://reviews.llvm.org/D60122 (r357595) changed the symbols description format in yaml2obj. This change updates the LLDB tests. llvm-svn: 357600
2019-01-29BreakpadRecords: Add parsing code for FILE and LINE recordsPavel Labath1-0/+16
The two records aren't used by anything yet, but this part can be separated out easily, so I am comitting it separately to simplify reviews of the followup patch. llvm-svn: 352507
2019-01-22breakpad: Add FUNC records to the symtabPavel Labath1-0/+15
This patch extends SymbolFileBreakpad::AddSymbols to include the symbols from the FUNC records too. These symbols come from the debug info and have a size associated with them, so they are given preference in case there is a PUBLIC record for the same address. To achieve this, I first pre-process the symbols into a temporary DenseMap, and then insert the uniqued symbols into the module's symtab. Reviewers: clayborg, lemo, zturner Reviewed By: clayborg Subscribers: lldb-commits Differential Revision: https://reviews.llvm.org/D56590 llvm-svn: 351781
2019-01-19Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2-8/+6
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
2019-01-18Breakpad: Extract parsing code into a separate filePavel Labath3-0/+71
Summary: This centralizes parsing of breakpad records, which was previously spread out over ObjectFileBreakpad and SymbolFileBreakpad. For each record type X there is a separate breakpad::XRecord class, and an associated parse function. The classes just store the information in the breakpad records in a more accessible form. It is up to the users to determine what to do with that data. This separation also made it possible to write some targeted tests for the parsing code, which was previously unaccessible, so I write a couple of those too. Reviewers: clayborg, lemo, zturner Reviewed By: clayborg Subscribers: mgorny, fedor.sergeev, lldb-commits Differential Revision: https://reviews.llvm.org/D56844 llvm-svn: 351541
2018-11-06[ObjectFile] Prefer reinterpret_cast<>Davide Italiano1-2/+2
llvm-svn: 346247
2018-11-06[ObjectFileELF] Fix misaligned read/writes caught by UBSan.Davide Italiano1-13/+20
llvm-svn: 346244
2018-11-05Add a relocation to ObjectFileELF::ApplyRelocations and a testNathan Lanza3-0/+246
Summary: pcm files can end up being processed by lldb with relocations to be made for the .debug_info section. When a R_AARCH64_ABS64 relocation was required lldb would hit an `assert(false)` and die. Add R_AARCH64_ABS64 relocations to the S+A 64 bit width code path. Add a test for R_AARCH64_ABS64 and R_AARCH64_ABS32 .rela.debug_info relocations in a pcm file. Reviewers: sas, xiaobai, davide, javed.absar, espindola Reviewed By: davide Subscribers: labath, zturner, emaste, mgorny, arichardson, kristof.beyls Differential Revision: https://reviews.llvm.org/D51566 llvm-svn: 346171
2018-11-01[FileSystem] Move path resolution logic out of FileSpecJonas Devlieghere1-3/+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
2018-10-31[FileSystem] Extend file system and have it use the VFS.Jonas Devlieghere1-0/+3
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
2018-07-19ELF: Replace the header-extension unit test with a lit onePavel Labath2-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
2018-06-13[FileSpec] Make style argument mandatory for SetFile. NFCJonas Devlieghere1-1/+1
Update SetFile uses in the unittests. llvm-svn: 334668
2018-06-12Refactor ExecuteAndWait to take StringRefs.Zachary Turner1-2/+3
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
2018-02-05Add a comment explaining how the input for ↵Pavel Labath2-0/+25
GetModuleSpecifications_EarlySectionHeaders was generated Davide pointed out this would be useful if the file ever needs to be regenerated (and I certainly agree). I also replace the test binary with a slightly smaller one -- I intended to do this in the original commit, but I forgot to add it to the patch as I was juggling several things at the same time. llvm-svn: 324256
2018-02-05Fix parsing of object files with "early" section headersPavel Labath3-0/+15
ObjectFileELF::GetModuleSpecifications contained a lot of tip-toing code which was trying to avoid loading the full object file into memory. It did this by trying to load data only up to the offset if was accessing. However, in practice this was useless, as 99% of object files we encounter have section headers at the end, so we would load the whole file as soon as we start parsing the section headers. In fact, this would break as soon as we encounter a file which does *not* have section headers at the end (yaml2obj produces these), as the access to .strtab (which we need to get the section names) was not guarded by this offset check. As this strategy was completely ineffective anyway, I do not attempt to proliferate it further by guarding the .strtab accesses. Instead I just lead the full file as soon as we are reasonably sure that we are indeed processing an elf file. If we really care about the load size here, we would need to reimplement this to just load the bits of the object file we need, instead of loading everything from the start of the object file to the given offset. However, given that the OS will do this for us for free when using mmap, I think think this is really necessary. For testing this I check a (tiny) SO file instead of yaml2obj-ing it because the fact that they come out first is an implementation detail of yaml2obj that can change in the future. llvm-svn: 324254
2017-12-15ObjectFileELF: Add support for compressed sectionsPavel Labath1-1/+2
Summary: We use the llvm decompressor to decompress SHF_COMPRESSED sections. This enables us to read data from debug info sections, which are sometimes compressed, particuarly in the split-dwarf case. This functionality is only available if llvm is compiled with zlib support. Reviewers: clayborg, zturner Subscribers: emaste, mgorny, aprantl, lldb-commits Differential Revision: https://reviews.llvm.org/D40616 llvm-svn: 320813
2017-10-03cmake + xcode: prevent gtests from using includes from project rootTim Hammerquist1-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
2017-09-13[unittests] Speculative fix for changes introduced in rL313156Vedant Kumar1-1/+3
llvm-svn: 313181