summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF
Commit message (Collapse)AuthorAgeFilesLines
...
* [DebugInfo] Accept `S` in augmentation strings in CIE.Fangrui Song2018-05-081-0/+3
| | | | | | glibc libc.a(sigaction.o) compiled from sysdeps/unix/sysv/linux/x86_64/sigaction.c uses "zRS". llvm-svn: 331738
* llvm-symbolizer: Handle function definitions nested within other functionsDavid Blaikie2018-05-011-2/+6
| | | | | | | | | | | | LLVM always puts function definition DIEs at the top level, but under some circumstances GCC does not (at least in this case with member functions of a function-local type). To ensure that doesn't appear as though the local type's member function is unduly inlined within the outer function - ensure the inline discovery DIE parent walk stops at the first DW_TAG_subprogram. llvm-svn: 331291
* [DebugInfo] Prevent infinite recursion for malformed DWARFJonas Devlieghere2018-04-301-10/+30
| | | | | | | | | | | This prevents infinite recursion in DWARFDie::findRecursively for malformed DWARF where a DIE references itself. This fixes PR36257. Differential revision: https://reviews.llvm.org/D43092 llvm-svn: 331200
* [DebugInfo] Use WithColor for more debug line warningsAndrew Ng2018-04-201-6/+8
| | | | | | | | | | Updated two more debug line related warnings to use WithColor. This was necessary to ensure consistent output order of the warnings on Windows for debug line tests. Differential Revision: https://reviews.llvm.org/D45871 llvm-svn: 330440
* [Support] Extend WithColor helpersJonas Devlieghere2018-04-151-9/+3
| | | | | | | Although printing warnings and errors to stderr is by far the most common case, this patch makes it possible to specify any stream. llvm-svn: 330094
* [DebugInfo] Use WithColor to print errors/warningsJonas Devlieghere2018-04-144-23/+28
| | | | | | | Use the convenience methods from WithColor to consistently print errors and warnings in libDebugInfo. llvm-svn: 330092
* 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
* [DebugInfo] Change std::sort to llvm::sort in response to r327219Mandeep Singh Grang2018-04-013-8/+8
| | | | | | | | | | | | | | | | | | | | | | 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
* .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
* Use correct format specifier.Paul Robinson2018-03-261-1/+1
| | | | | | Review comment on r328235 by James Henderson. llvm-svn: 328578
* [DWARF] Replace assert with diagnostic. PR36868.Paul Robinson2018-03-221-2/+8
| | | | llvm-svn: 328235
* 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
* 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
* 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
* 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
* [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
* [DWARF v5] Support for verbose dumping of .debug_rnglist entriesWolfgang Pieb2018-03-083-28/+87
| | | | | | | | | | | | | | | | Adding verbose dumping to the recent implementation of dumping of v5 range list entries. We're capturing the entries as is as they come in during extraction, including their file offset, so we can dump them in more detail. The offset table entries which are table-relative are shown as is (as in non-verbose mode) and with the actual file offset they map to. Reviewers: dblaikie, aprantl, jdevlieghere, jhenderson Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D43366 llvm-svn: 327059
* DWARFVerifier: Basic verification of .debug_namesPavel Labath2018-03-081-0/+87
| | | | | | | | | | | | | | | | | Summary: This patch adds basic .debug_names verification capabilities to the DWARF verifier. Right now, it checks that the headers and abbreviation tables of the individual name indexes can be parsed correctly, it verifies the buckets table and the cross-checks the CU lists for consistency. I intend to add further checks in follow-up patches. Reviewers: JDevlieghere, aprantl, probinson, dblaikie Subscribers: vleschuk, echristo, clayborg, llvm-commits Differential Revision: https://reviews.llvm.org/D44211 llvm-svn: 327011
* [DWARF] Don't attempt to parse line tables at invalid offsetsJames Henderson2018-03-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Whilst working on improvements to the error handling of the debug line parsing code, I noticed that if an invalid offset were to be specified in a call to getOrParseLineTable(), an entry in the LineTableMap would still be created, even if the offset was not within the section range. The immediate parsing attempt afterwards would fail (it would end up getting a version of 0), and thereafter, any subsequent calls to getOrParseLineTable or getLineTable would return the default- constructed, invalid line table. In reality, we shouldn't even attempt to parse this table, and we should always return a nullptr from these two functions for this situation. I have tested this via a unit test, which required some new framework for unit testing debug line. My plan is to add quite a few more unit tests for the new error reporting mechanism that will follow shortly, hence the reason why the supporting code for the tests are written the way they are - I intend to extend the DwarfGenerator class to support generating debug line. At that point, I'll make sure that there are a few positive test cases for this and the parsing code too. Differential Revision: https://reviews.llvm.org/D44200 Reviewers: JDevlieghere, aprantl llvm-svn: 326995
* Reland "[DebugInfo] Support DWARF expressions in eh_frame"Rafael Auler2018-03-084-369/+262
| | | | | | | | | | Summary: Original change was D43313 (r326932) and reverted by r326953 because it broke an LLD test and a windows build. The LLD test was already fixed in lld commit r326944 (thanks maskray). This is the original change with the windows build fixed. llvm-svn: 326970
* Revert r326932: [DebugInfo] Support DWARF expressions in eh_frameRui Ueyama2018-03-074-262/+369
| | | | | | This reverts commit rr326932 because it broke lld/test/ELF/eh-frame-hdr-augmentation.s. llvm-svn: 326953
* [DebugInfo] Support DWARF expressions in eh_frameRafael Auler2018-03-074-369/+262
| | | | | | | | | | | | | | | | | | This patch enhances DWARFDebugFrame with the capability of parsing and printing DWARF expressions in CFI instructions. It also makes FDEs and CIEs accessible to lib users, so they can process them in client tools that rely on LLVM. To make it self-contained with a test case, it teaches llvm-readobj to be able to dump EH frames and checks they are correct in a unit test. The llvm-readobj code is Maksim Panchenko's work (maksfb). Reviewers: JDevlieghere, espindola Reviewed By: JDevlieghere Differential Revision: https://reviews.llvm.org/D43313 llvm-svn: 326932
* [dwarfdump] Only print CU relative offset in verbose modeJonas Devlieghere2018-03-071-8/+15
| | | | | | | | | | | | Instead of only printing the CU-relative offset in non-verbose mode, it makes more sense to only printed the resolved address. In verbose mode we still print both. Differential revision: https://reviews.llvm.org/D44148 rdar://33525475 llvm-svn: 326903
* Implement equal_range for the DWARF v5 accelerator tablePavel Labath2018-02-241-19/+177
| | | | | | | | | | | | | | | | | | | Summary: This patch implements the name lookup functionality of the .debug_names accelerator table and hooks it up to "llvm-dwarfdump -find". To make the interface of the two kinds of accelerator tables more consistent, I've created an abstract "DWARFAcceleratorTable::Entry" class, which provides a consistent interface to access the common functionality of the table entries (such as getting the die offset, die tag, etc.). I've also modified the apple table to vend entries conforming to this interface. Reviewers: JDevlieghere, aprantl, probinson, dblaikie Subscribers: vleschuk, clayborg, echristo, llvm-commits Differential Revision: https://reviews.llvm.org/D43067 llvm-svn: 326003
* [DebugInfo] Support DWARF v5 source code embedding extensionScott Linder2018-02-232-29/+73
| | | | | | | | | | | | | | | | | | | In DWARF v5 the Line Number Program Header is extensible, allowing values with new content types. In this extension a content type is added, DW_LNCT_LLVM_source, which contains the embedded source code of the file. Add new optional attribute for !DIFile IR metadata called source which contains source text. Use this to output the source to the DWARF line table of code objects. Analogously extend METADATA_FILE in Bitcode and .file directive in ASM to support optional source. Teach llvm-dwarfdump and llvm-objdump about the new values. Update the output format of llvm-dwarfdump to make room for the new attribute on file_names entries, and support embedded sources for the -source option in llvm-objdump. Differential Revision: https://reviews.llvm.org/D42765 llvm-svn: 325970
* [dwarfdump] Fix spurious verification errors for DW_AT_location attributesJonas Devlieghere2018-02-171-15/+20
| | | | | | | | | | | Verifying any DWARF file that is optimized and contains at least one tag with a DW_AT_location with a location list offset as a DW_AT_form_dataXXX results in dwarfdump spuriously claiming that the location list is invalid. Differential revision: https://reviews.llvm.org/D40199 llvm-svn: 325430
* Revert "Rewrite the cached map used for locating the most precise DIE among ↵David Blaikie2018-02-131-360/+26
| | | | | | | | | | | | | | | inlined subroutines for a given address." Seeing some inlining missing in internal uses of symbolizer. I'll work on a reproduction, tests, improvements & recommit as soon as possible. (Chandler would like it to be known that this improvement did make check-llvm 4x faster... - so there's certainly some fairly good motivation to push on fixing/figuring this out & getting it back in) This reverts commit r321345. llvm-svn: 324981
* Simplify switch statement (NFC)Adrian Prantl2018-02-121-5/+3
| | | | llvm-svn: 324945
* Fix the syntax highlighting of strings in dwarfdump.Adrian Prantl2018-02-121-4/+4
| | | | llvm-svn: 324936
* Factor out common condition into an easier to understand helper function (NFC).Adrian Prantl2018-02-122-2/+12
| | | | llvm-svn: 324935
* [DWARFv5] Fix dumper to show the file table starts at index 0.Paul Robinson2018-02-081-1/+4
| | | | | | | | Emitting the correct (root of compilation) file at index 0 will be posted for review later; I wanted to get this minor change out of the way first. llvm-svn: 324669
* [DWARF] Regularize dumping strings from line tables.Paul Robinson2018-02-053-25/+46
| | | | | | | | | | | | | | | | | The major visible difference here is that in line-table dumps, directory and file names are wrapped in double-quotes; previously, directory names got single quotes and file names were not quoted at all. The improvement in this patch is that when a DWARF v5 line table header has indirect strings, in a verbose dump these will all have their section[offset] printed as well as the name itself. This matches the format used for dumping strings in the .debug_info section. Differential Revision: https://reviews.llvm.org/D42802 llvm-svn: 324270
* Fix more print format specifiers in debug_rnglists dumpingJames Henderson2018-02-051-4/+6
| | | | | | | | | See also r324096. I have made the assumption that DWARF64 is not an issue for the time being with these fixes. llvm-svn: 324223
* Fix MSVC signed/unsigned comparison warning. NFCI.Simon Pilgrim2018-02-031-1/+1
| | | | llvm-svn: 324171
* Fix type sizes that were causing incorrect string formattingJames Henderson2018-02-021-2/+2
| | | | llvm-svn: 324096
* Add missing new files from r324077James Henderson2018-02-022-0/+218
| | | | | | Differential Revision: https://reviews.llvm.org/D42481 llvm-svn: 324078
* [DWARF v5] Add limited support for dumping .debug_rnglistsJames Henderson2018-02-023-12/+29
| | | | | | | | | | | | | | | | | | | | | This change adds support to llvm-dwarfdump for dumping DWARF5 .debug_rnglists sections in regular ELF files. It is not complete, in that several DW_RLE_* encodings are currently not supported, but does dump the headert and the basic ranges for DW_RLE_start_length and DW_RLE_start_end encodings. Obvious next steps are to add verbose dumping that dumps the raw encodings, rather than the interpreted contents, to add -verify support of the section (e.g. to show that the correct number of offsets are specified), add dumping of .debug_rnglists.dwo, and to add support for other encodings. Reviewed by: dblaikie, JDevlieghere Differential Revision: https://reviews.llvm.org/D42481 llvm-svn: 324077
* Stop tracking .debug_line_str in DWARFUnit. NFC.Paul Robinson2018-01-292-14/+13
| | | | llvm-svn: 323701
* [DWARFv5] Re-enable dumping a line table with no CU.Paul Robinson2018-01-293-21/+37
| | | | | | | | | | | r323476 added support for DW_FORM_line_strp, and incorrectly made that depend on having a DWARFUnit available. We shouldn't be tracking .debug_line_str in DWARFUnit after all. After this patch, I can do an NFC follow up and undo a bunch of the "plumbing" part of r323476. Differential Revision: https://reviews.llvm.org/D42609 llvm-svn: 323691
* Fix windows test failure caused by r323638Pavel Labath2018-01-291-1/+1
| | | | | | | | | | | | | | The test was failing because of an incorrect sizeof check in the name index parsing code. This code was meant to check that we have enough input to parse the fixed-size part of the dwarf header, which it did by comparing the input to sizeof(Header). Originally struct Header only contained the fixed-size part, but during review, we've moved additional members into it, which rendered the sizeof check invalid. I resolve this by moving the fixed-size part to a separate struct and updating the sizeof-expression to use that. llvm-svn: 323648
OpenPOWER on IntegriCloud