cleanup: extract breakpoint code into Common. only have one shared PPCDebugInterface.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@3567 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard
2009-06-28 12:15:31 +00:00
parent 7c92dada85
commit 8e7fdbc150
20 changed files with 44 additions and 42 deletions

View File

@ -0,0 +1,154 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#include "Common.h"
#include "DebugInterface.h"
#include "BreakPoints.h"
void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bool write, int size, u32 pc)
{
if ((write && OnWrite) || (!write && OnRead))
{
if (Log)
{
DEBUG_LOG(MEMMAP, "CHK %08x %s%i at %08x (%s)",
iValue, write ? "Write" : "Read", // read or write
size*8, addr, // address
debug_interface->GetDescription(addr).c_str() // symbol map description
);
}
if (Break)
debug_interface->breakNow();
}
}
bool BreakPoints::IsAddressBreakPoint(u32 _iAddress)
{
std::vector<TBreakPoint>::iterator iter;
for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter)
if ((*iter).iAddress == _iAddress)
return true;
return false;
}
bool BreakPoints::IsTempBreakPoint(u32 _iAddress)
{
std::vector<TBreakPoint>::iterator iter;
for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter)
if ((*iter).iAddress == _iAddress && (*iter).bTemporary)
return true;
return false;
}
bool BreakPoints::Add(u32 em_address, bool temp)
{
if (!IsAddressBreakPoint(em_address)) // only add new addresses
{
TBreakPoint pt; // breakpoint settings
pt.bOn = true;
pt.bTemporary = temp;
pt.iAddress = em_address;
m_BreakPoints.push_back(pt);
return true;
} else {
return false;
}
}
bool BreakPoints::Remove(u32 _iAddress)
{
std::vector<TBreakPoint>::iterator iter;
for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter)
{
if ((*iter).iAddress == _iAddress)
{
m_BreakPoints.erase(iter);
return true;
}
}
return false;
}
void BreakPoints::Clear()
{
m_BreakPoints.clear();
}
void BreakPoints::DeleteByAddress(u32 _Address)
{
// first check breakpoints
{
std::vector<TBreakPoint>::iterator iter;
for (iter = m_BreakPoints.begin(); iter != m_BreakPoints.end(); ++iter)
{
if ((*iter).iAddress == _Address)
{
m_BreakPoints.erase(iter);
return;
}
}
}
}
void MemChecks::Add(const TMemCheck& _rMemoryCheck)
{
m_MemChecks.push_back(_rMemoryCheck);
}
TMemCheck *MemChecks::GetMemCheck(u32 address)
{
std::vector<TMemCheck>::iterator iter;
for (iter = m_MemChecks.begin(); iter != m_MemChecks.end(); ++iter)
{
if ((*iter).bRange)
{
if (address >= (*iter).StartAddress && address <= (*iter).EndAddress)
return &(*iter);
}
else
{
if ((*iter).StartAddress == address)
return &(*iter);
}
}
//none found
return 0;
}
void MemChecks::Clear()
{
m_MemChecks.clear();
}
void MemChecks::DeleteByAddress(u32 _Address)
{
std::vector<TMemCheck>::iterator iter;
for (iter = m_MemChecks.begin(); iter != m_MemChecks.end(); ++iter)
{
if ((*iter).StartAddress == _Address)
{
m_MemChecks.erase(iter);
return;
}
}
}

View File

@ -0,0 +1,100 @@
// Copyright (C) 2003-2009 Dolphin Project.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, version 2.0.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License 2.0 for more details.
// A copy of the GPL 2.0 should have been included with the program.
// If not, see http://www.gnu.org/licenses/
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
#ifndef _DEBUGGER_BREAKPOINTS_H
#define _DEBUGGER_BREAKPOINTS_H
#include <vector>
#include <string>
#include "Common.h"
class DebugInterface;
struct TBreakPoint
{
u32 iAddress;
bool bOn;
bool bTemporary;
};
struct TMemCheck
{
TMemCheck() {
numHits = 0;
}
u32 StartAddress;
u32 EndAddress;
bool bRange;
bool OnRead;
bool OnWrite;
bool Log;
bool Break;
u32 numHits;
void Action(DebugInterface *dbg_interface, u32 _iValue, u32 addr, bool write, int size, u32 pc);
};
// Code breakpoints.
class BreakPoints
{
public:
typedef std::vector<TBreakPoint> TBreakPoints;
const TBreakPoints& GetBreakPoints() { return m_BreakPoints; }
// is address breakpoint
bool IsAddressBreakPoint(u32 _iAddress);
bool IsTempBreakPoint(u32 _iAddress);
// AddBreakPoint
bool Add(u32 em_address, bool temp=false);
// Remove Breakpoint
bool Remove(u32 _iAddress);
void Clear();
void DeleteByAddress(u32 _Address);
private:
TBreakPoints m_BreakPoints;
u32 m_iBreakOnCount;
};
// Memory breakpoints
class MemChecks
{
public:
typedef std::vector<TMemCheck> TMemChecks;
TMemChecks m_MemChecks;
const TMemChecks& GetMemChecks() { return m_MemChecks; }
void Add(const TMemCheck& _rMemoryCheck);
//memory breakpoint
TMemCheck *GetMemCheck(u32 address);
void DeleteByAddress(u32 _Address);
void Clear();
};
#endif

View File

@ -27,6 +27,7 @@ public:
virtual void setPC(unsigned int /*address*/) {}
virtual void step() {}
virtual void runToBreakpoint() {}
virtual void breakNow() {}
virtual void insertBLR(unsigned int /*address*/, unsigned int) {}
virtual int getColor(unsigned int /*address*/){return 0xFFFFFFFF;}
virtual std::string getDescription(unsigned int /*address*/) = 0;

View File

@ -5,6 +5,7 @@ import sys
files = [
"ABI.cpp",
"BreakPoints.cpp",
"CDUtils.cpp",
"ChunkFile.cpp",
"ColorUtil.cpp",