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

@ -556,6 +556,14 @@
RelativePath=".\Src\ABI.h" RelativePath=".\Src\ABI.h"
> >
</File> </File>
<File
RelativePath=".\Src\BreakPoints.cpp"
>
</File>
<File
RelativePath=".\Src\BreakPoints.h"
>
</File>
<File <File
RelativePath=".\Src\CDUtils.cpp" RelativePath=".\Src\CDUtils.cpp"
> >

View File

@ -17,12 +17,10 @@
#include "Common.h" #include "Common.h"
#include "../HW/CPU.h" #include "DebugInterface.h"
#include "../Host.h" #include "BreakPoints.h"
#include "../PowerPC/PPCSymbolDB.h"
#include "Debugger_BreakPoints.h"
void TMemCheck::Action(u32 iValue, u32 addr, bool write, int size, u32 pc) void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bool write, int size, u32 pc)
{ {
if ((write && OnWrite) || (!write && OnRead)) if ((write && OnWrite) || (!write && OnRead))
{ {
@ -31,11 +29,11 @@ void TMemCheck::Action(u32 iValue, u32 addr, bool write, int size, u32 pc)
DEBUG_LOG(MEMMAP, "CHK %08x %s%i at %08x (%s)", DEBUG_LOG(MEMMAP, "CHK %08x %s%i at %08x (%s)",
iValue, write ? "Write" : "Read", // read or write iValue, write ? "Write" : "Read", // read or write
size*8, addr, // address size*8, addr, // address
g_symbolDB.GetDescription(addr) // symbol map description debug_interface->GetDescription(addr).c_str() // symbol map description
); );
} }
if (Break) if (Break)
CCPU::Break(); debug_interface->breakNow();
} }
} }
@ -92,7 +90,6 @@ bool BreakPoints::Remove(u32 _iAddress)
void BreakPoints::Clear() void BreakPoints::Clear()
{ {
m_BreakPoints.clear(); m_BreakPoints.clear();
Host_UpdateBreakPointView();
} }
void BreakPoints::DeleteByAddress(u32 _Address) void BreakPoints::DeleteByAddress(u32 _Address)
@ -151,7 +148,6 @@ void MemChecks::DeleteByAddress(u32 _Address)
if ((*iter).StartAddress == _Address) if ((*iter).StartAddress == _Address)
{ {
m_MemChecks.erase(iter); m_MemChecks.erase(iter);
Host_UpdateBreakPointView();
return; return;
} }
} }

View File

@ -23,6 +23,8 @@
#include "Common.h" #include "Common.h"
class DebugInterface;
struct TBreakPoint struct TBreakPoint
{ {
u32 iAddress; u32 iAddress;
@ -48,7 +50,7 @@ struct TMemCheck
u32 numHits; u32 numHits;
void Action(u32 _iValue, u32 addr, bool write, int size, u32 pc); void Action(DebugInterface *dbg_interface, u32 _iValue, u32 addr, bool write, int size, u32 pc);
}; };
// Code breakpoints. // Code breakpoints.

View File

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

View File

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

View File

@ -1987,14 +1987,6 @@
<Filter <Filter
Name="Debugger" Name="Debugger"
> >
<File
RelativePath=".\Src\Debugger\Debugger_BreakPoints.cpp"
>
</File>
<File
RelativePath=".\Src\Debugger\Debugger_BreakPoints.h"
>
</File>
<File <File
RelativePath=".\Src\Debugger\Debugger_SymbolMap.cpp" RelativePath=".\Src\Debugger\Debugger_SymbolMap.cpp"
> >

View File

