Debugger: Fix CFI length computation.

- Due to a slight oversight during optimization refactoring, the length
  of the FDE's call frame instructions would sometimes be computed
  incorrectly, leading us to overflow past the end of the instructions,
  and fail to unwind the frame correctly if the address in question fell
  at the end. Fixes a regression introduced in commit
  d390ebee9e.
This commit is contained in:
Rene Gollent
2014-11-16 00:17:11 -05:00
parent a46669aa1c
commit c87c95791e
+5 -5
View File
@@ -1900,10 +1900,6 @@ DwarfFile::_UnwindCallFrame(CompilationUnit* unit, uint8 addressSize,
if (cieRemaining < 0)
return B_BAD_DATA;
uint64 remaining = lengthOffset + length - info->fdeOffset;
if (remaining < 0)
return B_BAD_DATA;
// skip CIE ID, initial offset and range, since we already know those
// from FDELookupInfo.
dwarf64 ? dataReader.Read<uint64>(0) : dataReader.Read<uint32>(0);
@@ -1947,6 +1943,10 @@ DwarfFile::_UnwindCallFrame(CompilationUnit* unit, uint8 addressSize,
if (error != B_OK)
return error;
uint64 remaining = lengthOffset + length - dataReader.Offset();
if (remaining < 0)
return B_BAD_DATA;
DataReader restrictedReader =
dataReader.RestrictedReader(remaining);
error = _ParseFrameInfoInstructions(unit, context,
@@ -2552,7 +2552,7 @@ DwarfFile::_ParseFrameInfoInstructions(CompilationUnit* unit,
}
default:
WARNING(" unknown opcode %u!\n", opcode);
TRACE_CFI(" unknown opcode %u!\n", opcode);
return B_BAD_DATA;
}
}