1 /* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2013, Rene Gollent, rene@gollent.com. 4 * Distributed under the terms of the MIT License. 5 */ 6 7 #include "SpecificImageDebugInfo.h" 8 9 #include "BasicFunctionDebugInfo.h" 10 #include "DebuggerInterface.h" 11 #include "Demangler.h" 12 #include "ImageInfo.h" 13 #include "SymbolInfo.h" 14 15 16 SpecificImageDebugInfo::~SpecificImageDebugInfo() 17 { 18 } 19 20 21 /*static*/ status_t 22 SpecificImageDebugInfo::GetFunctionsFromSymbols( 23 const BObjectList<SymbolInfo>& symbols, 24 BObjectList<FunctionDebugInfo>& functions, DebuggerInterface* interface, 25 const ImageInfo& imageInfo, SpecificImageDebugInfo* info) 26 { 27 // create the function infos 28 int32 functionsAdded = 0; 29 for (int32 i = 0; SymbolInfo* symbol = symbols.ItemAt(i); i++) { 30 if (symbol->Type() != B_SYMBOL_TYPE_TEXT) 31 continue; 32 33 FunctionDebugInfo* function = new(std::nothrow) BasicFunctionDebugInfo( 34 info, symbol->Address(), symbol->Size(), symbol->Name(), 35 Demangler::Demangle(symbol->Name())); 36 if (function == NULL || !functions.AddItem(function)) { 37 delete function; 38 int32 index = functions.CountItems() - 1; 39 for (; functionsAdded >= 0; functionsAdded--, index--) { 40 function = functions.RemoveItemAt(index); 41 delete function; 42 } 43 return B_NO_MEMORY; 44 } 45 46 functionsAdded++; 47 } 48 49 return B_OK; 50 } 51