1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 03:33:20 +01:00

DWARF: Don't crash when looking up an invalid address.

llvm-svn: 139846
This commit is contained in:
Benjamin Kramer 2011-09-15 21:08:54 +00:00
parent 6ccd8e9c0d
commit 912beeec25

View File

@ -147,13 +147,19 @@ DILineInfo DWARFContext::getLineInfoForAddress(uint64_t address) {
uint32_t cuOffset = getDebugAranges()->offsetAtIndex(arangeIndex); uint32_t cuOffset = getDebugAranges()->offsetAtIndex(arangeIndex);
// Retrieve the compile unit. // Retrieve the compile unit.
DWARFCompileUnit *cu = getCompileUnitForOffset(cuOffset); DWARFCompileUnit *cu = getCompileUnitForOffset(cuOffset);
if (!cu)
return DILineInfo("<invalid>", 0, 0);
// Get the line table for this compile unit. // Get the line table for this compile unit.
const DWARFDebugLine::LineTable *lineTable = getLineTableForCompileUnit(cu); 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. // Get the index of the row we're looking for in the line table.
uint64_t hiPC = uint64_t hiPC =
cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_high_pc, cu->getCompileUnitDIE()->getAttributeValueAsUnsigned(cu, DW_AT_high_pc,
-1ULL); -1ULL);
uint32_t rowIndex = lineTable->lookupAddress(address, hiPC); uint32_t rowIndex = lineTable->lookupAddress(address, hiPC);
if (rowIndex == -1U)
return DILineInfo("<invalid>", 0, 0);
// From here, contruct the DILineInfo. // From here, contruct the DILineInfo.
const DWARFDebugLine::Row &row = lineTable->Rows[rowIndex]; const DWARFDebugLine::Row &row = lineTable->Rows[rowIndex];