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 | f5b0accf43a4fa22fc6050daac59441e3c9288b0 (patch) | |
tree | 65941651942dc014dd766531cec52733d59ddda2 /lib/DebugInfo | |
parent | b9edad0163296e02f7b4dbbc22b50615dede357c (diff) | |
download | external_llvm-f5b0accf43a4fa22fc6050daac59441e3c9288b0.zip external_llvm-f5b0accf43a4fa22fc6050daac59441e3c9288b0.tar.gz external_llvm-f5b0accf43a4fa22fc6050daac59441e3c9288b0.tar.bz2 |
DWARF: Don't crash when looking up an invalid address.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@139846 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/DebugInfo')
-rw-r--r-- | lib/DebugInfo/DWARFContext.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/DebugInfo/DWARFContext.cpp b/lib/DebugInfo/DWARFContext.cpp index 5fd4280..4fc0b30 100644 --- a/lib/DebugInfo/DWARFContext.cpp +++ b/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]; |