summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo
Commit message (Collapse)AuthorAgeFilesLines
...
* [Debuginfo][COFF] Minimal serialization support for precompiled types recordsAlexandre Ganea2018-04-093-1360/+1400
| | | | | | | | | | | | | This change adds support for the LF_PRECOMP and LF_ENDPRECOMP records required to read/write Microsoft precompiled types .objs. See https://en.wikipedia.org/wiki/Precompiled_header#Microsoft_Visual_C_and_C++ This also adds handling for the .debug$P section, which is actually a .debug$T section in disguise, found only in precompiled .objs. Differential Revision: https://reviews.llvm.org/D45283 llvm-svn: 329613
* [NFC] fix trivial typos in comments and error messageHiroshi Inoue2018-04-091-1/+1
| | | | | | "is is" -> "is", "are are" -> "are" llvm-svn: 329546
* DWARFVerifier: validate information in name index entriesPavel Labath2018-04-062-3/+129
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch add checks to verify that the information in the name index entries is consistent with the debug_info section. Specifically, we check that entries point to valid DIEs, and their names, tags, and compile units match the information in the debug_info sections. These checks are only run if the previous checks did not find any errors in the name index headers. Attempting to proceed with the checks anyway would likely produce a lot of spurious errors and the verification code would need to be very careful to avoid crashing. I also add a couple of more checks to the abbreviation-validation code to verify that some attributes are always present (an index without a DW_IDX_die_offset attribute is fairly useless). The entry verification works only on indexes without any type units - I haven't attempted to extend it to type units, as we don't even have a DWARF v5-compatible type unit generator at the moment. Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45323 llvm-svn: 329392
* [debug_loc] Fix typo in DWARFExpression constructorPavel Labath2018-04-062-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The positions of the DwarfVersion and AddressSize arguments were reversed, which caused parsing for dwarf opcodes which contained address-size-dependent operands (such as DW_OP_addr). Amusingly enough, none of the address-size asserts fired, as dwarf version was always 4, which is a valid address size. I ran into this when constructing weird inputs for the DWARF verifier. I I add a test case as hand-written dwarf -- I am not sure how to trigger this differently, as having a DW_OP_addr inside a location list is a fairly non-standard thing to do. Fixing this error exposed a bug in the debug_loc.dwo parser, which was always being constructed with an address size of 0. I fix that as well by following the pattern in the non-dwo parser of picking up the address size from the first compile unit (which is technically not correct, but probably good enough in practice). Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D45324 llvm-svn: 329381
* [DWARF v5][NFC]: Refactor DebugRnglists to prepare for the support of the ↵Wolfgang Pieb2018-04-052-99/+128
| | | | | | | | | | | | DW_AT_ranges attribute in conjunction with .debug_rnglists. Reviewers: JDevlieghere Differential Revision: https://reviews.llvm.org/D45307 llvm-svn: 329345
* [llvm-pdbutil] Add the ability to explain binary files.Zachary Turner2018-04-043-14/+20
| | | | | | | | | | Using this, you can use llvm-pdbutil to export the contents of a stream to a binary file, then run explain on the binary file so that it treats the offset as an offset into the stream instead of an offset into a file. This makes it easy to compare the contents of the same stream from two different files. llvm-svn: 329207
* Minor no-op cmake file style fix.Nico Weber2018-04-041-1/+2
| | | | llvm-svn: 329137
* [DebugInfoPDB] Add a few missing definitions to PDBTypes.hAaron Smith2018-04-031-0/+3
| | | | | | | | | The missing definitions are from cvconst.h shipped with DIA SDK. Correct the url to MSDN for MemoryTypeEnum and set the underlying type of PDB_StackFrameType and PDB_MemoryType to uint16_t. llvm-svn: 329104
* [llvm-pdbutil] Add an export subcommand.Zachary Turner2018-04-022-4/+13
| | | | | | | | | | | | | | | | | This command can dump the binary contents of a stream to a file. This is useful when you want to do side-by-side comparisons of a specific stream from two PDBs to examine the differences between them. You can export both of them to a file, then open them up side by side in a hex editor (for example), so as to eliminate any differences that might arise from the contents being on different blocks in the PDB. In subsequent patches I plan to improve the "explain" subcommand so that you can explain the contents of a binary file that isn't necessarily a full PDB, but one of these dumped streams, by telling the subcommand how to interpret the contents. llvm-svn: 329002
* [DebugInfo] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-04-014-9/+9
| | | | | | | | | | | | | | | | | | | | | | Summary: r327219 added wrappers to std::sort which randomly shuffle the container before sorting. This will help in uncovering non-determinism caused due to undefined sorting order of objects having the same key. To make use of that infrastructure we need to invoke llvm::sort instead of std::sort. Note: This patch is one of a series of patches to replace *all* std::sort to llvm::sort. Refer the comments section in D44363 for a list of all the required patches. Reviewers: echristo, zturner, samsonov Reviewed By: echristo Subscribers: JDevlieghere, llvm-commits Differential Revision: https://reviews.llvm.org/D45134 llvm-svn: 328935
* [llvm-pdbutil] Dig deeper into the PDB and DBI streams when explaining.Zachary Turner2018-03-301-13/+9
| | | | | | | | | This will show more detail when using `llvm-pdbutil explain` on an offset in the DBI or PDB streams. Specifically, it will dig into individual header fields and substreams to give a more precise description of what the byte represents. llvm-svn: 328878
* [MSF] Default to FPM2, and always mark FPM pages allocated.Zachary Turner2018-03-291-32/+6
| | | | | | | | | | | | | | | | | | | | | | | | There are two FPMs in an MSF file, the idea being that for incremental updates you can write to the alternate one and then atomically swap them on commit. LLVM defaulted to using FPM1 on the first commit, but this differs from Microsoft's behavior which is to default to using FPM2 on the first commit. To eliminate some byte-level file differences, this patch changes LLVM's default to also be FPM2. Additionally, LLVM was trying to be "smart" about marking FPM pages allocated. In addition to marking every page belonging to the alternate FPM as unallocated, LLVM also marked pages at the end of the main FPM which were not needed as unallocated. In order to match the behavior of Microsoft-generated PDBs, we now always mark every FPM block as allocated, regardless of whether it is in the main FPM or the alt FPM, and regardless of whether or not it describes blocks which are actually in the file. This has the side benefit of simplifying our code. llvm-svn: 328812
* .debug_names: Correctly align the AugmentationStringSize fieldPavel Labath2018-03-291-2/+1
| | | | | | | | | | | | | We should align the value of the field, not the overall section offset. This distinction matters if one of the debug_names contributions is not of size which is a multiple of four. The dwarf producers may choose to emit rounded contributions, but they are not required to do so. In the latter case, without this patch we would corrupt the parsing state, as we would adjust the offset even if subsequent contributions contained correctly rounded augmentation strings. llvm-svn: 328796
* .debug_names: Parse DW_IDX_die_offset as a referencePavel Labath2018-03-291-1/+1
| | | | | | | | | | | Before this patch we were parsing the attributes as section offsets, as that is what apple_names is doing. However, this is not correct as DWARF v5 specifies that this attribute should use the Reference form class. This also updates all the testcases (except the ones that deliberately pass a different form) to use the correct form class. llvm-svn: 328773
* [DWARF][DWARF v5]: Adding support for dumping DW_RLE_offset_pair and ↵Wolfgang Pieb2018-03-271-19/+48
| | | | | | | | | | DW_RLE_base_address Reviewers: dblakie, aprantl Differential Revision: https://reviews.llvm.org/D44811 llvm-svn: 328662
* [DebugInfoPDB] Print the method name along with the variant valueAaron Smith2018-03-261-1/+1
| | | | | | | | | | | | | | | Before this change, using dumpProperties() with PDBSymbolData would look like this: get_locationType: 3 1 After this change: get_locationType: 3 get_value: 1 llvm-svn: 328590
* [DebugInfoPDB] Add methods to get the compiland and line numbers with ↵Aaron Smith2018-03-261-1/+50
| | | | | | PDBSymbolData llvm-svn: 328587
* [DebugInfoPDB] Add DIA implementation of findLineNumbersByRVAAaron Smith2018-03-262-0/+14
| | | | | | | This method is used to find line numbers for PDBSymbolData that have an invalid virtual address. llvm-svn: 328586
* [DebugInfoPDB] Add DIA implementation of addressForVA and addressForRVAAaron Smith2018-03-262-0/+32
| | | | | | These are used in finding line numbers for PDBSymbolData llvm-svn: 328585
* Use correct format specifier.Paul Robinson2018-03-261-1/+1
| | | | | | Review comment on r328235 by James Henderson. llvm-svn: 328578
* [PDB] Resubmit "Support embedding natvis files in PDBs."Zachary Turner2018-03-232-1/+123
| | | | | | | | | | | | This was reverted several times due to what ultimately turned out to be incompatibilities in our serialized hash table format. Several changes went in prior to this to fix those issues since they were more fundamental and independent of supporting injected sources, so now that those are fixed this change should hopefully pass. llvm-svn: 328363
* [PDB] Make our PDBs look more like MS PDBs.Zachary Turner2018-03-237-47/+146
| | | | | | | | | | | | | | | | | | When investigating bugs in PDB generation, the first step is often to do the same link with link.exe and then compare PDBs. But comparing PDBs is hard because two completely different byte sequences can both be correct, so it hampers the investigation when you also have to spend time figuring out not just which bytes are different, but also if the difference is meaningful. This patch fixes a couple of cases related to string table emission, hash table emission, and the order in which we emit strings that makes more of our bytes the same as the bytes generated by MS PDBs. Differential Revision: https://reviews.llvm.org/D44810 llvm-svn: 328348
* [DWARF] Replace assert with diagnostic. PR36868.Paul Robinson2018-03-221-2/+8
| | | | llvm-svn: 328235
* [Codeview/PDB] Rename some methods for clarity.Zachary Turner2018-03-224-12/+29
| | | | | | | | | NFC, this just renames some methods to better express what they do, and also adds a few helper methods to add some symmetry to the API in a few places (for example there was a getStringFromId but not a getIdFromString method in the string table). llvm-svn: 328221
* DWARFVerifier: verify debug_names abbreviation tablePavel Labath2018-03-221-0/+86
| | | | | | | | | | | | | | | | | Summary: This commit adds checks of the abbreviation table in a DWARF v5 Name Index. The most interesting/useful check is the one which checks that each index attributes is encoded using the correct form class, but it also checks for the more obvious errors like unknown forms/tags/attributes and duplicated attributes. Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44736 llvm-svn: 328202
* [DIA] Add IPDBSectionContrib interfaces and DIA implementationAaron Smith2018-03-226-0/+210
| | | | | | | | | | | | | | | | | | | | | To resolve symbol context at a particular address, we need to determine the compiland for the address. We are able to determine the parent compiland of PDBSymbolFunc, PDBSymbolTypeUDT, PDBSymbolTypeEnum symbols indirectly through line information. However no such information is availabile for PDBSymbolData, i.e. variables. The Section Contribution table from PDBs has information about each compiland's contribution to sections by address. For example, a piece of a contribution looks like, VA RelativeVA Sect No. Offset Length Compiland 14000087B0 000087B0 0001 000077B0 000000BB exe_main.obj So given an address, it's possible to determine its compiland with this information. llvm-svn: 328178
* [PDB] Get more DIA table enumeratorsAaron Smith2018-03-221-6/+8
| | | | | | Rename the original function and make it a static template. llvm-svn: 328177
* [PDB] Don't ignore bucket 0 when writing the PDB string table.Zachary Turner2018-03-212-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | The hash table is a list of buckets, and the *value* stored in the bucket cannot be 0 since that is reserved. However, the code here was incorrectly skipping over the 0'th bucket entirely. The 0'th bucket is perfectly fine, just none of these buckets can contain the value 0. As a result, whenever there was a string where hash(S) % Size was equal to 0, we would write the value in the next bucket instead. We never caught this in our tests due to *another* bug, which is that we would iterate the entire list of buckets looking for the value, only using the hash value as a starting point. However, the real algorithm stops when it finds 0 in a bucket since it takes that to mean "the item is not in the hash table". The unit test is updated to carefully construct a set of hash values that will cause one item to hash to 0 mod bucket count, and the reader is also updated to return an error indicating that the item is not found when it encounters a 0 bucket. llvm-svn: 328162
* [PDB] Remove unused private variable, re-applying r327900 after relanding ↵Reid Kleckner2018-03-212-7/+4
| | | | | | more natvis changes[4~ llvm-svn: 328156
* Handle abbr_offset with relocations.Rafael Espindola2018-03-212-6/+8
| | | | | | | | | This is mostly just plumbing to get a DWARFDataExtractor where we compute abbr_offset so we can use getRelocatedValue. This is part of PR36793. llvm-svn: 328154
* [dwarf] Unify unknown dwarf enum formatting codePavel Labath2018-03-213-67/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: We have had at least three pieces of code (in DWARFAbbreviationDeclaration, DWARFAcceleratorTable and DWARFDie) that have hand-rolled support for dumping unknown dwarf enum values. While not terrible, they are a bit distracting and enable small differences to creep in (Unknown_ffff vs. Unknown_0xffff). I ended up needing to add a fourth place (DWARFVerifier), so it seems it would be a good time to centralize. This patch creates an alternative to the XXXString dumping functions in the BinaryFormat library, which formats an unknown value as DW_TYPE_unknown_1234, instead of just an empty string. It is based on the formatv function, as that allows us to avoid materializing the string for unknown values (and because this way I don't have to invent a name for the new functions :P). In this patch I add formatters for dwarf attributes, forms, tags, and index attributes as these are the ones in use currently, but adding other enums is straight-forward. Reviewers: dblaikie, JDevlieghere, aprantl Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44570 llvm-svn: 328090
* Revert "Resubmit "Support embedding natvis files in PDBs.""Zachary Turner2018-03-208-186/+32
| | | | | | | | This is still failing on a different bot this time due to some issue related to hashing absolute paths. Reverting until I can figure it out. llvm-svn: 328014
* Resubmit "Support embedding natvis files in PDBs."Zachary Turner2018-03-208-32/+186
| | | | | | | | | | | The issue causing this to fail in certain configurations should be fixed. It was due to the fact that DIA apparently expects there to be a null string at ID 1 in the string table. I'm not sure why this is important but it seems to make a difference, so set it. llvm-svn: 328002
* [PDB] Add a method to get the full path of the source file for ↵Aaron Smith2018-03-191-15/+86
| | | | | | | | | | | | | | | | | PDBSymbolCompiland Summary: Redefine PDBSymbolCompiland::getSourceFileName() to return the filename (w/o directory) of the source file that is used to compile the compiland. This is because the result returned previously is ambiguous. It could be the filename, relative path or full path of the source file. Move the implementation of SymbolFilePDB::GetSourceFileNameForPDBCompiland() into a new method PDBSymbolCompiland::getSourceFileFullPath(). Reviewers: zturner, rnk, llvm-commits Reviewed By: zturner Differential Revision: https://reviews.llvm.org/D44458 llvm-svn: 327910
* [PDB] Add exclusive methods to derived symbol classAaron Smith2018-03-191-0/+15
| | | | | | | | | | | | Summary: This commit adds two methods to the PDBSymboFunc class used in parsing symbols. getLineNumbers() is used to determine a Function symbol's declaration and getCompilandId() is used to initialize the SymbolContext field sc.comp_unit. Reviewers: zturner, rnk, llvm-commits Reviewed By: zturner Differential Revision: https://reviews.llvm.org/D44457 llvm-svn: 327909
* Revert "Support embedding natvis files in PDBs."Zachary Turner2018-03-198-186/+32
| | | | | | | This is causing a test failure on a certain bot, so I'm removing this temporarily until we can figure out the source of the error. llvm-svn: 327903
* Remove an unused private variable.Zachary Turner2018-03-192-7/+4
| | | | llvm-svn: 327900
* Support embedding natvis files in PDBs.Zachary Turner2018-03-196-25/+182
| | | | | | | | | | | | | | | | | | | | | | | | Natvis is a debug language supported by Visual Studio for specifying custom visualizers. The /NATVIS option is an undocumented link.exe flag which will take a .natvis file and "inject" it into the PDB. This way, you can ship the debug visualizers for a program along with the PDB, which is very useful for postmortem debugging. This is implemented by adding a new "named stream" to the PDB with a special name of /src/files/<natvis file name> and simply copying the contents of the xml into this file. Additionally, we need to emit a single stream named /src/headerblock which contains a hash table of embedded files to records describing them. This patch adds this functionality, including the /NATVIS option to lld-link. Differential Revision: https://reviews.llvm.org/D44328 llvm-svn: 327895
* DWARFVerifier: Enhance validation of .debug_names hash tablesPavel Labath2018-03-161-15/+116
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch adds more checks to the .debug_names validator. Specifically, they check for: - buckets claiming to be non-empty but pointing to mismatched hashes (most consumers would interpret this as an empty bucket, but it questionable whether the generator meant that) - hashes that are not reachable from any bucket - names with incorrect hashes Together, these checks ensure that any name in the index can be reached through the hash table using the regular lookup algorithm. We also warn if we encounter a name index without a hash table. Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44433 llvm-svn: 327699
* [PDB] Fix a bug where we were serializing hash tables incorrectly.Zachary Turner2018-03-151-3/+5
| | | | | | | | | | | There was some code that tried to calculate the number of 4-byte words required to hold N bits, but it was instead computing the number of bytes required to hold N bits. This was leading to extraneous data being output into the hash table, which would cause certain operations in DIA (the Microsoft PDB reader) to fail. llvm-svn: 327675
* Refactor the PDB HashTable class.Zachary Turner2018-03-153-192/+27
| | | | | | | | | It previously only worked when the key and value types were both 4 byte integers. We now have a use case for a non trivial value type, so we need to extend it to support arbitrary value types, which means templatizing it. llvm-svn: 327647
* [DebugInfo] Add a new method IPDBSession::findLineNumbersBySectOffsetAaron Smith2018-03-152-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | Summary: Some PDB symbols do not have a valid VA or RVA but have Addr by Section and Offset. For example, a variable in thread-local storage has the following properties: get_addressOffset: 0 get_addressSection: 5 get_lexicalParentId: 2 get_name: g_tls get_symIndexId: 12 get_typeId: 4 get_dataKind: 6 get_symTag: 7 get_locationType: 2 This change provides a new method to locate line numbers by Section and Offset from those symbols. Reviewers: zturner, rnk, llvm-commits Subscribers: asmith, JDevlieghere Differential Revision: https://reviews.llvm.org/D44407 llvm-svn: 327601
* DWARF: Unify form size handling codePavel Labath2018-03-145-104/+14
| | | | | | | | | | | | | | | | | Summary: This patch replaces the two switches which are deducing the size of various forms with a single implementation. I have put the new implementation into BinaryFormat, to avoid introducing dependencies between the two independent libraries (DebugInfo and CodeGen) that need this functionality. Reviewers: aprantl, JDevlieghere, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D44418 llvm-svn: 327486
* Handle mixed-OS paths in DWARF readerEugene Zemtsov2018-03-131-2/+10
| | | | | | | | Make sure that DWARF line information generated by Windows can be properly read by Posix OS and vice versa. Differential Revision: https://reviews.llvm.org/D44290 llvm-svn: 327430
* [PDB] Support dumping injected sources via the DIA reader.Zachary Turner2018-03-137-0/+169
| | | | | | | | | | | | | | | | | | Injected sources are basically a way to add actual source file content to your PDB. Presumably you could use this for shipping your source code with your debug information, but in practice I can only find this being used for embedding natvis files inside of PDBs. In order to effectively test LLVM's natvis file injection, we need a way to dump the injected sources of a PDB in a way that is authoritative (i.e. based on Microsoft's understanding of the PDB format, and not LLVM's). To this end, I've added support for dumping injected sources via DIA. I made a PDB file that used the /natvis option to generate a test case. Differential Revision: https://reviews.llvm.org/D44405 llvm-svn: 327428
* [DebugInfo] Replace unreachable with NoneJonas Devlieghere2018-03-121-1/+1
| | | | | | | | | Invalid user input should not trigger assertions and unreachables. We already return an Option so we should just return None here. Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=5532 llvm-svn: 327274
* [DebugInfo/AccelTable] Fix inconsistency in getDIEOffset implementationsPavel Labath2018-03-091-8/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Even though the getDIEOffset offset function was common for the two accelerator table implementations, it was doing two different things: for the Apple tables, it was returning the die offset relative to the start of the section, whereas for DWARF v5 tables, it was relative to the start of the CU. I resolve this by renaming the function to getDIESectionOffset to make it obvious what the function returns, and change the DWARF implementation to return the section offset. I also keep the CU-relative accessor, but only in the DWARF implementation (there is no way to get this information for the Apple tables). This was not caught by existing tests because the hand-written inputs also erroneously used section offsets instead of CU-relative ones. While looking at this, I noticed that the Apple implementation was not fully correct either -- the header contains a DIEOffsetBase field, which should be added to offsets encoded with the DW_FORM_ref*** family, but this was not being used. This went unnoticed because all current writers set this field to zero anyway. I fix this as well and add a hand-written test which demonstrates the issue. Reviewers: JDevlieghere, dblaikie Subscribers: aprantl, llvm-commits Differential Revision: https://reviews.llvm.org/D44202 llvm-svn: 327116
* [Support] Move syntax highlighting into supportJonas Devlieghere2018-03-097-128/+23
| | | | | | | | | | | | Move the DWARF syntax highlighting into support. This has several advantages, most notably that this makes the WithColor RAII wrapper available outside libDebugInfo. Furthermore, several projects all have their own code for handling colored output. This provides a place to centralize it. Differential revision: https://reviews.llvm.org/D44215 llvm-svn: 327108
* [DebugInfo] Move RangeListEntries instead of copying.Benjamin Kramer2018-03-081-2/+2
| | | | | | | This is needed for correctness as RangeListEntry is not copy-assignable, which std::vector might rely on. llvm-svn: 327067
* Fix compilation failure with MSVC.Zachary Turner2018-03-081-1/+1
| | | | llvm-svn: 327063
OpenPOWER on IntegriCloud