* Some moving and renaming.

* Added TeamDebugInfo which serves as factory for ImageDebugInfos.
* Added the DWARF code to the build again. It's not used yet, though.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31278 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold 2009-06-27 21:09:21 +00:00
parent 10f01c97ec
commit 671ef9b084
26 changed files with 394 additions and 142 deletions

View File

@ -10,6 +10,8 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) arch ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) arch x86 ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) debug_info ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) debugger_interface ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) dwarf ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) elf ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) gui team_window ] ;
SEARCH_SOURCE += [ FDirName $(SUBDIR) model ] ;
@ -23,7 +25,6 @@ SubDirHdrs [ FDirName $(debugAnalyzerSources) gui ] ;
Application Debugger :
BreakpointManager.cpp
Debugger.cpp
# ElfFile.cpp
Jobs.cpp
TeamDebugger.cpp
ThreadHandler.cpp
@ -41,16 +42,31 @@ Application Debugger :
# debug_info
BasicFunctionDebugInfo.cpp
DebuggerDebugInfo.cpp
DebugInfo.cpp
DebuggerImageDebugInfo.cpp
DebuggerTeamDebugInfo.cpp
FunctionDebugInfo.cpp
ImageDebugInfo.cpp
ImageDebugInfoProvider.cpp
SpecificImageDebugInfo.cpp
SpecificTeamDebugInfo.cpp
TeamDebugInfo.cpp
# debugger_interface
DebugEvent.cpp
DebuggerInterface.cpp
# dwarf
attribute_classes.cpp
AttributeValue.cpp
DebugInfoEntries.cpp
DebugInfoEntry.cpp
DwarfManager.cpp
SourceLanguageInfo.cpp
tag_names.cpp
# elf
ElfFile.cpp
# gui/team_window
ImageFunctionsView.cpp
ImageListView.cpp
@ -76,15 +92,6 @@ Application Debugger :
Thread.cpp
ThreadInfo.cpp
# DWARF
# attribute_classes.cpp
# AttributeValue.cpp
# DebugInfoEntries.cpp
# DebugInfoEntry.cpp
# DwarfManager.cpp
# SourceLanguageInfo.cpp
# tag_names.cpp
:
<nogrist>Debugger_demangler.o
<nogrist>Debugger_disasm_x86.o

View File

