llvm.org GIT mirror llvm / aef0513
[DWARF Verifier] Add helper function to dump DIEs. [NFC] It's pretty common for the verifier to dump the relevant DIE when it finds an issue. This tends to be relatively verbose and error prone because we have to pass the DIDumpOptions to the DIE's dump method. This patch adds a helper function to the verifier to make this easier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@342526 91177308-0d34-0410-b5e6-96231b3b80d8 Jonas Devlieghere 1 year, 9 months ago
2 changed file(s) with 19 addition(s) and 24 deletion(s). Raw diff Collapse all Expand all
100100 raw_ostream &error() const;
101101 raw_ostream &warn() const;
102102 raw_ostream ¬e() const;
103 raw_ostream &dump(const DWARFDie &Die, unsigned indent = 0) const;
103104
104105 /// Verifies the abbreviations section.
105106 ///
55 // License. See LICENSE.TXT for details.
66 //
77 //===----------------------------------------------------------------------===//
8
98 #include "llvm/DebugInfo/DWARF/DWARFVerifier.h"
109 #include "llvm/ADT/SmallSet.h"
1110 #include "llvm/DebugInfo/DWARF/DWARFCompileUnit.h"
367366 if (IntersectingChild != ParentRI.Children.end()) {
368367 ++NumErrors;
369368 error() << "DIEs have overlapping address ranges:";
370 Die.dump(OS, 0);
371 IntersectingChild->Die.dump(OS, 0);
372 OS << "\n";
369 dump(Die);
370 dump(IntersectingChild->Die) << '\n';
373371 }
374372
375373 // Verify that ranges are contained within their parent.
379377 if (ShouldBeContained && !ParentRI.contains(RI)) {
380378 ++NumErrors;
381379 error() << "DIE address ranges are not contained in its parent's ranges:";
382 ParentRI.Die.dump(OS, 0);
383 Die.dump(OS, 2);
384 OS << "\n";
380 dump(ParentRI.Die);
381 dump(Die, 2) << '\n';
385382 }
386383
387384 // Recursively check children.
397394 auto ReportError = [&](const Twine &TitleMsg) {
398395 ++NumErrors;
399396 error() << TitleMsg << '\n';
400 Die.dump(OS, 0, DumpOpts);
401 OS << "\n";
397 dump(Die) << '\n';
402398 };
403399
404400 const DWARFObject &DObj = DCtx.getDWARFObj();
479475 << " is invalid (must be less than CU size of "
480476 << format("0x%08" PRIx32, CUSize) << "):\n";
481477 Die.dump(OS, 0, DumpOpts);
482 OS << "\n";
478 dump(Die) << '\n';
483479 } else {
484480 // Valid reference, but we will verify it points to an actual
485481 // DIE later.
498494 ++NumErrors;
499495 error() << "DW_FORM_ref_addr offset beyond .debug_info "
500496 "bounds:\n";
501 Die.dump(OS, 0, DumpOpts);
502 OS << "\n";
497 dump(Die) << '\n';
503498 } else {
504499 // Valid reference, but we will verify it points to an actual
505500 // DIE later.
514509 if (SecOffset && *SecOffset >= DObj.getStringSection().size()) {
515510 ++NumErrors;
516511 error() << "DW_FORM_strp offset beyond .debug_str bounds:\n";
517 Die.dump(OS, 0, DumpOpts);
518 OS << "\n";
512 dump(Die) << '\n';
519513 }
520514 break;
521515 }
537531 ++NumErrors;
538532 error() << "invalid DIE reference " << format("0x%08" PRIx64, Pair.first)
539533 << ". Offset is in between DIEs:\n";
540 for (auto Offset : Pair.second) {
541 auto ReferencingDie = DCtx.getDIEForOffset(Offset);
542 ReferencingDie.dump(OS, 0, DumpOpts);
543 OS << "\n";
544 }
534 for (auto Offset : Pair.second)
535 dump(DCtx.getDIEForOffset(Offset)) << '\n';
545536 OS << "\n";
546537 }
547538 return NumErrors;
564555 ++NumDebugLineErrors;
565556 error() << ".debug_line[" << format("0x%08" PRIx32, LineTableOffset)
566557 << "] was not able to be parsed for CU:\n";
567 Die.dump(OS, 0, DumpOpts);
568 OS << '\n';
558 dump(Die) << '\n';
569559 continue;
570560 }
571561 } else {
582572 << format("0x%08" PRIx32, Iter->second.getOffset()) << " and "
583573 << format("0x%08" PRIx32, Die.getOffset())
584574 << ", have the same DW_AT_stmt_list section offset:\n";
585 Iter->second.dump(OS, 0, DumpOpts);
586 Die.dump(OS, 0, DumpOpts);
587 OS << '\n';
575 dump(Iter->second);
576 dump(Die) << '\n';
588577 // Already verified this line table before, no need to do it again.
589578 continue;
590579 }
13681357 raw_ostream &DWARFVerifier::warn() const { return WithColor::warning(OS); }
13691358
13701359 raw_ostream &DWARFVerifier::note() const { return WithColor::note(OS); }
1360
1361 raw_ostream &DWARFVerifier::dump(const DWARFDie &Die, unsigned indent) const {
1362 Die.dump(OS, indent, DumpOpts);
1363 return OS;
1364 }