summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Revert "DWARFVerifier: Check "completeness" of .debug_names section"Pavel Labath2018-05-091-146/+0
| | | | | | | | | | | | | | The new verifier check has found an error in the debug-names-name-collisions.ll test on the PS4 bot: error: Name Index @ 0x0: Entry @ 0xdc: mismatched Name of DIE @ 0x23: index - _ZN3foo3fooE; debug_info - foo. Reverting while I investigate whether this is a bug in the verifier or the generator. This reverts commit r331868. llvm-svn: 331869
* DWARFVerifier: Check "completeness" of .debug_names sectionPavel Labath2018-05-091-0/+146
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch implements a check which makes sure all entries required by the DWARF v5 specification are present in the Name Index. The algorithm tries to follow the wording of Section 6.1.1.1 of the spec as closely as possible. The main deviation from it is that instead of a whitelist-based approach in the spec "The name index must contain an entry for each debugging information entry that defines a named subprogram, label, variable, type, or namespace" I chose a blacklist-based one, where I consider everything to be "in" and then remove the entries that don't make sense. I did this because it has more potential for catching interesting cases and the above is a bit vague (it uses plain words like "variable" and "subprogram", but the rest of the section speaks about specific TAGs). This approach has raised some interesting questions, the main one being whether enumerator values should be indexed. The consensus seems to be that they should, although it does not follow from section 6.1.1.1. For the time being I made the verifier ignore these, as LLVM does not do this yet, and I wanted to get a clean run when verifying generated debug info. Another interesting case was the DW_TAG_imported_declaration. It was not immediately clear to me whether this should go in or not, but currently it is not indexed, and (unlike the enumerators) in does not seem to cause problems for LLDB, so I've also ignored it. Reviewers: JDevlieghere, aprantl, dblaikie Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D46583 llvm-svn: 331868
* [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
* DWARFVerifier: validate information in name index entriesPavel Labath2018-04-061-0/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* 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
* [Support] Move syntax highlighting into supportJonas Devlieghere2018-03-091-6/+5
| | | | | | | | | | | | 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
* 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
* [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
* Stop tracking .debug_line_str in DWARFUnit. NFC.Paul Robinson2018-01-291-4/+4
| | | | llvm-svn: 323701
* [DWARFv5] Support DW_FORM_line_strp in llvm-dwarfdump.Paul Robinson2018-01-251-4/+4
| | | | | | | | | | | This form is like DW_FORM_strp, but points to .debug_line_str instead of .debug_str as the string section. It's intended to be used from the line-table header, and allows string-pooling of directory and filenames across compilation units. Differential Revision: https://reviews.llvm.org/D42553 llvm-svn: 323476
* Rename DwarfAcceleratorTable to AppleAcceleratorTable. NFCPavel Labath2018-01-221-8/+8
| | | | | | | | | This frees up the first name to be used as an base class for the apple table and the dwarf5 .debug_names accel table. The rename was split off from D42297 (adding of debug_names support), which is still under review. llvm-svn: 323113
* [dwarfdump] Fix off-by-one bug in accelerator table extractor.Jonas Devlieghere2017-12-111-2/+2
| | | | | | | | | | | | | | | This fixes a bug where the verifier was complaining about empty accelerator tables. When the table is empty, its size is not a valid offset as it points after the end of the section. This patch also makes the extractor return llvm:Error instead of bool for better error reporting in the verifier. Differential revision: https://reviews.llvm.org/D41063 rdar://35932007 llvm-svn: 320399
* Fix BB after r316756 "[llvm-dwarfdump] - Teach verifier to report broken ↵George Rimar2017-10-271-1/+1
| | | | | | | | | | | DWARF expressions." Bot: http://lab.llvm.org:8011/builders/clang-with-thin-lto-ubuntu/builds/6255 Changed format of this message by mistake. llvm-svn: 316757
* [llvm-dwarfdump] - Teach verifier to report broken DWARF expressions.George Rimar2017-10-271-26/+38
| | | | | | | | | | | | | Patch improves next things: * Fixes assert/crash in getOpDesc when giving it a invalid expression op code. * DWARFExpression::print() called DWARFExpression::Operation::getEndOffset() which returned and used uninitialized field EndOffset. Patch fixes that. * Teaches verifier to verify DW_AT_location and error out on broken expressions. Differential revision: https://reviews.llvm.org/D39294 llvm-svn: 316756
* Re-land "[llvm-dwarfdump] Print type names in DW_AT_type DIEs"Jonas Devlieghere2017-10-101-2/+2
| | | | | | | | | | | | This patch adds printing for DW_AT_type DIEs like it is already the case for DW_AT_specification DIEs. This is a rather naive approach and only a start. We should have pretty printers for different languages. Recommit after being reverted in r315299. Differential revision: https://reviews.llvm.org/D36993 llvm-svn: 315316
* [dwarfdump] Verify that unit type matches root DIEJonas Devlieghere2017-10-061-8/+24
| | | | | | | | | | | | | This patch adds two new verifiers: - It checks that the root DIE of a CU is actually a valid unit DIE. (based on its tag) - For DWARF5 which contains a unit type int he CU header, it checks that this matches the type of the unit DIE. Differential revision: https://reviews.llvm.org/D38453 llvm-svn: 315121
* [dwarfdump][NFC] Consistent printing of address rangesJonas Devlieghere2017-09-291-8/+3
| | | | | | | | | | | | | | This implement the insertion operator for DWARF address ranges so they are consistently printed as [LowPC, HighPC). While a dump method might have felt more consistent, it is used exclusively for printing error messages in the verifier and never used for actual dumping. Hence this approach is more intuitive and creates less clutter at the call sites. Differential revision: https://reviews.llvm.org/D38395 llvm-svn: 314523
* [dwarfdump][NFC] Consistent errors and warnings with --verifyJonas Devlieghere2017-09-291-79/+96
| | | | | | | | | | | This patch introduces 3 helper functions: error(), warn() and note() to make printing during verification more consistent. When supported, the respective prefixes are printed in color using the same color scheme as clang. Differential revision: https://reviews.llvm.org/D38368 llvm-svn: 314498
* [dwarfdump] Verify that CUs have a unit DIE.Jonas Devlieghere2017-09-281-3/+8
| | | | | | | | | This patch adds a check to the DWARF verifier to detect CUs without a unit DIE. Differential revision: https://reviews.llvm.org/D38363 llvm-svn: 314426
* llvm-dwarfdump: implement --recurse-depth=<N>Adrian Prantl2017-09-201-11/+11
| | | | | | | | | | This patch implements the Darwin dwarfdump option --recurse-depth=<N>, which limits the recursion depth when selectively printing DIEs at an offset. Differential Revision: https://reviews.llvm.org/D38064 llvm-svn: 313778
* [test] Fix TestDWARFDieRangeInfoIntersectsJonas Devlieghere2017-09-141-0/+2
| | | | | | Fixes heap buffer overflow triggered in DWARF verifier, detected by ASAN. llvm-svn: 313280
* [dwarfdump] Add DWARF verifiers for address rangesJonas Devlieghere2017-09-141-4/+135
| | | | | | | | | | | | | | | | This patch started as an attempt to rebase Greg's differential (D32821). The result is both quite similar and different at the same time. It adds the following checks: - Verify that all address ranges in a DIE are valid. - Verify that no ranges within the DIE overlap. - Verify that no ranges overlap with the ranges of a sibling. - Verify that children are completely contained in its (direct) parent's address range. (unless both are subprograms) Differential revision: https://reviews.llvm.org/D37696 llvm-svn: 313255
* Revert "[dwarfdump] Add DWARF verifiers for address ranges"Jonas Devlieghere2017-09-141-135/+4
| | | | | | This reverts commit r313250. llvm-svn: 313253
* [dwarfdump] Add DWARF verifiers for address rangesJonas Devlieghere2017-09-141-4/+135
| | | | | | | | | | | | | | | | This patch started as an attempt to rebase Greg's differential (D32821). The result is both quite similar and different at the same time. It adds the following checks: - Verify that all address ranges in a DIE are valid. - Verify that no ranges within the DIE overlap. - Verify that no ranges overlap with the ranges of a sibling. - Verify that children are completely contained in its (direct) parent's address range. (unless both are subprograms) Differential revision: https://reviews.llvm.org/D37696 llvm-svn: 313250
* [dwarfdump] Rename Brief to Verbose in DIDumpOptionsJonas Devlieghere2017-09-131-11/+11
| | | | | | | | | | | This patches renames "brief" to "verbose" in de DIDumpOptions and inverts the logic to match the new behavior where brief is the default. Changing the default value uncovered some bugs related to the DIDumpOptions not being propagated and have been fixed as well. Differential revision: https://reviews.llvm.org/D37745 llvm-svn: 313139
* [dwarfdump] Verify line table prologueJonas Devlieghere2017-09-081-0/+41
| | | | | | | | | | This patch adds prologue verification, which is already present in Apple's dwarfdump. It checks for invalid directory indices and warns about duplicate file paths. Differential revision: https://reviews.llvm.org/D37511 llvm-svn: 312782
* [DebugInfo][DWARF] Correct some usages of PRIx32 to PRIx64Simon Dardis2017-08-071-4/+4
| | | | | | | | | | | These lead to tests failing spuriously as the values after being rendered to a string were incorrect. Reviewers: clayborg Differential Revision: https://reviews.llvm.org/D36319 llvm-svn: 310262
* [DWARF] Added verification check for tags in accelerator tables. This patch ↵Spyridoula Gravani2017-07-311-5/+14
| | | | | | | | verifies that the atom tag is actually the same with the tag of the DIE that we retrieve from the table. Differential Revision: https://reviews.llvm.org/D35963 llvm-svn: 309596
* [DWARF] Generalized verification of .apple_names accelerator table to be ↵Spyridoula Gravani2017-07-261-44/+64
| | | | | | | | applicable to any acceleration table. Added verification for .apple_types, .apple_namespaces and .apple_objc sections. Differential Revision: https://reviews.llvm.org/D35853 llvm-svn: 309068
* DWARFVerifier.cpp: Fix -m32 in r308928. Use PRIx64.NAKAMURA Takumi2017-07-251-1/+2
| | | | llvm-svn: 308949
* [DWARF] Added verification check for die ranges. If highPC is an address, ↵Spyridoula Gravani2017-07-241-0/+13
| | | | | | | | then it should be greater than lowPC for each range. Differential Revision: https://reviews.llvm.org/D35733 llvm-svn: 308928
* [DWARF] Generalized verification of .debug_abbrev to be applicable to both ↵Spyridoula Gravani2017-07-211-14/+24
| | | | | | | | .debug_abbrev and .debug_abbrev.dwo sections. Differential Revision: https://reviews.llvm.org/D35698 llvm-svn: 308703
* [DWARF] Added check that verifies that no abbreviation declaration has more ↵Spyridoula Gravani2017-07-201-0/+31
| | | | | | | | | | | | | than one attribute with the same name. SUMMARY This patch adds a verification check on the abbreviation declarations in the .debug_abbrev section. The check makes sure that no abbreviation declaration has more than one attributes with the same name. Differential Revision: https://reviews.llvm.org/D35643 llvm-svn: 308579
* Use delegation instead of inheritance.Rafael Espindola2017-07-191-18/+21
| | | | | | | | | | This changes DwarfContext to delegate to DwarfObject instead of having pure virtual methods. With this DwarfContextInMemory is replaced with an implementation of DwarfObject that is local to a .cpp file. llvm-svn: 308543
* [DWARF] Modification of code for the verification of .debug_info section.Spyridoula Gravani2017-07-181-43/+85
| | | | | | | | | | | | | | | Summary: This patch modifies the handleDebugInfo() function so that we verify the contents of each unit in the .debug_info section only if its header has been successfully verified. This change will allow for more/different verification checks depending on the type of the unit since from dwarf5, the .debug_info section may consist of different types of units. Subscribers: aprantl Differential Revision: https://reviews.llvm.org/D35521 llvm-svn: 308245
* Remove set but not used variables from the debug info verifier code.Eric Christopher2017-07-141-6/+1
| | | | llvm-svn: 307987
* [DWARF] Introduce verification for the unit header chain in .debug_info ↵Spyridoula Gravani2017-07-131-0/+92
| | | | | | | | | | | | | | | section to llvm-dwarfdump. This patch adds verification checks for the unit header chain in the .debug_info section. Specifically, for each unit in the .debug_info section, the verifier checks that: The unit length is valid (i.e. the unit can actually fit in the .debug_info section) The dwarf version of the unit is valid The address size is valid (4 or 8) The unit type (if the unit is in dwarf5) is valid The debug_abbrev_offset is valid llvm-svn: 307975
* [DWARF] Added verification checks for the .apple_names section.Spyridoula Gravani2017-06-291-3/+63
| | | | | | | | This patch verifies the number of atoms, the validity of the form for each atom, as well as the validity of the hashdata. For hashdata, we're verifying that the hashdata offset is correct and that the offset in the .debug_info for each DIE in the hashdata is also valid. llvm-svn: 306735
* [DWARF] NFC: DWARFDataExtractor combines relocs with DataExtractor.Paul Robinson2017-06-291-4/+3
| | | | | | | | | | | Requires callers to directly associate relocations with a DataExtractor used to read data from a DWARF section, which helps a callee not make assumptions about which section it is reading. This is the next step in reducing DWARFFormValue's dependence on DWARFUnit. Differential Revision: https://reviews.llvm.org/D34704 llvm-svn: 306699
* [DWARF] Corrected behavior for when no .apple_names section is present in ↵Spyridoula Gravani2017-06-161-3/+3
| | | | | | | | | | the object. The verifier should not output any message in such a case. Added test case with no .apple_name section in the file to verify new functionality. Made existing test case more specific. llvm-svn: 305597
* Added partial verification for .apple_names accelerator table in ↵Spyridoula Gravani2017-06-141-0/+34
| | | | | | | | | | | llvm-dwarfdump output. This patch adds code which verifies that each bucket in the .apple_names accelerator table is either empty or has a valid hash index. Differential Revision: https://reviews.llvm.org/D34177 llvm-svn: 305344
* Revert "[Dwarf] Disable reference verification for now (PR32972)"Diana Picus2017-05-091-2/+1
| | | | | | This reverts commit r302520 because it break the unit tests. llvm-svn: 302524
* [Dwarf] Disable reference verification for now (PR32972)Renato Golin2017-05-091-1/+2
| | | | | | | | | | | | | | | There is no other explanation about why this only started happening now, even though it crashes on old code (supposedly reachable from here). The only common factor between the failing bots is that they use GCC (4.9 and 5.3) to compile Clang, while the others use Clang 3.8, but the failure is while building the tests, as an assertion, on Clang. Commenting it out for now in hope the bots will go back green, but we should keep looking for the real cause, and update bugzilla. llvm-svn: 302520
* Add const to "DWARFDie &Die" in a few functions as they can't change the ↵Greg Clayton2017-05-081-2/+2
| | | | | | DWARFDie. llvm-svn: 302471
* Fix typoEugene Zemtsov2017-05-081-1/+1
| | | | llvm-svn: 302470
* Fix typo "veify" to "verify".Greg Clayton2017-05-081-1/+1
| | | | llvm-svn: 302466
* Break verification down into smaller functions to keep code clean.Greg Clayton2017-05-031-142/+167
| | | | | | | | Adrian requested that we break things down to make things clean in the DWARFVerifier. This patch breaks everything down into nice individual functions and cleans up the code quite a bit and prepares us for the next round of verifiers. Differential Revision: https://reviews.llvm.org/D32812 llvm-svn: 302062
* Create DWARFVerifier.cpp and .h and move all DWARF verification code over ↵Greg Clayton2017-05-031-0/+252
into it. Adrian requested we create a DWARFVerifier.cpp file to contain all of the DWARF verification stuff. This change simply moves the functionality over into DWARFVerifier.h and DWARFVerifier.cpp, renames the DWARFVerifier methods to start with lower case, and switches DWARFContext.cpp over to using the new functionality. Differential Revision: https://reviews.llvm.org/D32809 llvm-svn: 302044
OpenPOWER on IntegriCloud