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

View File

@ -71,6 +71,7 @@ Application Debugger :
SymbolInfo.cpp
Team.cpp
TeamDebugModel.cpp
TeamMemory.cpp
Thread.cpp
ThreadInfo.cpp

View File

@ -20,9 +20,9 @@
#include "Team.h"
Architecture::Architecture(DebuggerInterface* debuggerInterface)
Architecture::Architecture(TeamMemory* teamMemory)
:
fDebuggerInterface(debuggerInterface)
fTeamMemory(teamMemory)
{
}

View File

@ -13,7 +13,6 @@
class CpuState;
class DebuggerInterface;
class FunctionDebugInfo;
class Image;
class ImageDebugInfoProvider;
@ -24,12 +23,12 @@ class StackFrame;
class StackTrace;
class Statement;
class Team;
class TeamMemory;
class Architecture : public Referenceable {
public:
Architecture(
DebuggerInterface* debuggerInterface);
Architecture(TeamMemory* teamMemory);
virtual ~Architecture();
virtual status_t Init();
@ -72,7 +71,7 @@ public:
// team is not locked
protected:
DebuggerInterface* fDebuggerInterface;
TeamMemory* fTeamMemory;
};

View File

@ -5,6 +5,8 @@
#ifndef ARCHITECTURE_TYPES_H
#define ARCHITECTURE_TYPES_H
#include <SupportDefs.h>
typedef uint64 target_addr_t;
typedef uint64 target_size_t;

View File

@ -12,19 +12,19 @@
#include <AutoDeleter.h>
#include "CpuStateX86.h"
#include "DebuggerInterface.h"
#include "DisassembledCode.h"
#include "FunctionDebugInfo.h"
#include "InstructionInfo.h"
#include "StackFrame.h"
#include "Statement.h"
#include "TeamMemory.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.
uint32 esp = cpuState->IntRegisterValue(X86_REGISTER_ESP);
uint32 address;
if (fDebuggerInterface->ReadMemory(esp, &address, 4) == 4) {
if (fTeamMemory->ReadMemory(esp, &address, 4) == 4) {
returnAddress = address;
previousFramePointer = framePointer;
framePointer = 0;
@ -171,7 +171,7 @@ ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
// The epilogue is a single "pop %ebp", so we check whether the
// current instruction is already a "ret".
uint8 code[1];
if (fDebuggerInterface->ReadMemory(eip, &code, 1) == 1
if (fTeamMemory->ReadMemory(eip, &code, 1) == 1
&& code[0] == 0xc3) {
stack = cpuState->IntRegisterValue(X86_REGISTER_ESP);
}
@ -179,7 +179,7 @@ ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
if (stack != 0) {
uint32 address;
if (fDebuggerInterface->ReadMemory(stack, &address, 4) == 4) {
if (fTeamMemory->ReadMemory(stack, &address, 4) == 4) {
returnAddress = address;
previousFramePointer = framePointer;
framePointer = 0;
@ -201,8 +201,7 @@ ArchitectureX86::CreateStackFrame(Image* image, FunctionDebugInfo* function,
if (readStandardFrame) {
uint32 frameData[2];
if (framePointer != 0
&& fDebuggerInterface->ReadMemory(framePointer, frameData, 8)
== 8) {
&& fTeamMemory->ReadMemory(framePointer, frameData, 8) == 8) {
previousFramePointer = frameData[0];
returnAddress = frameData[1];
}
@ -252,7 +251,7 @@ ArchitectureX86::UpdateStackFrameCpuState(const StackFrame* frame,
MemoryDeleter bufferDeleter(buffer);
// read the code
ssize_t bytesRead = fDebuggerInterface->ReadMemory(functionAddress, buffer,
ssize_t bytesRead = fTeamMemory->ReadMemory(functionAddress, buffer,
bufferSize);
if (bytesRead != (ssize_t)bufferSize)
return;
@ -339,7 +338,7 @@ ArchitectureX86::GetInstructionInfo(target_addr_t address,
// read the code
uint8 buffer[16];
// TODO: What's the maximum instruction size?
ssize_t bytesRead = fDebuggerInterface->ReadMemory(address, buffer,
ssize_t bytesRead = fTeamMemory->ReadMemory(address, buffer,
sizeof(buffer));
if (bytesRead < 0)
return bytesRead;
@ -410,7 +409,7 @@ ArchitectureX86::_HasFunctionPrologue(FunctionDebugInfo* function) const
return false;
uint8 buffer[3];
if (fDebuggerInterface->ReadMemory(function->Address(), buffer, 3) != 3)
if (fTeamMemory->ReadMemory(function->Address(), buffer, 3) != 3)
return false;
return buffer[0] == 0x55 && buffer[1] == 0x89 && buffer[2] == 0xe5;

View File

@ -12,8 +12,7 @@
class ArchitectureX86 : public Architecture {
public:
ArchitectureX86(
DebuggerInterface* debuggerInterface);
ArchitectureX86(TeamMemory* teamMemory);
virtual ~ArchitectureX86();
virtual status_t Init();

View File

@ -10,7 +10,7 @@
#include <debug_support.h>
#include <ObjectList.h>
#include "ArchitectureTypes.h"
#include "TeamMemory.h"
class Architecture;
@ -21,7 +21,7 @@ class SymbolInfo;
class ThreadInfo;
class DebuggerInterface {
class DebuggerInterface : public TeamMemory {
public:
DebuggerInterface(team_id teamID);
virtual ~DebuggerInterface();
@ -54,7 +54,8 @@ public:
CpuState*& _state);
// 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);
private:

View File

@ -37,11 +37,11 @@ private:
// #pragma mark - TeamDebugModel
TeamDebugModel::TeamDebugModel(Team* team, DebuggerInterface* debuggerInterface,
TeamDebugModel::TeamDebugModel(Team* team, TeamMemory* teamMemory,
Architecture* architecture)
:
fTeam(team),
fDebuggerInterface(debuggerInterface),
fTeamMemory(teamMemory),
fArchitecture(architecture)
{
}

View File

@ -22,7 +22,7 @@ enum {
class Architecture;
class Breakpoint;
class DebuggerInterface;
class TeamMemory;
class TeamDebugModel {
@ -33,7 +33,7 @@ public:
public:
TeamDebugModel(Team* team,
DebuggerInterface* debuggerInterface,
TeamMemory* teamMemory,
Architecture* architecture);
~TeamDebugModel();
@ -43,8 +43,8 @@ public:
void Unlock() { fTeam->Unlock(); }
Team* GetTeam() const { return fTeam; }
DebuggerInterface* GetDebuggerInterface() const
{ return fDebuggerInterface; }
TeamMemory* GetTeamMemory() const
{ return fTeamMemory; }
Architecture* GetArchitecture() const
{ return fArchitecture; }
@ -79,7 +79,7 @@ private:
private:
Team* fTeam;
DebuggerInterface* fDebuggerInterface;
TeamMemory* fTeamMemory;
Architecture* fArchitecture;
BreakpointList fBreakpoints;
ListenerList fListeners;

View File

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

View File

@ -0,0 +1,21 @@
/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* 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