Debugger: Add dedicated functions for global {un}init.
[haiku.git] / src / apps / debugger / debug_info / SpecificImageDebugInfo.cpp
blob0be04e63fd4b7900fa9c3937288328508b9c1b40
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 */
7 #include "SpecificImageDebugInfo.h"
9 #include "BasicFunctionDebugInfo.h"
10 #include "DebuggerInterface.h"
11 #include "Demangler.h"
12 #include "ImageInfo.h"
13 #include "SymbolInfo.h"
16 SpecificImageDebugInfo::~SpecificImageDebugInfo()
21 /*static*/ status_t
22 SpecificImageDebugInfo::GetFunctionsFromSymbols(
23 const BObjectList<SymbolInfo>& symbols,
24 BObjectList<FunctionDebugInfo>& functions, DebuggerInterface* interface,
25 const ImageInfo& imageInfo, SpecificImageDebugInfo* info)
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;
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;
43 return B_NO_MEMORY;
46 functionsAdded++;
49 return B_OK;