@ -33,7 +33,6 @@
#include "../HW/CPU.h" #include "../HW/CPU.h"
#include "../Debugger/Debugger_SymbolMap.h" // Debugger #include "../Debugger/Debugger_SymbolMap.h" // Debugger
#include "../Debugger/Debugger_BreakPoints.h"
#include "Boot_DOL.h" #include "Boot_DOL.h"
#include "Boot.h" #include "Boot.h"
@ -147,7 +146,7 @@ bool CBoot::Load_BIOS(const std::string& _rBiosFilename)
if (!File::ReadFileToString(false, _rBiosFilename.c_str(), data)) if (!File::ReadFileToString(false, _rBiosFilename.c_str(), data))
return false; return false;
Memory::WriteBigEData((const u8*)data.data() + 0x820, 0x81300000, data.size() - 0x820); Memory::WriteBigEData((const u8*)data.data() + 0x820, 0x81300000, (int)data.size() - 0x820);
PC = 0x81300000; PC = 0x81300000;
return true; return true;
} }

View File

@ -18,7 +18,6 @@
#include "Common.h" #include "Common.h"
#include "StringUtil.h" #include "StringUtil.h"
#include "Debugger_SymbolMap.h" #include "Debugger_SymbolMap.h"
#include "Debugger_BreakPoints.h"
#include "../Core.h" #include "../Core.h"
#include "../HW/Memmap.h" #include "../HW/Memmap.h"
#include "../PowerPC/PowerPC.h" #include "../PowerPC/PowerPC.h"

View File

@ -15,12 +15,12 @@
// Official SVN repository and contact information can be found at // Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#include "Debugger_BreakPoints.h"
#include "Debugger_SymbolMap.h" #include "Debugger_SymbolMap.h"
#include "DebugInterface.h" #include "DebugInterface.h"
#include "PPCDebugInterface.h" #include "PPCDebugInterface.h"
#include "PowerPCDisasm.h" #include "PowerPCDisasm.h"
#include "../Core.h" #include "../Core.h"
#include "../HW/CPU.h"
#include "../HW/DSP.h" #include "../HW/DSP.h"
#include "../HW/Memmap.h" #include "../HW/Memmap.h"
#include "../PowerPC/PowerPC.h" #include "../PowerPC/PowerPC.h"
@ -134,6 +134,11 @@ void PPCDebugInterface::insertBLR(unsigned int address, unsigned int value)
Memory::Write_U32(value, address); Memory::Write_U32(value, address);
} }
void PPCDebugInterface::breakNow()
{
CCPU::Break();
}
// ======================================================= // =======================================================
// Separate the blocks with colors. // Separate the blocks with colors.

View File

@ -4,7 +4,7 @@
#include <string> #include <string>
#include "DebugInterface.h" #include "DebugInterface.h"
#include "Debugger_Breakpoints.h"
//wrapper between disasm control and Dolphin debugger //wrapper between disasm control and Dolphin debugger
class PPCDebugInterface : public DebugInterface class PPCDebugInterface : public DebugInterface
@ -30,6 +30,7 @@ public:
virtual unsigned int getPC(); virtual unsigned int getPC();
virtual void setPC(unsigned int address); virtual void setPC(unsigned int address);
virtual void step() {} virtual void step() {}
virtual void breakNow();
virtual void runToBreakpoint(); virtual void runToBreakpoint();
virtual void insertBLR(unsigned int address, unsigned int); virtual void insertBLR(unsigned int address, unsigned int);
virtual int getColor(unsigned int address); virtual int getColor(unsigned int address);

View File

@ -24,7 +24,6 @@
#include "../PowerPC/PPCSymbolDB.h" #include "../PowerPC/PPCSymbolDB.h"
#include "../HW/Memmap.h" #include "../HW/Memmap.h"
#include "../Debugger/Debugger_SymbolMap.h" #include "../Debugger/Debugger_SymbolMap.h"
#include "../Debugger/Debugger_BreakPoints.h"
#include "HLE_OS.h" #include "HLE_OS.h"
#include "HLE_Misc.h" #include "HLE_Misc.h"

View File

