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