Pulled interface TeamMemory out of DebuggerInterface to make the arch and model

packages indepent of the latter.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31246 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2009-06-26 00:39:23 +00:00
parent 0f5f9d47b9
commit 1c6fd17f75
11 changed files with 62 additions and 29 deletions
+1
View File
@@ -71,6 +71,7 @@ Application Debugger :
SymbolInfo.cpp SymbolInfo.cpp
Team.cpp Team.cpp
TeamDebugModel.cpp TeamDebugModel.cpp
TeamMemory.cpp
Thread.cpp Thread.cpp
ThreadInfo.cpp ThreadInfo.cpp
+2 -2
View File
@@ -20,9 +20,9 @@
#include "Team.h" #include "Team.h"
Architecture::Architecture(DebuggerInterface* debuggerInterface) Architecture::Architecture(TeamMemory* teamMemory)
: :
fDebuggerInterface(debuggerInterface) fTeamMemory(teamMemory)
{ {
} }
+3 -4
View File
@@ -13,7 +13,6 @@
class CpuState; class CpuState;
class DebuggerInterface;
class FunctionDebugInfo; class FunctionDebugInfo;
class Image; class Image;
class ImageDebugInfoProvider; class ImageDebugInfoProvider;
@@ -24,12 +23,12 @@ class StackFrame;
class StackTrace; class StackTrace;
class Statement; class Statement;
class Team; class Team;
class TeamMemory;
class Architecture : public Referenceable { class Architecture : public Referenceable {
public: public:
Architecture( Architecture(TeamMemory* teamMemory);
DebuggerInterface* debuggerInterface);
virtual ~Architecture(); virtual ~Architecture();
virtual status_t Init(); virtual status_t Init();
@@ -72,7 +71,7 @@ public:
// team is not locked // team is not locked
protected: protected:
DebuggerInterface* fDebuggerInterface; TeamMemory* fTeamMemory;
}; };
@@ -5,6 +5,8 @@
#ifndef ARCHITECTURE_TYPES_H #ifndef ARCHITECTURE_TYPES_H
#define ARCHITECTURE_TYPES_H #define ARCHITECTURE_TYPES_H
#include <SupportDefs.h>
typedef uint64 target_addr_t; typedef uint64 target_addr_t;
typedef uint64 target_size_t; typedef uint64 target_size_t;
+10 -11
View File
@@ -12,19 +12,19 @@
#include <AutoDeleter.h> #include <AutoDeleter.h>
#include "CpuStateX86.h" #include "CpuStateX86.h"
#include "DebuggerInterface.h"
#include "DisassembledCode.h" #include "DisassembledCode.h"
#include "FunctionDebugInfo.h" #include "FunctionDebugInfo.h"
#include "InstructionInfo.h" #include "InstructionInfo.h"
#include "StackFrame.h" #include "StackFrame.h"
#include "Statement.h" #include "Statement.h"
#include "TeamMemory.h"
#include "disasm/DisassemblerX86.h" #include "disasm/DisassemblerX86.h"
ArchitectureX86::ArchitectureX86(DebuggerInterface* debuggerInterface) ArchitectureX86::ArchitectureX86(TeamMemory* teamMemory)
: :
Architecture(debuggerInterface) Architecture(teamMemory)
{ {
} }
@@ -138,7 +138,7 @@ ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
// stack. // stack.
uint32 esp = cpuState->IntRegisterValue(X86_REGISTER_ESP); uint32 esp = cpuState->IntRegisterValue(X86_REGISTER_ESP);
uint32 address; uint32 address;
if (fDebuggerInterface->ReadMemory(esp, &address, 4) == 4) { if (fTeamMemory->ReadMemory(esp, &address, 4) == 4) {
returnAddress = address; returnAddress = address;
previousFramePointer = framePointer; previousFramePointer = framePointer;
framePointer = 0; framePointer = 0;
@@ -171,7 +171,7 @@ ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
// The epilogue is a single "pop %ebp", so we check whether the // The epilogue is a single "pop %ebp", so we check whether the
// current instruction is already a "ret". // current instruction is already a "ret".
uint8 code[1]; uint8 code[1];
if (fDebuggerInterface->ReadMemory(eip, &code, 1) == 1 if (fTeamMemory->ReadMemory(eip, &code, 1) == 1
&& code[0] == 0xc3) { && code[0] == 0xc3) {
stack = cpuState->IntRegisterValue(X86_REGISTER_ESP); stack = cpuState->IntRegisterValue(X86_REGISTER_ESP);
} }
@@ -179,7 +179,7 @@ ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
if (stack != 0) { if (stack != 0) {
uint32 address; uint32 address;
if (fDebuggerInterface->ReadMemory(stack, &address, 4) == 4) { if (fTeamMemory->ReadMemory(stack, &address, 4) == 4) {
returnAddress = address; returnAddress = address;
previousFramePointer = framePointer; previousFramePointer = framePointer;
framePointer = 0; framePointer = 0;
@@ -201,8 +201,7 @@ ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
if (readStandardFrame) { if (readStandardFrame) {
uint32 frameData[2]; uint32 frameData[2];
if (framePointer != 0 if (framePointer != 0
&& fDebuggerInterface->ReadMemory(framePointer, frameData, 8) && fTeamMemory->ReadMemory(framePointer, frameData, 8) == 8) {
== 8) {
previousFramePointer = frameData[0]; previousFramePointer = frameData[0];
returnAddress = frameData[1]; returnAddress = frameData[1];
} }
@@ -252,7 +251,7 @@ ArchitectureX86::UpdateStackFrameCpuState(const StackFrame* frame,
MemoryDeleter bufferDeleter(buffer); MemoryDeleter bufferDeleter(buffer);
// read the code // read the code
ssize_t bytesRead = fDebuggerInterface->ReadMemory(functionAddress, buffer, ssize_t bytesRead = fTeamMemory->ReadMemory(functionAddress, buffer,
bufferSize); bufferSize);
if (bytesRead != (ssize_t)bufferSize) if (bytesRead != (ssize_t)bufferSize)
return; return;
@@ -339,7 +338,7 @@ ArchitectureX86::GetInstructionInfo(target_addr_t address,
// read the code // read the code
uint8 buffer[16]; uint8 buffer[16];
// TODO: What's the maximum instruction size? // TODO: What's the maximum instruction size?
ssize_t bytesRead = fDebuggerInterface->ReadMemory(address, buffer, ssize_t bytesRead = fTeamMemory->ReadMemory(address, buffer,
sizeof(buffer)); sizeof(buffer));
if (bytesRead < 0) if (bytesRead < 0)
return bytesRead; return bytesRead;
@@ -410,7 +409,7 @@ ArchitectureX86::_HasFunctionPrologue(FunctionDebugInfo* function) const
return false; return false;
uint8 buffer[3]; uint8 buffer[3];
if (fDebuggerInterface->ReadMemory(function->Address(), buffer, 3) != 3) if (fTeamMemory->ReadMemory(function->Address(), buffer, 3) != 3)
return false; return false;
return buffer[0] == 0x55 && buffer[1] == 0x89 && buffer[2] == 0xe5; return buffer[0] == 0x55 && buffer[1] == 0x89 && buffer[2] == 0xe5;
+1 -2
View File
@@ -12,8 +12,7 @@
class ArchitectureX86 : public Architecture { class ArchitectureX86 : public Architecture {
public: public:
ArchitectureX86( ArchitectureX86(TeamMemory* teamMemory);
DebuggerInterface* debuggerInterface);
virtual ~ArchitectureX86(); virtual ~ArchitectureX86();
virtual status_t Init(); virtual status_t Init();
@@ -10,7 +10,7 @@
#include <debug_support.h> #include <debug_support.h>
#include <ObjectList.h> #include <ObjectList.h>
#include "ArchitectureTypes.h" #include "TeamMemory.h"
class Architecture; class Architecture;
@@ -21,7 +21,7 @@ class SymbolInfo;
class ThreadInfo; class ThreadInfo;
class DebuggerInterface { class DebuggerInterface : public TeamMemory {
public: public:
DebuggerInterface(team_id teamID); DebuggerInterface(team_id teamID);
virtual ~DebuggerInterface(); virtual ~DebuggerInterface();
@@ -54,7 +54,8 @@ public:
CpuState*& _state); CpuState*& _state);
// returns a reference to the caller // returns a reference to the caller
ssize_t ReadMemory(target_addr_t address, void* buffer, // TeamMemory
virtual ssize_t ReadMemory(target_addr_t address, void* buffer,
size_t size); size_t size);
private: private:
+2 -2
View File
@@ -37,11 +37,11 @@ private:
// #pragma mark - TeamDebugModel // #pragma mark - TeamDebugModel
TeamDebugModel::TeamDebugModel(Team* team, DebuggerInterface* debuggerInterface, TeamDebugModel::TeamDebugModel(Team* team, TeamMemory* teamMemory,
Architecture* architecture) Architecture* architecture)
: :
fTeam(team), fTeam(team),
fDebuggerInterface(debuggerInterface), fTeamMemory(teamMemory),
fArchitecture(architecture) fArchitecture(architecture)
{ {
} }
+5 -5
View File
@@ -22,7 +22,7 @@ enum {
class Architecture; class Architecture;
class Breakpoint; class Breakpoint;
class DebuggerInterface; class TeamMemory;
class TeamDebugModel { class TeamDebugModel {
@@ -33,7 +33,7 @@ public:
public: public:
TeamDebugModel(Team* team, TeamDebugModel(Team* team,
DebuggerInterface* debuggerInterface, TeamMemory* teamMemory,
Architecture* architecture); Architecture* architecture);
~TeamDebugModel(); ~TeamDebugModel();
@@ -43,8 +43,8 @@ public:
void Unlock() { fTeam->Unlock(); } void Unlock() { fTeam->Unlock(); }
Team* GetTeam() const { return fTeam; } Team* GetTeam() const { return fTeam; }
DebuggerInterface* GetDebuggerInterface() const TeamMemory* GetTeamMemory() const
{ return fDebuggerInterface; } { return fTeamMemory; }
Architecture* GetArchitecture() const Architecture* GetArchitecture() const
{ return fArchitecture; } { return fArchitecture; }
@@ -79,7 +79,7 @@ private:
private: private:
Team* fTeam; Team* fTeam;
DebuggerInterface* fDebuggerInterface; TeamMemory* fTeamMemory;
Architecture* fArchitecture; Architecture* fArchitecture;
BreakpointList fBreakpoints; BreakpointList fBreakpoints;
ListenerList fListeners; ListenerList fListeners;
+11
View File
@@ -0,0 +1,11 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#include "TeamMemory.h"
TeamMemory::~TeamMemory()
{
}
+21
View File
@@ -0,0 +1,21 @@
/*
* Copyright 2009, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License.
*/
#ifndef TEAM_MEMORY_H
#define TEAM_MEMORY_H
#include "TargetAddressRange.h"
class TeamMemory {
public:
virtual ~TeamMemory();
virtual ssize_t ReadMemory(target_addr_t address, void* buffer,
size_t size) = 0;
};
#endif // TEAM_MEMORY_H