From c87c95791ef7efc2f7ad566824217007e1949d08 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sun, 16 Nov 2014 00:15:11 -0500 Subject: [PATCH] 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 d390ebee9e7355ca364f0e105374a33907a5a7cb. --- src/apps/debugger/dwarf/DwarfFile.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/apps/debugger/dwarf/DwarfFile.cpp b/src/apps/debugger/dwarf/DwarfFile.cpp index 8ef735321b..8d4ec5ab42 100644 --- a/src/apps/debugger/dwarf/DwarfFile.cpp +++ b/src/apps/debugger/dwarf/DwarfFile.cpp @@ -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(0) : dataReader.Read(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; } }