@ -23,8 +23,6 @@
#include "../Core.h" #include "../Core.h"
#include "CPU.h" #include "CPU.h"
#include "../Debugger/Debugger_BreakPoints.h"
namespace namespace
{ {
static bool g_Branch; static bool g_Branch;

View File

@ -46,7 +46,6 @@ may be redirected here (for example to Read_U32()).
#include "WII_IOB.h" #include "WII_IOB.h"
#include "WII_IPC.h" #include "WII_IPC.h"
#include "../ConfigManager.h" #include "../ConfigManager.h"
#include "../Debugger/Debugger_BreakPoints.h"
#include "../Debugger/Debugger_SymbolMap.h" #include "../Debugger/Debugger_SymbolMap.h"
///////////////////////////// /////////////////////////////

View File

@ -257,7 +257,7 @@ u8 Read_U8(const u32 _Address)
if (mc) if (mc)
{ {
mc->numHits++; mc->numHits++;
mc->Action(_var, _Address,false, 1, PC); mc->Action(&PowerPC::debug_interface, _var, _Address, false, 1, PC);
} }
#endif #endif
return (u8)_var; return (u8)_var;
@ -272,7 +272,7 @@ u16 Read_U16(const u32 _Address)
if (mc) if (mc)
{ {
mc->numHits++; mc->numHits++;
mc->Action(_var, _Address,false, 2, PC); mc->Action(&PowerPC::debug_interface, _var, _Address, false, 2, PC);
} }
#endif #endif
return (u16)_var; return (u16)_var;
@ -294,7 +294,7 @@ u32 Read_U32(const u32 _Address)
if (mc) if (mc)
{ {
mc->numHits++; mc->numHits++;
mc->Action(_var, _Address, false, 4, PC); mc->Action(&PowerPC::debug_interface, _var, _Address, false, 4, PC);
} }
#endif #endif
return _var; return _var;
@ -310,7 +310,7 @@ u64 Read_U64(const u32 _Address)
if (mc) if (mc)
{ {
mc->numHits++; mc->numHits++;
mc->Action((u32)_var, _Address, false, 8, PC); mc->Action(&PowerPC::debug_interface, (u32)_var, _Address, false, 8, PC);
} }
#endif #endif
return _var; return _var;
@ -324,7 +324,7 @@ void Write_U8(const u8 _Data, const u32 _Address)
if (mc) if (mc)
{ {
mc->numHits++; mc->numHits++;
mc->Action(_Data,_Address,true,1,PC); mc->Action(&PowerPC::debug_interface, _Data,_Address,true,1,PC);
} }
#endif #endif
WriteToHardware<u8>(_Address, _Data, _Address, FLAG_WRITE); WriteToHardware<u8>(_Address, _Data, _Address, FLAG_WRITE);
@ -338,7 +338,7 @@ void Write_U16(const u16 _Data, const u32 _Address)
if (mc) if (mc)
{ {
mc->numHits++; mc->numHits++;
mc->Action(_Data,_Address,true,2,PC); mc->Action(&PowerPC::debug_interface, _Data,_Address,true,2,PC);
} }
#endif #endif
@ -353,7 +353,7 @@ void Write_U32(const u32 _Data, const u32 _Address)
if (mc) if (mc)
{ {
mc->numHits++; mc->numHits++;
mc->Action(_Data,_Address,true,4,PC); mc->Action(&PowerPC::debug_interface, _Data,_Address,true,4,PC);
} }
#endif #endif
WriteToHardware<u32>(_Address, _Data, _Address, FLAG_WRITE); WriteToHardware<u32>(_Address, _Data, _Address, FLAG_WRITE);
@ -367,7 +367,7 @@ void Write_U64(const u64 _Data, const u32 _Address)
if (mc) if (mc)
{ {
mc->numHits++; mc->numHits++;
mc->Action((u32)_Data,_Address,true,8,PC); mc->Action(&PowerPC::debug_interface, (u32)_Data,_Address,true,8,PC);
} }
#endif #endif

View File

@ -22,6 +22,7 @@
#include <vector> #include <vector>
#include "../HW/Memmap.h" #include "../HW/Memmap.h"
#include "../PowerPC/PowerPC.h"
#include "PPCSymbolDB.h" #include "PPCSymbolDB.h"
#include "SignatureDB.h" #include "SignatureDB.h"
#include "PPCAnalyst.h" #include "PPCAnalyst.h"
@ -31,7 +32,7 @@ PPCSymbolDB g_symbolDB;
PPCSymbolDB::PPCSymbolDB() PPCSymbolDB::PPCSymbolDB()
{ {
// Get access to the disasm() fgnction // Get access to the disasm() fgnction
debugger = new PPCDebugInterface(); debugger = &PowerPC::debug_interface;
} }
PPCSymbolDB::~PPCSymbolDB() PPCSymbolDB::~PPCSymbolDB()

View File

@ -44,6 +44,7 @@ static CoreMode mode;
BreakPoints breakpoints; BreakPoints breakpoints;
MemChecks memchecks; MemChecks memchecks;
PPCDebugInterface debug_interface;
void CompactCR() void CompactCR()
{ {

View File

@ -20,7 +20,8 @@
#include "Common.h" #include "Common.h"
#include "Gekko.h" #include "Gekko.h"
#include "../Debugger/Debugger_BreakPoints.h" #include "BreakPoints.h"
#include "../Debugger/PPCDebugInterface.h"
class PointerWrap; class PointerWrap;
@ -76,6 +77,7 @@ extern PowerPCState ppcState;
extern BreakPoints breakpoints; extern BreakPoints breakpoints;
extern MemChecks memchecks; extern MemChecks memchecks;
extern PPCDebugInterface debug_interface;
void Init(); void Init();
void Shutdown(); void Shutdown();

View File

@ -24,11 +24,9 @@ files = ["ActionReplay.cpp",
"Boot/Boot_ELF.cpp", "Boot/Boot_ELF.cpp",
"Boot/Boot_WiiWAD.cpp", "Boot/Boot_WiiWAD.cpp",
"Boot/ElfReader.cpp", "Boot/ElfReader.cpp",
"Debugger/Debugger_BreakPoints.cpp",
"Debugger/Debugger_SymbolMap.cpp", "Debugger/Debugger_SymbolMap.cpp",
"Debugger/Dump.cpp", "Debugger/Dump.cpp",
"Debugger/PPCDebugInterface.cpp", "Debugger/PPCDebugInterface.cpp",
# "Debugger/GClibloc.cpp", #Outdated
"HW/AudioInterface.cpp", "HW/AudioInterface.cpp",
"HW/CommandProcessor.cpp", "HW/CommandProcessor.cpp",
"HW/CPU.cpp", "HW/CPU.cpp",

View File

@ -353,7 +353,7 @@ void CCodeWindow::CreateGUIControls(const SCoreStartupParameter& _LocalCoreStart
wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL); wxBoxSizer* sizerBig = new wxBoxSizer(wxHORIZONTAL);
wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL); wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
DebugInterface* di = new PPCDebugInterface(); DebugInterface* di = &PowerPC::debug_interface;
codeview = new CCodeView(di, &g_symbolDB, this, ID_CODEVIEW); codeview = new CCodeView(di, &g_symbolDB, this, ID_CODEVIEW);
sizerBig->Add(sizerLeft, 2, wxEXPAND); sizerBig->Add(sizerLeft, 2, wxEXPAND);

View File

@ -66,7 +66,7 @@ CMemoryWindow::CMemoryWindow(wxWindow* parent, wxWindowID id,
// didn't see anything usefull in the left part // didn't see anything usefull in the left part
//wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL); //wxBoxSizer* sizerLeft = new wxBoxSizer(wxVERTICAL);
DebugInterface* di = new PPCDebugInterface(); DebugInterface* di = &PowerPC::debug_interface;
//sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(20, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND); //sizerLeft->Add(symbols = new wxListBox(this, IDM_SYMBOLLIST, wxDefaultPosition, wxSize(20, 100), 0, NULL, wxLB_SORT), 1, wxEXPAND);
memview = new CMemoryView(di, this, wxID_ANY); memview = new CMemoryView(di, this, wxID_ANY);