Extend SpecificImageDebugInfo::GetFunctions() ...
...to also take the list of symbols in the image as a parameter. This allows us to prefetch the symbols once in ImageInfo::FinishInit() for each image and then let each specific info subclass use them if/as needed, rather than having to do the entire symbol lookup/sort twice for every image. - Adjust callers accordingly.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -42,9 +43,10 @@ DebuggerImageDebugInfo::Init()
|
||||
|
||||
|
||||
status_t
|
||||
DebuggerImageDebugInfo::GetFunctions(BObjectList<FunctionDebugInfo>& functions)
|
||||
DebuggerImageDebugInfo::GetFunctions(const BObjectList<SymbolInfo>& symbols,
|
||||
BObjectList<FunctionDebugInfo>& functions)
|
||||
{
|
||||
return SpecificImageDebugInfo::GetFunctionsFromSymbols(functions,
|
||||
return SpecificImageDebugInfo::GetFunctionsFromSymbols(symbols, functions,
|
||||
fDebuggerInterface, fImageInfo, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef DEBUGGER_IMAGE_DEBUG_INFO_H
|
||||
@@ -26,6 +27,7 @@ public:
|
||||
status_t Init();
|
||||
|
||||
virtual status_t GetFunctions(
|
||||
const BObjectList<SymbolInfo>& symbols,
|
||||
BObjectList<FunctionDebugInfo>& functions);
|
||||
virtual status_t GetType(GlobalTypeCache* cache,
|
||||
const BString& name,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009-2012, Ingo Weinhold, [email protected].
|
||||
* Copyright 2012, Rene Gollent, [email protected].
|
||||
* Copyright 2012-2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -299,7 +299,8 @@ DwarfImageDebugInfo::Init()
|
||||
|
||||
|
||||
status_t
|
||||
DwarfImageDebugInfo::GetFunctions(BObjectList<FunctionDebugInfo>& functions)
|
||||
DwarfImageDebugInfo::GetFunctions(const BObjectList<SymbolInfo>& symbols,
|
||||
BObjectList<FunctionDebugInfo>& functions)
|
||||
{
|
||||
TRACE_IMAGES("DwarfImageDebugInfo::GetFunctions()\n");
|
||||
TRACE_IMAGES(" %" B_PRId32 " compilation units\n",
|
||||
@@ -414,7 +415,7 @@ DwarfImageDebugInfo::GetFunctions(BObjectList<FunctionDebugInfo>& functions)
|
||||
|
||||
// if we had no compilation units, fall back to providing basic
|
||||
// debug infos with DWARF-supported call frame unwinding
|
||||
return SpecificImageDebugInfo::GetFunctionsFromSymbols(functions,
|
||||
return SpecificImageDebugInfo::GetFunctionsFromSymbols(symbols, functions,
|
||||
fDebuggerInterface, fImageInfo, this);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2010-2012, Rene Gollent, [email protected].
|
||||
* Copyright 2010-2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef DWARF_IMAGE_DEBUG_INFO_H
|
||||
@@ -52,6 +52,7 @@ public:
|
||||
{ return fRelocationDelta; }
|
||||
|
||||
virtual status_t GetFunctions(
|
||||
const BObjectList<SymbolInfo>& symbols,
|
||||
BObjectList<FunctionDebugInfo>& functions);
|
||||
virtual status_t GetType(GlobalTypeCache* cache,
|
||||
const BString& name,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2010, Rene Gollent, [email protected].
|
||||
* Copyright 2010-2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -8,9 +8,11 @@
|
||||
|
||||
#include <new>
|
||||
|
||||
#include "DebuggerInterface.h"
|
||||
#include "FunctionDebugInfo.h"
|
||||
#include "FunctionInstance.h"
|
||||
#include "SpecificImageDebugInfo.h"
|
||||
#include "SymbolInfo.h"
|
||||
|
||||
|
||||
ImageDebugInfo::ImageDebugInfo(const ImageInfo& imageInfo)
|
||||
@@ -35,14 +37,21 @@ ImageDebugInfo::AddSpecificInfo(SpecificImageDebugInfo* info)
|
||||
|
||||
|
||||
status_t
|
||||
ImageDebugInfo::FinishInit()
|
||||
ImageDebugInfo::FinishInit(DebuggerInterface* interface)
|
||||
{
|
||||
BObjectList<SymbolInfo> symbols(50, true);
|
||||
status_t error = interface->GetSymbolInfos(fImageInfo.TeamID(),
|
||||
fImageInfo.ImageID(), symbols);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
symbols.SortItems(&_CompareSymbols);
|
||||
|
||||
// get functions -- get them from most expressive debug info first and add
|
||||
// missing functions from less expressive debug infos
|
||||
for (int32 i = 0; SpecificImageDebugInfo* specificInfo
|
||||
= fSpecificInfos.ItemAt(i); i++) {
|
||||
BObjectList<FunctionDebugInfo> functions;
|
||||
status_t error = specificInfo->GetFunctions(functions);
|
||||
error = specificInfo->GetFunctions(symbols, functions);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
@@ -175,3 +184,11 @@ ImageDebugInfo::_CompareAddressFunction(const target_addr_t* address,
|
||||
return -1;
|
||||
return *address < function->Address() + function->Size() ? 0 : 1;
|
||||
}
|
||||
|
||||
|
||||
/*static*/ int
|
||||
ImageDebugInfo::_CompareSymbols(const SymbolInfo* a, const SymbolInfo* b)
|
||||
{
|
||||
return a->Address() < b->Address()
|
||||
? -1 : (a->Address() == b->Address() ? 0 : 1);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2010, Rene Gollent, [email protected].
|
||||
* Copyright 2010-2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef IMAGE_DEBUG_INFO_H
|
||||
@@ -25,6 +25,7 @@ class FunctionInstance;
|
||||
class GlobalTypeCache;
|
||||
class LocatableFile;
|
||||
class SpecificImageDebugInfo;
|
||||
class SymbolInfo;
|
||||
class Type;
|
||||
class TypeLookupConstraints;
|
||||
|
||||
@@ -37,7 +38,7 @@ public:
|
||||
const ImageInfo& GetImageInfo() const { return fImageInfo; }
|
||||
|
||||
bool AddSpecificInfo(SpecificImageDebugInfo* info);
|
||||
status_t FinishInit();
|
||||
status_t FinishInit(DebuggerInterface* interface);
|
||||
|
||||
status_t GetType(GlobalTypeCache* cache,
|
||||
const BString& name,
|
||||
@@ -65,6 +66,8 @@ private:
|
||||
static int _CompareAddressFunction(
|
||||
const target_addr_t* address,
|
||||
const FunctionInstance* function);
|
||||
static int _CompareSymbols(const SymbolInfo* a,
|
||||
const SymbolInfo* b);
|
||||
|
||||
private:
|
||||
ImageInfo fImageInfo;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2013, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -19,19 +20,10 @@ SpecificImageDebugInfo::~SpecificImageDebugInfo()
|
||||
|
||||
/*static*/ status_t
|
||||
SpecificImageDebugInfo::GetFunctionsFromSymbols(
|
||||
const BObjectList<SymbolInfo>& symbols,
|
||||
BObjectList<FunctionDebugInfo>& functions, DebuggerInterface* interface,
|
||||
const ImageInfo& imageInfo, SpecificImageDebugInfo* info)
|
||||
{
|
||||
BObjectList<SymbolInfo> symbols(20, true);
|
||||
status_t error = interface->GetSymbolInfos(imageInfo.TeamID(),
|
||||
imageInfo.ImageID(), symbols);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
// sort the symbols -- not necessary, but a courtesy to ImageDebugInfo which
|
||||
// will peform better when inserting functions at the end of a list
|
||||
symbols.SortItems(&_CompareSymbols);
|
||||
|
||||
// create the function infos
|
||||
int32 functionsAdded = 0;
|
||||
for (int32 i = 0; SymbolInfo* symbol = symbols.ItemAt(i); i++) {
|
||||
@@ -56,11 +48,3 @@ SpecificImageDebugInfo::GetFunctionsFromSymbols(
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
/*static*/ int
|
||||
SpecificImageDebugInfo::_CompareSymbols(const SymbolInfo* a,
|
||||
const SymbolInfo* b)
|
||||
{
|
||||
return a->Address() < b->Address()
|
||||
? -1 : (a->Address() == b->Address() ? 0 : 1);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2013, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef SPECIFIC_IMAGE_DEBUG_INFO_H
|
||||
@@ -41,6 +42,7 @@ public:
|
||||
virtual ~SpecificImageDebugInfo();
|
||||
|
||||
virtual status_t GetFunctions(
|
||||
const BObjectList<SymbolInfo>& symbols,
|
||||
BObjectList<FunctionDebugInfo>& functions)
|
||||
= 0;
|
||||
// returns references
|
||||
@@ -87,14 +89,12 @@ public:
|
||||
|
||||
protected:
|
||||
static status_t GetFunctionsFromSymbols(
|
||||
const BObjectList<SymbolInfo>& symbols,
|
||||
BObjectList<FunctionDebugInfo>& functions,
|
||||
DebuggerInterface* interface,
|
||||
const ImageInfo& imageInfo,
|
||||
SpecificImageDebugInfo* info);
|
||||
|
||||
private:
|
||||
static int _CompareSymbols(const SymbolInfo* a,
|
||||
const SymbolInfo* b);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
||||
* Copyright 2012, Rene Gollent, rene@gollent.com.
|
||||
* Copyright 2012-2013, Rene Gollent, rene@gollent.com.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
@@ -448,7 +448,7 @@ TeamDebugInfo::LoadImageDebugInfo(const ImageInfo& imageInfo,
|
||||
// fail only when out of memory
|
||||
}
|
||||
|
||||
status_t error = imageDebugInfo->FinishInit();
|
||||
status_t error = imageDebugInfo->FinishInit(fDebuggerInterface);
|
||||
if (error != B_OK)
|
||||
return error;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user