From dbf07c84a22f5b395d00d66e7d3b0e1160cb2f13 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Mon, 28 May 2012 15:39:38 -0400 Subject: [PATCH] Fix problems unwinding call frames. Our more recent build of gcc4 appears to have switched to using .eh_frame for almost all useful call frame information when built with debugging. Use a somewhat crude heuristic (size) to determine if the .debug_frame section we've been given might actually be of use or not (assuming it exists at all, this was inconsistent in my tests. Sometimes apps had no .debug_frame at all, other times it was present but was only roundabouts 100 bytes). Fixes ticket #8508. --- src/apps/debugger/dwarf/DwarfFile.cpp | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/apps/debugger/dwarf/DwarfFile.cpp b/src/apps/debugger/dwarf/DwarfFile.cpp index 647edbb393..d4cb185c49 100644 --- a/src/apps/debugger/dwarf/DwarfFile.cpp +++ b/src/apps/debugger/dwarf/DwarfFile.cpp @@ -350,15 +350,25 @@ DwarfFile::Load(const char* fileName) fDebugRangesSection = fElfFile->GetSection(".debug_ranges"); fDebugLineSection = fElfFile->GetSection(".debug_line"); fDebugFrameSection = fElfFile->GetSection(".debug_frame"); - if (fDebugFrameSection == NULL) { - fDebugFrameSection = fElfFile->GetSection(".eh_frame"); - fUsingEHFrameSection = fDebugFrameSection != NULL; - if (fUsingEHFrameSection) { - fGCC4EHFrameSection = !fDebugFrameSection->IsWritable(); - // Crude heuristic for recognizing GCC 4 (Itanium ABI) style - // .eh_frame sections. The ones generated by GCC 2 are writable, - // the ones generated by GCC 4 aren't. + ElfSection* ehFrameSection = fElfFile->GetSection(".eh_frame"); + if (fDebugFrameSection != NULL) { + if (ehFrameSection != NULL && ehFrameSection->Size() + > fDebugFrameSection->Size()) { + fElfFile->PutSection(fDebugFrameSection); + fDebugFrameSection = ehFrameSection; + fUsingEHFrameSection = true; } + + } else if (ehFrameSection != NULL) { + fDebugFrameSection = ehFrameSection; + fUsingEHFrameSection = true; + } + + if (fUsingEHFrameSection) { + fGCC4EHFrameSection = !fDebugFrameSection->IsWritable(); + // Crude heuristic for recognizing GCC 4 (Itanium ABI) style + // .eh_frame sections. The ones generated by GCC 2 are writable, + // the ones generated by GCC 4 aren't. } fDebugLocationSection = fElfFile->GetSection(".debug_loc"); fDebugPublicTypesSection = fElfFile->GetSection(".debug_pubtypes");