From fae657041d430f82d0a414df31d84d2aec20b664 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Fri, 22 Oct 2010 16:13:16 +0000 Subject: [PATCH] anevilyak+bonefish: Fix several instances of off-by-one errors when computing the data block for CFA expressions. This fixes unwinding the stack frame on gcc4.4. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@39047 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/dwarf/DwarfFile.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/apps/debugger/dwarf/DwarfFile.cpp b/src/apps/debugger/dwarf/DwarfFile.cpp index 5e919968a6..2a0a8fc4dc 100644 --- a/src/apps/debugger/dwarf/DwarfFile.cpp +++ b/src/apps/debugger/dwarf/DwarfFile.cpp @@ -430,6 +430,8 @@ DwarfFile::UnwindCallFrame(CompilationUnit* unit, bool dwarf64; off_t entryOffset = dataReader.Offset(); uint64 length = dataReader.ReadInitialLength(dwarf64); + TRACE_CFI("DwarfFile::UnwindCallFrame(): offset: %Lx, length: %Lx\n", + entryOffset, length); if (length > (uint64)dataReader.BytesRemaining()) return B_BAD_DATA; off_t lengthOffset = dataReader.Offset(); @@ -443,8 +445,10 @@ DwarfFile::UnwindCallFrame(CompilationUnit* unit, ? cieID == 0xffffffffffffffffULL : cieID == 0xffffffff)) { // this is a CIE -- skip it + TRACE_CFI("Skipping CIE: %Lx\n", cieID); previousCIE = entryOffset; } else { + TRACE_CFI("Found FDE\n"); // this is a FDE target_addr_t initialLocation = dataReader.ReadAddress(0); target_size_t addressRange = dataReader.ReadAddress(0); @@ -452,6 +456,8 @@ DwarfFile::UnwindCallFrame(CompilationUnit* unit, if (dataReader.HasOverflow()) return B_BAD_DATA; + TRACE_CFI("location: %Lx, initial location: %Lx, address range: %Lx\n", + location, initialLocation, addressRange); if (location >= initialLocation && location < initialLocation + addressRange) { // This is the FDE we're looking for. @@ -1656,8 +1662,8 @@ DwarfFile::_ParseFrameInfoInstructions(CompilationUnit* unit, } case DW_CFA_def_cfa_expression: { - uint8* block = (uint8*)dataReader.Data(); uint64 blockLength = dataReader.ReadUnsignedLEB128(0); + uint8* block = (uint8*)dataReader.Data(); dataReader.Skip(blockLength); TRACE_CFI(" DW_CFA_def_cfa_expression: %p, %llu\n", @@ -1670,8 +1676,8 @@ DwarfFile::_ParseFrameInfoInstructions(CompilationUnit* unit, case DW_CFA_expression: { uint32 reg = dataReader.ReadUnsignedLEB128(0); - uint8* block = (uint8*)dataReader.Data(); uint64 blockLength = dataReader.ReadUnsignedLEB128(0); + uint8* block = (uint8*)dataReader.Data(); dataReader.Skip(blockLength); TRACE_CFI(" DW_CFA_expression: reg: %lu, block: %p, " @@ -1752,8 +1758,8 @@ DwarfFile::_ParseFrameInfoInstructions(CompilationUnit* unit, case DW_CFA_val_expression: { uint32 reg = dataReader.ReadUnsignedLEB128(0); - uint8* block = (uint8*)dataReader.Data(); uint64 blockLength = dataReader.ReadUnsignedLEB128(0); + uint8* block = (uint8*)dataReader.Data(); dataReader.Skip(blockLength); TRACE_CFI(" DW_CFA_val_expression: reg: %lu, block: %p, "