[Haiku-commits] r31278 - in haiku/trunk/src/apps/debugger: . arch debug_info elf model
bonefish at BerliOS
bonefish at mail.berlios.de
Sat Jun 27 23:09:22 CEST 2009
Author: bonefish
Date: 2009-06-27 23:09:21 +0200 (Sat, 27 Jun 2009)
New Revision: 31278
ViewCVS: http://svn.berlios.de/viewcvs/haiku?rev=31278&view=rev
Added:
haiku/trunk/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/DebuggerTeamDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/DebuggerTeamDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/SpecificTeamDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/SpecificTeamDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/TeamDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/TeamDebugInfo.h
haiku/trunk/src/apps/debugger/elf/
haiku/trunk/src/apps/debugger/elf/ElfFile.cpp
haiku/trunk/src/apps/debugger/elf/ElfFile.h
Removed:
haiku/trunk/src/apps/debugger/ElfFile.cpp
haiku/trunk/src/apps/debugger/ElfFile.h
haiku/trunk/src/apps/debugger/debug_info/DebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h
Modified:
haiku/trunk/src/apps/debugger/Jamfile
haiku/trunk/src/apps/debugger/Jobs.cpp
haiku/trunk/src/apps/debugger/Jobs.h
haiku/trunk/src/apps/debugger/TeamDebugger.cpp
haiku/trunk/src/apps/debugger/TeamDebugger.h
haiku/trunk/src/apps/debugger/ThreadHandler.cpp
haiku/trunk/src/apps/debugger/arch/Architecture.cpp
haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h
haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.cpp
haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h
haiku/trunk/src/apps/debugger/model/Team.cpp
haiku/trunk/src/apps/debugger/model/Team.h
Log:
* 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.
Deleted: haiku/trunk/src/apps/debugger/ElfFile.cpp
Deleted: haiku/trunk/src/apps/debugger/ElfFile.h
Modified: haiku/trunk/src/apps/debugger/Jamfile
===================================================================
--- haiku/trunk/src/apps/debugger/Jamfile 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/Jamfile 2009-06-27 21:09:21 UTC (rev 31278)
@@ -10,6 +10,8 @@
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 @@
Application Debugger :
BreakpointManager.cpp
Debugger.cpp
-# ElfFile.cpp
Jobs.cpp
TeamDebugger.cpp
ThreadHandler.cpp
@@ -41,16 +42,31 @@
# 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 @@
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
Modified: haiku/trunk/src/apps/debugger/Jobs.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/Jobs.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -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 @@
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 @@
// #pragma mark - LoadImageDebugInfoJob
-LoadImageDebugInfoJob::LoadImageDebugInfoJob(
- DebuggerInterface* debuggerInterface, Architecture* architecture,
- Image* image)
+LoadImageDebugInfoJob::LoadImageDebugInfoJob(Image* image)
:
- fDebuggerInterface(debuggerInterface),
- fArchitecture(architecture),
fImage(image)
{
fImage->AddReference();
@@ -254,15 +251,10 @@
locker.Unlock();
// create the debug info
- ImageDebugInfo* debugInfo = new(std::nothrow) ImageDebugInfo(imageInfo,
- fDebuggerInterface, fArchitecture);
+ ImageDebugInfo* debugInfo;
+ status_t error = fImage->GetTeam()->DebugInfo()->LoadImageDebugInfo(
+ imageInfo, debugInfo);
- status_t error;;
- if (debugInfo != NULL)
- error = debugInfo->Init();
- else
- error = B_NO_MEMORY;
-
// set the result
locker.Lock();
if (error == B_OK) {
@@ -278,8 +270,7 @@
/*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 @@
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 @@
{
// 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);
Modified: haiku/trunk/src/apps/debugger/Jobs.h
===================================================================
--- haiku/trunk/src/apps/debugger/Jobs.h 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/Jobs.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -86,18 +86,13 @@
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 @@
// earlier.
private:
- DebuggerInterface* fDebuggerInterface;
- Architecture* fArchitecture;
Image* fImage;
};
Modified: haiku/trunk/src/apps/debugger/TeamDebugger.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/TeamDebugger.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -23,6 +23,7 @@
#include "Jobs.h"
#include "MessageCodes.h"
#include "Statement.h"
+#include "TeamDebugInfo.h"
#include "TeamDebugModel.h"
@@ -91,14 +92,35 @@
{
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 @@
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 @@
void
TeamDebugger::ImageDebugInfoRequested(TeamWindow* window, Image* image)
{
- LoadImageDebugInfoJob::ScheduleIfNecessary(fDebuggerInterface,
- fDebuggerInterface->GetArchitecture(), fWorker, image);
+ LoadImageDebugInfoJob::ScheduleIfNecessary(fWorker, image);
}
Modified: haiku/trunk/src/apps/debugger/TeamDebugger.h
===================================================================
--- haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/TeamDebugger.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -18,6 +18,7 @@
class DebuggerInterface;
+class TeamDebugInfo;
class TeamDebugModel;
@@ -97,6 +98,7 @@
ThreadHandlerTable fThreadHandlers;
// protected by the team lock
DebuggerInterface* fDebuggerInterface;
+ TeamDebugInfo* fTeamDebugInfo;
Worker* fWorker;
BreakpointManager* fBreakpointManager;
thread_id fDebugEventListener;
Modified: haiku/trunk/src/apps/debugger/ThreadHandler.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/ThreadHandler.cpp 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/ThreadHandler.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -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 @@
// 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;
}
Modified: haiku/trunk/src/apps/debugger/arch/Architecture.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/arch/Architecture.cpp 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/arch/Architecture.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -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 @@
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;
}
Modified: haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -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;
}
Modified: haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/BasicFunctionDebugInfo.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -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 @@
virtual SourceLocation SourceEndLocation() const;
private:
- DebugInfo* fDebugInfo;
+ SpecificImageDebugInfo* fImageDebugInfo;
target_addr_t fAddress;
target_size_t fSize;
const BString fName;
Deleted: haiku/trunk/src/apps/debugger/debug_info/DebugInfo.cpp
Deleted: haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h
Deleted: haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp
Deleted: haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h
Copied: haiku/trunk/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp (from rev 31270, haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp)
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.cpp 2009-06-27 16:43:07 UTC (rev 31270)
+++ haiku/trunk/src/apps/debugger/debug_info/DebuggerImageDebugInfo.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include "DebuggerImageDebugInfo.h"
+
+#include <algorithm>
+#include <new>
+
+#include <AutoDeleter.h>
+
+#include "Architecture.h"
+#include "BasicFunctionDebugInfo.h"
+#include "DebuggerInterface.h"
+#include "Demangler.h"
+#include "SymbolInfo.h"
+
+
+DebuggerImageDebugInfo::DebuggerImageDebugInfo(const ImageInfo& imageInfo,
+ DebuggerInterface* debuggerInterface, Architecture* architecture)
+ :
+ fImageInfo(imageInfo),
+ fDebuggerInterface(debuggerInterface),
+ fArchitecture(architecture)
+{
+}
+
+
+DebuggerImageDebugInfo::~DebuggerImageDebugInfo()
+{
+}
+
+
+status_t
+DebuggerImageDebugInfo::Init()
+{
+ return B_OK;
+}
+
+
+status_t
+DebuggerImageDebugInfo::GetFunctions(BObjectList<FunctionDebugInfo>& functions)
+{
+ BObjectList<SymbolInfo> symbols(20, true);
+ status_t error = fDebuggerInterface->GetSymbolInfos(fImageInfo.TeamID(),
+ fImageInfo.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++) {
+ if (symbol->Type() != B_SYMBOL_TYPE_TEXT)
+ continue;
+
+ FunctionDebugInfo* function = new(std::nothrow) BasicFunctionDebugInfo(
+ this, symbol->Address(), symbol->Size(), symbol->Name(),
+ Demangler::Demangle(symbol->Name()));
+ if (function == NULL || !functions.AddItem(function)) {
+ delete function;
+ int32 index = functions.CountItems() - 1;
+ for (; functionsAdded >= 0; functionsAdded--, index--) {
+ function = functions.RemoveItemAt(index);
+ delete function;
+ }
+ return B_NO_MEMORY;
+ }
+
+ functionsAdded++;
+ }
+
+ return B_OK;
+}
+
+
+status_t
+DebuggerImageDebugInfo::CreateFrame(Image* image, FunctionDebugInfo* function,
+ CpuState* cpuState, StackFrame*& _previousFrame,
+ CpuState*& _previousCpuState)
+{
+ return B_UNSUPPORTED;
+}
+
+
+status_t
+DebuggerImageDebugInfo::LoadSourceCode(FunctionDebugInfo* function,
+ SourceCode*& _sourceCode)
+{
+ // allocate a buffer for the function code
+ static const target_size_t kMaxBufferSize = 64 * 1024;
+ target_size_t bufferSize = std::min(function->Size(), kMaxBufferSize);
+ void* buffer = malloc(bufferSize);
+ if (buffer == NULL)
+ return B_NO_MEMORY;
+ MemoryDeleter bufferDeleter(buffer);
+
+ // read the function code
+ ssize_t bytesRead = fDebuggerInterface->ReadMemory(function->Address(),
+ buffer, bufferSize);
+ if (bytesRead < 0)
+ return bytesRead;
+
+ return fArchitecture->DisassembleCode(function, buffer, bytesRead,
+ _sourceCode);
+}
+
+
+status_t
+DebuggerImageDebugInfo::GetStatement(FunctionDebugInfo* function,
+ target_addr_t address, Statement*& _statement)
+{
+ return fArchitecture->GetStatement(function, address, _statement);
+}
+
+
+/*static*/ int
+DebuggerImageDebugInfo::_CompareSymbols(const SymbolInfo* a,
+ const SymbolInfo* b)
+{
+ return a->Address() < b->Address()
+ ? -1 : (a->Address() == b->Address() ? 0 : 1);
+}
Copied: haiku/trunk/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h (from rev 31265, haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h)
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DebuggerDebugInfo.h 2009-06-27 13:19:18 UTC (rev 31265)
+++ haiku/trunk/src/apps/debugger/debug_info/DebuggerImageDebugInfo.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef DEBUGGER_IMAGE_DEBUG_INFO_H
+#define DEBUGGER_IMAGE_DEBUG_INFO_H
+
+#include <String.h>
+
+#include "ImageInfo.h"
+#include "SpecificImageDebugInfo.h"
+
+
+class Architecture;
+class DebuggerInterface;
+class FunctionDebugInfo;
+class SymbolInfo;
+
+
+class DebuggerImageDebugInfo : public SpecificImageDebugInfo {
+public:
+ DebuggerImageDebugInfo(
+ const ImageInfo& imageInfo,
+ DebuggerInterface* debuggerInterface,
+ Architecture* architecture);
+ virtual ~DebuggerImageDebugInfo();
+
+ status_t Init();
+
+ virtual status_t GetFunctions(
+ BObjectList<FunctionDebugInfo>& functions);
+ virtual status_t CreateFrame(Image* image,
+ FunctionDebugInfo* function,
+ CpuState* cpuState,
+ StackFrame*& _previousFrame,
+ CpuState*& _previousCpuState);
+ virtual status_t LoadSourceCode(FunctionDebugInfo* function,
+ SourceCode*& _sourceCode);
+ virtual status_t GetStatement(FunctionDebugInfo* function,
+ target_addr_t address,
+ Statement*& _statement);
+
+private:
+ static int _CompareSymbols(const SymbolInfo* a,
+ const SymbolInfo* b);
+
+private:
+ ImageInfo fImageInfo;
+ DebuggerInterface* fDebuggerInterface;
+ Architecture* fArchitecture;
+};
+
+
+#endif // DEBUGGER_IMAGE_DEBUG_INFO_H
Added: haiku/trunk/src/apps/debugger/debug_info/DebuggerTeamDebugInfo.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DebuggerTeamDebugInfo.cpp 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/DebuggerTeamDebugInfo.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at 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;
+}
Added: haiku/trunk/src/apps/debugger/debug_info/DebuggerTeamDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DebuggerTeamDebugInfo.h 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/DebuggerTeamDebugInfo.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at 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
Modified: haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/FunctionDebugInfo.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -20,8 +20,8 @@
};
-class DebugInfo;
class SourceCode;
+class SpecificImageDebugInfo;
class FunctionDebugInfo : public Referenceable {
@@ -32,7 +32,7 @@
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;
Modified: haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.cpp 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -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 @@
}
-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;
Modified: haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/ImageDebugInfo.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -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:
ImageInfo fImageInfo;
- DebuggerInterface* fDebuggerInterface;
- Architecture* fArchitecture;
- DebugInfoList fDebugInfos;
+ SpecificInfoList fSpecificInfos;
FunctionList fFunctions;
};
Copied: haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.cpp (from rev 31265, haiku/trunk/src/apps/debugger/debug_info/DebugInfo.cpp)
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DebugInfo.cpp 2009-06-27 13:19:18 UTC (rev 31265)
+++ haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -0,0 +1,11 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include "SpecificImageDebugInfo.h"
+
+
+SpecificImageDebugInfo::~SpecificImageDebugInfo()
+{
+}
Copied: haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.h (from rev 31265, haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h)
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/DebugInfo.h 2009-06-27 13:19:18 UTC (rev 31265)
+++ haiku/trunk/src/apps/debugger/debug_info/SpecificImageDebugInfo.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -0,0 +1,51 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+#ifndef SPECIFIC_IMAGE_DEBUG_INFO_H
+#define SPECIFIC_IMAGE_DEBUG_INFO_H
+
+#include <ObjectList.h>
+#include <Referenceable.h>
+
+#include "ArchitectureTypes.h"
+
+
+class Architecture;
+class CpuState;
+class DebuggerInterface;
+class FunctionDebugInfo;
+class Image;
+class SourceCode;
+class StackFrame;
+class Statement;
+
+
+class SpecificImageDebugInfo : public Referenceable {
+public:
+ virtual ~SpecificImageDebugInfo();
+
+ virtual status_t GetFunctions(
+ BObjectList<FunctionDebugInfo>& functions)
+ = 0;
+ // returns references
+
+ virtual status_t CreateFrame(Image* image,
+ FunctionDebugInfo* function,
+ CpuState* cpuState,
+ StackFrame*& _previousFrame,
+ CpuState*& _previousCpuState) = 0;
+ // returns reference to previous frame
+ // and CPU state; returned CPU state
+ // can be NULL; can return B_UNSUPPORTED
+ virtual status_t LoadSourceCode(FunctionDebugInfo* function,
+ SourceCode*& _sourceCode) = 0;
+ // returns reference
+ virtual status_t GetStatement(FunctionDebugInfo* function,
+ target_addr_t address,
+ Statement*& _statement) = 0;
+ // returns reference
+};
+
+
+#endif // SPECIFIC_IMAGE_DEBUG_INFO_H
Added: haiku/trunk/src/apps/debugger/debug_info/SpecificTeamDebugInfo.cpp
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/SpecificTeamDebugInfo.cpp 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/SpecificTeamDebugInfo.cpp 2009-06-27 21:09:21 UTC (rev 31278)
@@ -0,0 +1,11 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at gmx.de.
+ * Distributed under the terms of the MIT License.
+ */
+
+#include "SpecificTeamDebugInfo.h"
+
+
+SpecificTeamDebugInfo::~SpecificTeamDebugInfo()
+{
+}
Added: haiku/trunk/src/apps/debugger/debug_info/SpecificTeamDebugInfo.h
===================================================================
--- haiku/trunk/src/apps/debugger/debug_info/SpecificTeamDebugInfo.h 2009-06-27 18:07:37 UTC (rev 31277)
+++ haiku/trunk/src/apps/debugger/debug_info/SpecificTeamDebugInfo.h 2009-06-27 21:09:21 UTC (rev 31278)
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2009, Ingo Weinhold, ingo_weinhold at 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();
[... truncated: 230 lines follow ...]
More information about the Haiku-commits
mailing list