diff options
| author | Greg Clayton <gclayton@apple.com> | 2017-05-03 15:45:31 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2017-05-03 15:45:31 +0000 |
| commit | 8df55b43e1a5f7acc9815b689940c6ac0de251ca (patch) | |
| tree | 4f60ca346642de95eeb7dd3dabcbc1a28a88b43a /llvm/lib | |
| parent | a271c54324bf882ef1e7d6a16987563fc6e5a2f3 (diff) | |
| download | bcm5719-llvm-8df55b43e1a5f7acc9815b689940c6ac0de251ca.tar.gz bcm5719-llvm-8df55b43e1a5f7acc9815b689940c6ac0de251ca.zip | |
Verify that no compile units share the same line table in "llvm-dwarfdump --verify"
Check to make sure no compile units have the same DW_AT_stmt_list values. Report a verification error if they do.
Differential Revision: https://reviews.llvm.org/D32771
llvm-svn: 302039
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/DebugInfo/DWARF/DWARFContext.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp index 84aa0909b6d..2733bef7bae 100644 --- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp @@ -447,11 +447,13 @@ public: } bool HandleDebugLine() { + std::map<uint64_t, DWARFDie> StmtListToDie; bool Success = true; OS << "Verifying .debug_line...\n"; for (const auto &CU : DCtx.compile_units()) { uint32_t LineTableOffset = 0; - auto StmtFormValue = CU->getUnitDIE().find(DW_AT_stmt_list); + auto CUDie = CU->getUnitDIE(); + auto StmtFormValue = CUDie.find(DW_AT_stmt_list); if (!StmtFormValue) { // No line table for this compile unit. continue; @@ -468,6 +470,21 @@ public: // Skip this line table as it isn't valid. No need to create an error // here because we validate this in the .debug_info verifier. continue; + } else { + auto Iter = StmtListToDie.find(LineTableOffset); + if (Iter != StmtListToDie.end()) { + Success = false; + OS << "error: two compile unit DIEs, " + << format("0x%08" PRIx32, Iter->second.getOffset()) << " and " + << format("0x%08" PRIx32, CUDie.getOffset()) + << ", have the same DW_AT_stmt_list section offset:\n"; + Iter->second.dump(OS, 0); + CUDie.dump(OS, 0); + OS << '\n'; + // Already verified this line table before, no need to do it again. + continue; + } + StmtListToDie[LineTableOffset] = CUDie; } } auto LineTable = DCtx.getLineTableForUnit(CU.get()); @@ -475,7 +492,7 @@ public: Success = false; OS << "error: .debug_line[" << format("0x%08" PRIx32, LineTableOffset) << "] was not able to be parsed for CU:\n"; - CU->getUnitDIE().dump(OS, 0); + CUDie.dump(OS, 0); OS << '\n'; continue; } |