@ -12,13 +12,14 @@
#include "Architecture.h"
#include "CpuState.h"
#include "DebuggerInterface.h"
#include "DebugInfo.h"
#include "FunctionDebugInfo.h"
#include "Image.h"
#include "ImageDebugInfo.h"
#include "SourceCode.h"
#include "SpecificImageDebugInfo.h"
#include "StackTrace.h"
#include "Team.h"
#include "TeamDebugInfo.h"
#include "Thread.h"
@ -182,8 +183,8 @@ GetStackTraceJob::GetImageDebugInfo(Image* image, ImageDebugInfo*& _info)
while (image->GetImageDebugInfo() == NULL) {
// schedule a job, if not loaded
ImageDebugInfo* info;
status_t error = LoadImageDebugInfoJob::ScheduleIfNecessary(
fDebuggerInterface, fArchitecture, GetWorker(), image, &info);
status_t error = LoadImageDebugInfoJob::ScheduleIfNecessary(GetWorker(),
image, &info);
if (error != B_OK)
return error;
@ -220,12 +221,8 @@ GetStackTraceJob::GetImageDebugInfo(Image* image, ImageDebugInfo*& _info)
// #pragma mark - LoadImageDebugInfoJob
LoadImageDebugInfoJob::LoadImageDebugInfoJob(
DebuggerInterface* debuggerInterface, Architecture* architecture,
Image* image)
LoadImageDebugInfoJob::LoadImageDebugInfoJob(Image* image)
:
fDebuggerInterface(debuggerInterface),
fArchitecture(architecture),
fImage(image)
{
fImage->AddReference();
@ -254,14 +251,9 @@ LoadImageDebugInfoJob::Do()
locker.Unlock();
// create the debug info
ImageDebugInfo* debugInfo = new(std::nothrow) ImageDebugInfo(imageInfo,
fDebuggerInterface, fArchitecture);
status_t error;;
if (debugInfo != NULL)
error = debugInfo->Init();
else
error = B_NO_MEMORY;
ImageDebugInfo* debugInfo;
status_t error = fImage->GetTeam()->DebugInfo()->LoadImageDebugInfo(
imageInfo, debugInfo);
// set the result
locker.Lock();
@ -278,8 +270,7 @@ LoadImageDebugInfoJob::Do()
/*static*/ status_t
LoadImageDebugInfoJob::ScheduleIfNecessary(DebuggerInterface* debuggerInterface,
Architecture* architecture, Worker* worker, Image* image,
LoadImageDebugInfoJob::ScheduleIfNecessary(Worker* worker, Image* image,
ImageDebugInfo** _imageDebugInfo)
{
AutoLocker<Team> teamLocker(image->GetTeam());
@ -305,8 +296,7 @@ LoadImageDebugInfoJob::ScheduleIfNecessary(DebuggerInterface* debuggerInterface,
return B_ERROR;
// schedule a job
LoadImageDebugInfoJob* job = new(std::nothrow) LoadImageDebugInfoJob(
debuggerInterface, architecture, image);
LoadImageDebugInfoJob* job = new(std::nothrow) LoadImageDebugInfoJob(image);
if (job == NULL)
return B_NO_MEMORY;
@ -358,8 +348,8 @@ LoadSourceCodeJob::Do()
{
// load the source code, if we can
SourceCode* sourceCode = NULL;
status_t error = fFunction->GetDebugInfo()->LoadSourceCode(fFunction,
sourceCode);
status_t error = fFunction->GetSpecificImageDebugInfo()->LoadSourceCode(
fFunction, sourceCode);
// set the result
AutoLocker<Team> locker(fTeam);

View File

@ -86,18 +86,13 @@ private:
class LoadImageDebugInfoJob : public Job {
public:
LoadImageDebugInfoJob(
DebuggerInterface* debuggerInterface,
Architecture* architecture,
Image* image);
LoadImageDebugInfoJob(Image* image);
virtual ~LoadImageDebugInfoJob();
virtual JobKey Key() const;
virtual status_t Do();
static status_t ScheduleIfNecessary(
DebuggerInterface* debuggerInterface,
Architecture* architecture, Worker* worker,
static status_t ScheduleIfNecessary(Worker* worker,
Image* image,
ImageDebugInfo** _imageDebugInfo = NULL);
// If already loaded returns a
@ -109,8 +104,6 @@ public:
// earlier.
private:
DebuggerInterface* fDebuggerInterface;
Architecture* fArchitecture;
Image* fImage;
};

View File

@ -23,6 +23,7 @@
#include "Jobs.h"
#include "MessageCodes.h"
#include "Statement.h"
#include "TeamDebugInfo.h"
#include "TeamDebugModel.h"
@ -91,14 +92,35 @@ TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain)
{
fTeamID = teamID;
// create debugger interface
fDebuggerInterface = new(std::nothrow) DebuggerInterface(fTeamID);
if (fDebuggerInterface == NULL)
return B_NO_MEMORY;
status_t error = fDebuggerInterface->Init();
if (error != B_OK)
return error;
// create team debug info
TeamDebugInfo* teamDebugInfo = new(std::nothrow) TeamDebugInfo(
fDebuggerInterface, fDebuggerInterface->GetArchitecture());
if (teamDebugInfo == NULL)
return B_NO_MEMORY;
Reference<TeamDebugInfo> teamDebugInfoReference(teamDebugInfo);
error = teamDebugInfo->Init();
if (error != B_OK)
return error;
// check whether the team exists at all
// TODO: That should be done in the debugger interface!
team_info teamInfo;
status_t error = get_team_info(fTeamID, &teamInfo);
error = get_team_info(fTeamID, &teamInfo);
if (error != B_OK)
return error;
// create a team object
fTeam = new(std::nothrow) ::Team(fTeamID);
fTeam = new(std::nothrow) ::Team(fTeamID, teamDebugInfo);
if (fTeam == NULL)
return B_NO_MEMORY;
@ -124,15 +146,6 @@ TeamDebugger::Init(team_id teamID, thread_id threadID, bool stopInMain)
if (error != B_OK)
return error;
// create debugger interface
fDebuggerInterface = new(std::nothrow) DebuggerInterface(fTeamID);
if (fDebuggerInterface == NULL)
return B_NO_MEMORY;
error = fDebuggerInterface->Init();
if (error != B_OK)
return error;
// create the team debug model
fDebugModel = new(std::nothrow) TeamDebugModel(fTeam, fDebuggerInterface,
fDebuggerInterface->GetArchitecture());
@ -351,8 +364,7 @@ TeamDebugger::FunctionSourceCodeRequested(TeamWindow* window,
void
TeamDebugger::ImageDebugInfoRequested(TeamWindow* window, Image* image)
{
LoadImageDebugInfoJob::ScheduleIfNecessary(fDebuggerInterface,
fDebuggerInterface->GetArchitecture(), fWorker, image);
LoadImageDebugInfoJob::ScheduleIfNecessary(fWorker, image);
}

View File

@ -18,6 +18,7 @@
class DebuggerInterface;
class TeamDebugInfo;
class TeamDebugModel;
@ -97,6 +98,7 @@ private:
ThreadHandlerTable fThreadHandlers;
// protected by the team lock
DebuggerInterface* fDebuggerInterface;
TeamDebugInfo* fTeamDebugInfo;
Worker* fWorker;
BreakpointManager* fBreakpointManager;
thread_id fDebugEventListener;

View File

@ -15,13 +15,13 @@
#include "BreakpointManager.h"
#include "CpuState.h"
#include "DebuggerInterface.h"
#include "DebugInfo.h"
#include "FunctionDebugInfo.h"
#include "ImageDebugInfo.h"
#include "InstructionInfo.h"
#include "Jobs.h"
#include "MessageCodes.h"
#include "SourceCode.h"
#include "SpecificImageDebugInfo.h"
#include "StackTrace.h"
#include "Statement.h"
#include "Team.h"
@ -381,7 +381,7 @@ ThreadHandler::_GetStatementAtInstructionPointer(StackFrame* frame)
// We need to get the statement from the debug info of the function.
Statement* statement;
if (function->GetDebugInfo()->GetStatement(function,
if (function->GetSpecificImageDebugInfo()->GetStatement(function,
frame->InstructionPointer(), statement) != B_OK) {
return NULL;
}

View File

@ -11,11 +11,11 @@
#include <AutoLocker.h>
#include "CpuState.h"
#include "DebugInfo.h"
#include "FunctionDebugInfo.h"
#include "Image.h"
#include "ImageDebugInfo.h"
#include "ImageDebugInfoProvider.h"
#include "SpecificImageDebugInfo.h"
#include "StackTrace.h"
#include "Team.h"
@ -90,8 +90,8 @@ Architecture::CreateStackTrace(Team* team,
StackFrame* previousFrame = NULL;
CpuState* previousCpuState = NULL;
if (function != NULL) {
status_t error = function->GetDebugInfo()->CreateFrame(image,
function, cpuState, previousFrame, previousCpuState);
status_t error = function->GetSpecificImageDebugInfo()->CreateFrame(
image, function, cpuState, previousFrame, previousCpuState);
if (error != B_OK && error != B_UNSUPPORTED)
break;
}

View File

@ -5,33 +5,33 @@
#include "BasicFunctionDebugInfo.h"
#include "DebugInfo.h"
#include "SpecificImageDebugInfo.h"
BasicFunctionDebugInfo::BasicFunctionDebugInfo(DebugInfo* debugInfo,
target_addr_t address, target_size_t size, const BString& name,
const BString& prettyName)
BasicFunctionDebugInfo::BasicFunctionDebugInfo(
SpecificImageDebugInfo* debugInfo, target_addr_t address,
target_size_t size, const BString& name, const BString& prettyName)
:
fDebugInfo(debugInfo),
fImageDebugInfo(debugInfo),
fAddress(address),
fSize(size),
fName(name),
fPrettyName(prettyName)
{
fDebugInfo->AddReference();
fImageDebugInfo->AddReference();
}
BasicFunctionDebugInfo::~BasicFunctionDebugInfo()
{
fDebugInfo->RemoveReference();
fImageDebugInfo->RemoveReference();
}
DebugInfo*
BasicFunctionDebugInfo::GetDebugInfo() const
SpecificImageDebugInfo*
BasicFunctionDebugInfo::GetSpecificImageDebugInfo() const
{
return fDebugInfo;
return fImageDebugInfo;
}

View File

@ -13,14 +13,14 @@
class BasicFunctionDebugInfo : public FunctionDebugInfo {
public:
BasicFunctionDebugInfo(
DebugInfo* debugInfo,
SpecificImageDebugInfo* imageDebugInfo,
target_addr_t address,
target_size_t size,
const BString& name,
const BString& prettyName);
virtual ~BasicFunctionDebugInfo();
virtual DebugInfo* GetDebugInfo() const;
virtual SpecificImageDebugInfo* GetSpecificImageDebugInfo() const;
virtual target_addr_t Address() const;
virtual target_size_t Size() const;
virtual const char* Name() const;
@ -31,7 +31,7 @@ public:
virtual SourceLocation SourceEndLocation() const;
private:
DebugInfo* fDebugInfo;
SpecificImageDebugInfo* fImageDebugInfo;
target_addr_t fAddress;
target_size_t fSize;
const BString fName;

View File

@ -3,7 +3,7 @@
* Distributed under the terms of the MIT License.
*/
#include "DebuggerDebugInfo.h"
#include "DebuggerImageDebugInfo.h"
#include <algorithm>
#include <new>
@ -17,7 +17,7 @@
#include "SymbolInfo.h"
DebuggerDebugInfo::DebuggerDebugInfo(const ImageInfo& imageInfo,
DebuggerImageDebugInfo::DebuggerImageDebugInfo(const ImageInfo& imageInfo,
DebuggerInterface* debuggerInterface, Architecture* architecture)
:
fImageInfo(imageInfo),
@ -27,20 +27,20 @@ DebuggerDebugInfo::DebuggerDebugInfo(const ImageInfo& imageInfo,
}
DebuggerDebugInfo::~DebuggerDebugInfo()
DebuggerImageDebugInfo::~DebuggerImageDebugInfo()
{
}
status_t
DebuggerDebugInfo::Init()
DebuggerImageDebugInfo::Init()
{
return B_OK;
}
status_t
DebuggerDebugInfo::GetFunctions(BObjectList<FunctionDebugInfo>& functions)
DebuggerImageDebugInfo::GetFunctions(BObjectList<FunctionDebugInfo>& functions)
{
BObjectList<SymbolInfo> symbols(20, true);
status_t error = fDebuggerInterface->GetSymbolInfos(fImageInfo.TeamID(),
@ -79,7 +79,7 @@ DebuggerDebugInfo::GetFunctions(BObjectList<FunctionDebugInfo>& functions)
status_t
DebuggerDebugInfo::CreateFrame(Image* image, FunctionDebugInfo* function,
DebuggerImageDebugInfo::CreateFrame(Image* image, FunctionDebugInfo* function,
CpuState* cpuState, StackFrame*& _previousFrame,
CpuState*& _previousCpuState)
{
@ -88,7 +88,7 @@ DebuggerDebugInfo::CreateFrame(Image* image, FunctionDebugInfo* function,
status_t
DebuggerDebugInfo::LoadSourceCode(FunctionDebugInfo* function,
DebuggerImageDebugInfo::LoadSourceCode(FunctionDebugInfo* function,
SourceCode*& _sourceCode)
{
// allocate a buffer for the function code
@ -111,7 +111,7 @@ DebuggerDebugInfo::LoadSourceCode(FunctionDebugInfo* function,
status_t
DebuggerDebugInfo::GetStatement(FunctionDebugInfo* function,
DebuggerImageDebugInfo::GetStatement(FunctionDebugInfo* function,
target_addr_t address, Statement*& _statement)
{
return fArchitecture->GetStatement(function, address, _statement);
@ -119,7 +119,8 @@ DebuggerDebugInfo::GetStatement(FunctionDebugInfo* function,
/*static*/ int
DebuggerDebugInfo::_CompareSymbols(const SymbolInfo* a, const SymbolInfo* b)
DebuggerImageDebugInfo::_CompareSymbols(const SymbolInfo* a,
const SymbolInfo* b)
{
return a->Address() < b->Address()
? -1 : (a->Address() == b->Address() ? 0 : 1);

View File

@ -2,13 +2,13 @@
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef DEBUGGER_DEBUG_INFO_H
#define DEBUGGER_DEBUG_INFO_H
#ifndef DEBUGGER_IMAGE_DEBUG_INFO_H
#define DEBUGGER_IMAGE_DEBUG_INFO_H
#include <String.h>
#include "DebugInfo.h"
#include "ImageInfo.h"
#include "SpecificImageDebugInfo.h"
class Architecture;
@ -17,12 +17,13 @@ class FunctionDebugInfo;
class SymbolInfo;
class DebuggerDebugInfo : public DebugInfo {
class DebuggerImageDebugInfo : public SpecificImageDebugInfo {
public:
DebuggerDebugInfo(const ImageInfo& imageInfo,
DebuggerImageDebugInfo(
const ImageInfo& imageInfo,
DebuggerInterface* debuggerInterface,
Architecture* architecture);
virtual ~DebuggerDebugInfo();
virtual ~DebuggerImageDebugInfo();
status_t Init();
@ -50,4 +51,4 @@ private:
};
#endif // DEBUGGER_DEBUG_INFO_H
#endif // DEBUGGER_IMAGE_DEBUG_INFO_H

View File

@ -0,0 +1,52 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#include "DebuggerTeamDebugInfo.h"
#include <new>
#include "DebuggerImageDebugInfo.h"
DebuggerTeamDebugInfo::DebuggerTeamDebugInfo(
DebuggerInterface* debuggerInterface, Architecture* architecture)
:
fDebuggerInterface(debuggerInterface),
fArchitecture(architecture)
{
}
DebuggerTeamDebugInfo::~DebuggerTeamDebugInfo()
{
}
status_t
DebuggerTeamDebugInfo::Init()
{
return B_OK;
}
status_t
DebuggerTeamDebugInfo::CreateImageDebugInfo(const ImageInfo& imageInfo,
SpecificImageDebugInfo*& _imageDebugInfo)
{
DebuggerImageDebugInfo* debuggerInfo
= new(std::nothrow) DebuggerImageDebugInfo(imageInfo,
fDebuggerInterface, fArchitecture);
if (debuggerInfo == NULL)
return B_NO_MEMORY;
status_t error = debuggerInfo->Init();
if (error != B_OK) {
delete debuggerInfo;
return error;
}
_imageDebugInfo = debuggerInfo;
return B_OK;
}

View File

@ -0,0 +1,36 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef DEBUGGER_TEAM_DEBUG_INFO_H
#define DEBUGGER_TEAM_DEBUG_INFO_H
#include "SpecificTeamDebugInfo.h"
class Architecture;
class DebuggerInterface;
class FunctionDebugInfo;
class ImageInfo;
class DebuggerTeamDebugInfo : public SpecificTeamDebugInfo {
public:
DebuggerTeamDebugInfo(
DebuggerInterface* debuggerInterface,
Architecture* architecture);
virtual ~DebuggerTeamDebugInfo();
status_t Init();
virtual status_t CreateImageDebugInfo(const ImageInfo& imageInfo,
SpecificImageDebugInfo*& _imageDebugInfo);
private:
DebuggerInterface* fDebuggerInterface;
Architecture* fArchitecture;
};
#endif // DEBUGGER_TEAM_DEBUG_INFO_H

View File

@ -20,8 +20,8 @@ enum function_source_state {
};
class DebugInfo;
class SourceCode;
class SpecificImageDebugInfo;
class FunctionDebugInfo : public Referenceable {
@ -32,7 +32,7 @@ public:
FunctionDebugInfo();
virtual ~FunctionDebugInfo();
virtual DebugInfo* GetDebugInfo() const = 0;
virtual SpecificImageDebugInfo* GetSpecificImageDebugInfo() const = 0;
virtual target_addr_t Address() const = 0;
virtual target_size_t Size() const = 0;
virtual const char* Name() const = 0;

View File

@ -7,16 +7,13 @@
#include <new>
#include "DebuggerDebugInfo.h"
#include "FunctionDebugInfo.h"
#include "SpecificImageDebugInfo.h"
ImageDebugInfo::ImageDebugInfo(const ImageInfo& imageInfo,
DebuggerInterface* debuggerInterface, Architecture* architecture)
ImageDebugInfo::ImageDebugInfo(const ImageInfo& imageInfo)
:
fImageInfo(imageInfo),
fDebuggerInterface(debuggerInterface),
fArchitecture(architecture)
fImageInfo(imageInfo)
{
}
@ -28,36 +25,22 @@ ImageDebugInfo::~ImageDebugInfo()
}
status_t
ImageDebugInfo::Init()
bool
ImageDebugInfo::AddSpecificInfo(SpecificImageDebugInfo* info)
{
// Create debug infos for every kind debug info available, sorted
// descendingly by expressiveness.
return fSpecificInfos.AddItem(info);
}
// TODO: DWARF, etc.
// debugger based info
DebuggerDebugInfo* debuggerDebugInfo = new(std::nothrow) DebuggerDebugInfo(
fImageInfo, fDebuggerInterface, fArchitecture);
if (debuggerDebugInfo == NULL)
return B_NO_MEMORY;
status_t error = debuggerDebugInfo->Init();
if (error == B_OK && !fDebugInfos.AddItem(debuggerDebugInfo))
error = B_NO_MEMORY;
if (error != B_OK) {
delete debuggerDebugInfo;
if (error == B_NO_MEMORY)
return error;
// only "no memory" is fatal
}
status_t
ImageDebugInfo::FinishInit()
{
// get functions -- get them from most expressive debug info first and add
// missing functions from less expressive debug infos
for (int32 i = 0; DebugInfo* debugInfo = fDebugInfos.ItemAt(i); i++) {
for (int32 i = 0; SpecificImageDebugInfo* specificInfo
= fSpecificInfos.ItemAt(i); i++) {
FunctionList functions;
status_t error = debugInfo->GetFunctions(functions);
status_t error = specificInfo->GetFunctions(functions);
if (error != B_OK)
return error;

View File

@ -16,25 +16,24 @@
class Architecture;
class DebuggerInterface;
class DebugInfo;
class FunctionDebugInfo;
class SpecificImageDebugInfo;
class ImageDebugInfo : public Referenceable {
public:
ImageDebugInfo(const ImageInfo& imageInfo,
DebuggerInterface* debuggerInterface,
Architecture* architecture);
ImageDebugInfo(const ImageInfo& imageInfo),
~ImageDebugInfo();
status_t Init();
bool AddSpecificInfo(SpecificImageDebugInfo* info);
status_t FinishInit();
int32 CountFunctions() const;
FunctionDebugInfo* FunctionAt(int32 index) const;
FunctionDebugInfo* FunctionAtAddress(target_addr_t address) const;
private:
typedef BObjectList<DebugInfo> DebugInfoList;
typedef BObjectList<SpecificImageDebugInfo> SpecificInfoList;
typedef BObjectList<FunctionDebugInfo> FunctionList;
private:
@ -46,9 +45,7 @@ private:
private:
ImageInfo fImageInfo;
DebuggerInterface* fDebuggerInterface;
Architecture* fArchitecture;
DebugInfoList fDebugInfos;
SpecificInfoList fSpecificInfos;
FunctionList fFunctions;
};

View File

@ -0,0 +1,11 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#include "SpecificImageDebugInfo.h"
SpecificImageDebugInfo::~SpecificImageDebugInfo()
{
}

View File

@ -2,8 +2,8 @@
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef DEBUG_INFO_H
#define DEBUG_INFO_H
#ifndef SPECIFIC_IMAGE_DEBUG_INFO_H
#define SPECIFIC_IMAGE_DEBUG_INFO_H
#include <ObjectList.h>
#include <Referenceable.h>
@ -21,9 +21,9 @@ class StackFrame;
class Statement;
class DebugInfo : public Referenceable {
class SpecificImageDebugInfo : public Referenceable {
public:
virtual ~DebugInfo();
virtual ~SpecificImageDebugInfo();
virtual status_t GetFunctions(
BObjectList<FunctionDebugInfo>& functions)
@ -48,4 +48,4 @@ public:
};
#endif // DEBUG_INFO_H
#endif // SPECIFIC_IMAGE_DEBUG_INFO_H

View File

@ -3,9 +3,9 @@
* Distributed under the terms of the MIT License.
*/
#include "DebugInfo.h"
#include "SpecificTeamDebugInfo.h"
DebugInfo::~DebugInfo()
SpecificTeamDebugInfo::~SpecificTeamDebugInfo()
{
}

View File

@ -0,0 +1,25 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef SPECIFIC_TEAM_DEBUG_INFO_H
#define SPECIFIC_TEAM_DEBUG_INFO_H
#include <SupportDefs.h>
class ImageInfo;
class SpecificImageDebugInfo;
class SpecificTeamDebugInfo {
public:
virtual ~SpecificTeamDebugInfo();
virtual status_t CreateImageDebugInfo(const ImageInfo& imageInfo,
SpecificImageDebugInfo*& _imageDebugInfo)
= 0;
};
#endif // SPECIFIC_TEAM_DEBUG_INFO_H

View File

@ -0,0 +1,88 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#include "TeamDebugInfo.h"
#include <new>
#include <AutoDeleter.h>
#include "DebuggerTeamDebugInfo.h"
#include "ImageDebugInfo.h"
#include "SpecificImageDebugInfo.h"
TeamDebugInfo::TeamDebugInfo(DebuggerInterface* debuggerInterface,
Architecture* architecture)
:
fDebuggerInterface(debuggerInterface),
fArchitecture(architecture),
fSpecificInfos(10, true)
{
}
TeamDebugInfo::~TeamDebugInfo()
{
}
status_t
TeamDebugInfo::Init()
{
// create specific infos for all types of debug info we support
// DWARF
// TODO:...
// debugger based info
DebuggerTeamDebugInfo* debuggerInfo
= new(std::nothrow) DebuggerTeamDebugInfo(fDebuggerInterface,
fArchitecture);
if (debuggerInfo == NULL || !fSpecificInfos.AddItem(debuggerInfo)) {
delete debuggerInfo;
return B_NO_MEMORY;
}
status_t error = debuggerInfo->Init();
if (error != B_OK)
return error;
return B_OK;
}
status_t
TeamDebugInfo::LoadImageDebugInfo(const ImageInfo& imageInfo,
ImageDebugInfo*& _imageDebugInfo)
{
ImageDebugInfo* imageDebugInfo = new(std::nothrow) ImageDebugInfo(
imageInfo);
if (imageDebugInfo == NULL)
return B_NO_MEMORY;
ObjectDeleter<ImageDebugInfo> imageDebugInfoDeleter(imageDebugInfo);
for (int32 i = 0; SpecificTeamDebugInfo* specificTeamInfo
= fSpecificInfos.ItemAt(i); i++) {
SpecificImageDebugInfo* specificImageInfo;
status_t error = specificTeamInfo->CreateImageDebugInfo(imageInfo,
specificImageInfo);
if (error == B_OK) {
if (!imageDebugInfo->AddSpecificInfo(specificImageInfo)) {
delete specificImageInfo;
return B_NO_MEMORY;
}
} else if (error == B_NO_MEMORY)
return error;
// fail only when out of memory
}
status_t error = imageDebugInfo->FinishInit();
if (error != B_OK)
return error;
_imageDebugInfo = imageDebugInfoDeleter.Detach();
return B_OK;
}

View File

@ -0,0 +1,43 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef TEAM_DEBUG_INFO_H
#define TEAM_DEBUG_INFO_H
#include <ObjectList.h>
#include <Referenceable.h>
#include "ImageInfo.h"
class Architecture;
class DebuggerInterface;
class ImageDebugInfo;
class ImageInfo;
class SpecificTeamDebugInfo;
class TeamDebugInfo : public Referenceable {
public:
TeamDebugInfo(
DebuggerInterface* debuggerInterface,
Architecture* architecture);
~TeamDebugInfo();
status_t Init();
status_t LoadImageDebugInfo(const ImageInfo& imageInfo,
ImageDebugInfo*& _imageDebugInfo);
private:
typedef BObjectList<SpecificTeamDebugInfo> SpecificInfoList;
private:
DebuggerInterface* fDebuggerInterface;
Architecture* fArchitecture;
SpecificInfoList fSpecificInfos;
};
#endif // TEAM_DEBUG_INFO_H

View File

@ -9,14 +9,18 @@
#include <AutoLocker.h>
#include "TeamDebugInfo.h"
// #pragma mark - Team
Team::Team(team_id teamID)
Team::Team(team_id teamID, TeamDebugInfo* debugInfo)
:
fID(teamID)
fID(teamID),
fDebugInfo(debugInfo)
{
fDebugInfo->AddReference();
}
@ -27,6 +31,8 @@ Team::~Team()
while (Thread* thread = fThreads.RemoveHead())
thread->RemoveReference();
fDebugInfo->RemoveReference();
}

View File

@ -28,6 +28,9 @@ enum {
};
class TeamDebugInfo;
class Team : public BLocker {
public:
class Event;
@ -36,12 +39,13 @@ public:
class Listener;
public:
Team(team_id teamID);
Team(team_id teamID, TeamDebugInfo* debugInfo);
~Team();
status_t Init();
team_id ID() const { return fID; }
team_id ID() const { return fID; }
TeamDebugInfo* DebugInfo() const { return fDebugInfo; }
const char* Name() const { return fName.String(); }
void SetName(const BString& name);
@ -85,6 +89,7 @@ private:
private:
team_id fID;
TeamDebugInfo* fDebugInfo;
BString fName;
ThreadList fThreads;
ImageList fImages;