diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2011-09-15 21:08:54 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2011-09-15 21:08:54 +0000 |
commit | 901339d0702fd11ff38a412e7f2cd0837ba4b140 (patch) | |
tree | 673a6dacb2f973d200957dd8fd5e4737f283cf40 /llvm/lib/DebugInfo | |
parent | bceb9e5c05fe64ec134a43747c4d1adf7692a24e (diff) | |
download | bcm5719-llvm-901339d0702fd11ff38a412e7f2cd0837ba4b140.tar.gz bcm5719-llvm-901339d0702fd11ff38a412e7f2cd0837ba4b140.zip |
DWARF: Don't crash when looking up an invalid address.
llvm-svn: 139846
Diffstat (limited to 'llvm/lib/DebugInfo')
-rw-r--r-- | llvm/lib/DebugInfo/DWARFContext.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/DebugInfo/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARFContext.cpp index 5fd4280ba7a..4fc0b301bef 100644 --- a/llvm/lib/DebugInfo/DWARFContext.cpp +++ b/llvm/lib/DebugInfo/DWARFContext.cpp @@ -147,13 +147,19 @@ DILineInfo DWARFContext::getLineInfoForAddress(uint64_t address) { uint32_t cuOffset = getDebugAranges()->offsetAtIndex(arangeIndex); // Retrieve the compile unit. DWARFCompileUnit *cu = getCompileUnitForOffset(cuOffset); + if (!cu) + return DILineInfo("<invalid>", 0, 0); // Get the line table for this compile unit. const DWARFDebugLine::LineTable *lineTable = getLineTableForCompileUnit(cu); + if (!lineTable) + return DILineInfo("<invalid>", 0, 0); // Get the index of the row we're looking for in the line table. uint64_t hiPC = cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_high_pc, -1ULL); uint32_t rowIndex = lineTable->lookupAddress(address, hiPC); + if (rowIndex == -1U) + return DILineInfo("<invalid>", 0, 0); // From here, contruct the DILineInfo. const DWARFDebugLine::Row &row = lineTable->Rows[rowIndex]; |