From c93db3c16a199c33378d75d544da7a93df001cb9 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 3 Jul 2009 09:41:37 +0000 Subject: [PATCH] Don't require the .debug_str section. It's only needed for DW_FORM_strp attributes, but apparently those aren't generated by gcc 2. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31385 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/apps/debugger/dwarf/DwarfFile.cpp | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/apps/debugger/dwarf/DwarfFile.cpp b/src/apps/debugger/dwarf/DwarfFile.cpp index a60f888a30..8fb4dbefcc 100644 --- a/src/apps/debugger/dwarf/DwarfFile.cpp +++ b/src/apps/debugger/dwarf/DwarfFile.cpp @@ -74,9 +74,7 @@ DwarfFile::Load(const char* fileName) // get the interesting sections fDebugInfoSection = fElfFile->GetSection(".debug_info"); fDebugAbbrevSection = fElfFile->GetSection(".debug_abbrev"); - fDebugStringSection = fElfFile->GetSection(".debug_str"); - if (fDebugInfoSection == NULL || fDebugAbbrevSection == NULL - || fDebugStringSection == NULL) { + if (fDebugInfoSection == NULL || fDebugAbbrevSection == NULL) { fprintf(stderr, "DwarfManager::File::Load(\"%s\"): no " ".debug_info, .debug_abbrev, or .debug_str section.\n", fileName); @@ -84,6 +82,7 @@ DwarfFile::Load(const char* fileName) } // not mandatory sections + fDebugStringSection = fElfFile->GetSection(".debug_str"); fDebugRangesSection = fElfFile->GetSection(".debug_ranges"); fDebugLineSection = fElfFile->GetSection(".debug_line"); @@ -477,14 +476,20 @@ DwarfFile::_ParseEntryAttributes(DataReader& dataReader, break; case DW_FORM_strp: { - dwarf_off_t offset = dataReader.Read(0); - if (offset >= fDebugStringSection->Size()) { - fprintf(stderr, "Invalid DW_FORM_strp offset: %lu\n", - offset); + if (fDebugStringSection != NULL) { + dwarf_off_t offset = dataReader.Read(0); + if (offset >= fDebugStringSection->Size()) { + fprintf(stderr, "Invalid DW_FORM_strp offset: %lu\n", + offset); + return B_BAD_DATA; + } + attributeValue.SetToString( + (const char*)fDebugStringSection->Data() + offset); + } else { + fprintf(stderr, "Invalid DW_FORM_strp: no string " + "section!\n"); return B_BAD_DATA; } - attributeValue.SetToString( - (const char*)fDebugStringSection->Data() + offset); break; } case DW_FORM_udata: