Remove the entire concept of CPU_RUNNING_DEBUG and move the responsibility for breakpoint handling into the CPU cores. Breakpoints still only work in interpreter, not in JIT.. but now it's closer to becoming possible.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@1617 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
hrydgard 2008-12-21 11:56:37 +00:00
parent 347da362f1
commit ad44788b36
11 changed files with 75 additions and 244 deletions

View File

@ -1010,14 +1010,6 @@
RelativePath=".\Src\PowerPC\Jit64\JitCache.h" RelativePath=".\Src\PowerPC\Jit64\JitCache.h"
> >
</File> </File>
<File
RelativePath=".\Src\PowerPC\Jit64\JitCore.cpp"
>
</File>
<File
RelativePath=".\Src\PowerPC\Jit64\JitCore.h"
>
</File>
<File <File
RelativePath=".\Src\PowerPC\Jit64\JitRegCache.cpp" RelativePath=".\Src\PowerPC\Jit64\JitRegCache.cpp"
> >

View File

@ -44,7 +44,7 @@ public:
private: private:
enum { BIOS_SIZE = 2*1024*1024 }; enum { BIOS_SIZE = 2*1024*1024 };
static void RunFunction(u32 _iAddr, bool _bUseDebugger); static void RunFunction(u32 _iAddr);
static void UpdateDebugger_MapLoaded(const char* _gameID = NULL); static void UpdateDebugger_MapLoaded(const char* _gameID = NULL);

View File

@ -32,30 +32,18 @@
#include "VolumeCreator.h" #include "VolumeCreator.h"
#include "Boot.h" #include "Boot.h"
void CBoot::RunFunction(u32 _iAddr, bool _bUseDebugger) void CBoot::RunFunction(u32 _iAddr)
{ {
PC = _iAddr; PC = _iAddr;
LR = 0x00; LR = 0x00;
if (_bUseDebugger) while (PC != 0x00)
{ PowerPC::SingleStep();
CCPU::Break();
while (PC != 0x00)
CCPU::SingleStep();
}
else
{
while (PC != 0x00)
PowerPC::SingleStep();
}
} }
// __________________________________________________________________________________________________
//
// BIOS HLE: // BIOS HLE:
// copy the apploader to 0x81200000 // copy the apploader to 0x81200000
// execute the apploader // execute the apploader, function by function, using the above utility.
//
void CBoot::EmulatedBIOS(bool _bDebug) void CBoot::EmulatedBIOS(bool _bDebug)
{ {
LOG(BOOT, "Faking GC BIOS..."); LOG(BOOT, "Faking GC BIOS...");
@ -102,24 +90,22 @@ void CBoot::EmulatedBIOS(bool _bDebug)
VolumeHandler::ReadToPtr(Memory::GetPointer(0x81200000), iAppLoaderOffset + 0x20, iAppLoaderSize); VolumeHandler::ReadToPtr(Memory::GetPointer(0x81200000), iAppLoaderOffset + 0x20, iAppLoaderSize);
// ======================================================================================= // =======================================================================================
// Call iAppLoaderEntry.
//call iAppLoaderEntry
LOG(MASTER_LOG, "Call iAppLoaderEntry"); LOG(MASTER_LOG, "Call iAppLoaderEntry");
u32 iAppLoaderFuncAddr = 0x80003100; u32 iAppLoaderFuncAddr = 0x80003100;
PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0; PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0;
PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4; PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4;
PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8;
RunFunction(iAppLoaderEntry, _bDebug); RunFunction(iAppLoaderEntry);
u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0); u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr + 0);
u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4); u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr + 4);
u32 iAppLoaderClose = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+8); u32 iAppLoaderClose = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr + 8);
// iAppLoaderInit // iAppLoaderInit
LOG(MASTER_LOG, "Call iAppLoaderInit"); LOG(MASTER_LOG, "Call iAppLoaderInit");
PowerPC::ppcState.gpr[3] = 0x81300000; PowerPC::ppcState.gpr[3] = 0x81300000;
RunFunction(iAppLoaderInit, _bDebug); RunFunction(iAppLoaderInit);
// ======================================================================================= // =======================================================================================
/* iAppLoaderMain - Here we load the apploader, the DOL (the exe) and the FST (filesystem). /* iAppLoaderMain - Here we load the apploader, the DOL (the exe) and the FST (filesystem).
@ -133,7 +119,7 @@ void CBoot::EmulatedBIOS(bool _bDebug)
PowerPC::ppcState.gpr[4] = 0x81300008; PowerPC::ppcState.gpr[4] = 0x81300008;
PowerPC::ppcState.gpr[5] = 0x8130000c; PowerPC::ppcState.gpr[5] = 0x8130000c;
RunFunction(iAppLoaderMain, _bDebug); RunFunction(iAppLoaderMain);
u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004); u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004);
u32 iLength = Memory::ReadUnchecked_U32(0x81300008); u32 iLength = Memory::ReadUnchecked_U32(0x81300008);
@ -145,10 +131,9 @@ void CBoot::EmulatedBIOS(bool _bDebug)
} while(PowerPC::ppcState.gpr[3] != 0x00); } while(PowerPC::ppcState.gpr[3] != 0x00);
// ======================================================================================= // =======================================================================================
// iAppLoaderClose // iAppLoaderClose
LOG(MASTER_LOG, "call iAppLoaderClose"); LOG(MASTER_LOG, "call iAppLoaderClose");
RunFunction(iAppLoaderClose, _bDebug); RunFunction(iAppLoaderClose);
// Load patches // Load patches
std::string gameID = VolumeHandler::GetVolume()->GetUniqueID(); std::string gameID = VolumeHandler::GetVolume()->GetUniqueID();
@ -354,7 +339,7 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0; PowerPC::ppcState.gpr[3] = iAppLoaderFuncAddr + 0;
PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4; PowerPC::ppcState.gpr[4] = iAppLoaderFuncAddr + 4;
PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8; PowerPC::ppcState.gpr[5] = iAppLoaderFuncAddr + 8;
RunFunction(iAppLoaderEntry, _bDebug); RunFunction(iAppLoaderEntry);
u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0); u32 iAppLoaderInit = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+0);
u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4); u32 iAppLoaderMain = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+4);
u32 iAppLoaderClose = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+8); u32 iAppLoaderClose = Memory::ReadUnchecked_U32(iAppLoaderFuncAddr+8);
@ -362,7 +347,7 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
// iAppLoaderInit // iAppLoaderInit
LOG(BOOT, "Call iAppLoaderInit"); LOG(BOOT, "Call iAppLoaderInit");
PowerPC::ppcState.gpr[3] = 0x81300000; PowerPC::ppcState.gpr[3] = 0x81300000;
RunFunction(iAppLoaderInit, _bDebug); RunFunction(iAppLoaderInit);
// iAppLoaderMain // iAppLoaderMain
LOG(BOOT, "Call iAppLoaderMain"); LOG(BOOT, "Call iAppLoaderMain");
@ -372,7 +357,7 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
PowerPC::ppcState.gpr[4] = 0x81300008; PowerPC::ppcState.gpr[4] = 0x81300008;
PowerPC::ppcState.gpr[5] = 0x8130000c; PowerPC::ppcState.gpr[5] = 0x8130000c;
RunFunction(iAppLoaderMain, _bDebug); RunFunction(iAppLoaderMain);
u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004); u32 iRamAddress = Memory::ReadUnchecked_U32(0x81300004);
u32 iLength = Memory::ReadUnchecked_U32(0x81300008); u32 iLength = Memory::ReadUnchecked_U32(0x81300008);
@ -384,7 +369,7 @@ bool CBoot::EmulatedBIOS_Wii(bool _bDebug)
// iAppLoaderClose // iAppLoaderClose
LOG(BOOT, "call iAppLoaderClose"); LOG(BOOT, "call iAppLoaderClose");
RunFunction(iAppLoaderClose, _bDebug); RunFunction(iAppLoaderClose);
// Load patches and run startup patches // Load patches and run startup patches
std::string gameID = VolumeHandler::GetVolume()->GetUniqueID(); std::string gameID = VolumeHandler::GetVolume()->GetUniqueID();

View File

@ -27,7 +27,9 @@
#include "../Debugger/Debugger_BreakPoints.h" #include "../Debugger/Debugger_BreakPoints.h"
using namespace PowerPC; using namespace PowerPC;
namespace {
namespace
{
static bool g_Branch; static bool g_Branch;
static Common::Event m_StepEvent; static Common::Event m_StepEvent;
static Common::Event *m_SyncEvent; static Common::Event *m_SyncEvent;
@ -53,52 +55,22 @@ void CCPU::Run()
while (true) while (true)
{ {
switch(PowerPC::state) { reswitch:
switch (PowerPC::state)
{
case CPU_RUNNING: case CPU_RUNNING:
//1: enter a fast runloop //1: enter a fast runloop
PowerPC::RunLoop(); PowerPC::RunLoop();
break; break;
case CPU_RUNNINGDEBUG:
//1: check for cpucompare
/*
if (CPUCompare::IsEnabled() && g_Branch)
{
g_Branch = false;
CPUCompare::Sync();
}*/
//2: check for breakpoint
if (BreakPoints::IsAddressBreakPoint(PC))
{
LOG(GEKKO, "Hit Breakpoint - %08x", PC);
EnableStepping(true);
if (BreakPoints::IsTempBreakPoint(PC))
BreakPoints::Remove(PC);
Host_UpdateDisasmDialog();
break;
}
/* if (!Core::g_CoreStartupParameter.bUseJIT && BreakPoints::GetBreakCount() == PowerPC::ppcState.DebugCount)
{
LOG(GEKKO, "Hit DebugCount breakpoint - %i", PowerPC::ppcState.DebugCount);
EnableStepping(true);
break;
}*/
//3: do a step
PowerPC::SingleStep();
break;
case CPU_STEPPING: case CPU_STEPPING:
//1: wait for step command..
m_StepEvent.Wait(); m_StepEvent.Wait();
//1: wait for step command..
if (state == CPU_POWERDOWN) if (state == CPU_POWERDOWN)
return; return;
if (state != CPU_STEPPING)
goto reswitch;
//2: check for cpu compare //2: check for cpu compare
if (CPUCompare::IsEnabled() && g_Branch) if (CPUCompare::IsEnabled() && g_Branch)
{ {
@ -165,65 +137,6 @@ void CCPU::EnableStepping(const bool _bStepping)
} }
} }
void CCPU::SingleStep()
{
switch (PowerPC::state)
{
case CPU_RUNNING:
//1: enter a fast runloop
PowerPC::RunLoop();
break;
case CPU_RUNNINGDEBUG:
//1: check for cpucompare
if (CPUCompare::IsEnabled() && g_Branch)
{
g_Branch = false;
CPUCompare::Sync();
}
//2: check for breakpoint
if (BreakPoints::IsAddressBreakPoint(PC))
{
LOG(GEKKO, "Hit Breakpoint - %08x", PC);
EnableStepping(true);
if (BreakPoints::IsTempBreakPoint(PC))
BreakPoints::Remove(PC);
break;
}
//3: do a step
PowerPC::SingleStep();
break;
case CPU_STEPPING:
//1: wait for step command..
m_StepEvent.Wait();
//2: check for cpu compare
if (CPUCompare::IsEnabled() && g_Branch)
{
g_Branch = false;
CPUCompare::Sync();
}
//3: do a step
PowerPC::SingleStep();
//4: update disasm dialog
if (m_SyncEvent) {
m_SyncEvent->Set();
m_SyncEvent = 0;
}
Host_UpdateDisasmDialog();
break;
case CPU_POWERDOWN:
//1: Exit loop!!
return;
}
}
void CCPU::Break() void CCPU::Break()
{ {
EnableStepping(true); EnableStepping(true);

View File

@ -17,9 +17,11 @@
#include "../../HW/Memmap.h" #include "../../HW/Memmap.h"
#include "../../HW/CPU.h" #include "../../HW/CPU.h"
#include "../../Host.h"
#include "../PPCTables.h" #include "../PPCTables.h"
#include "Interpreter.h" #include "Interpreter.h"
#include "../../Debugger/Debugger_SymbolMap.h" #include "../../Debugger/Debugger_SymbolMap.h"
#include "../../Debugger/Debugger_Breakpoints.h"
#include "../../CoreTiming.h" #include "../../CoreTiming.h"
#include "../../Core.h" #include "../../Core.h"
#include "PowerPCDisasm.h" #include "PowerPCDisasm.h"
@ -134,15 +136,46 @@ void Run()
while (!PowerPC::state) while (!PowerPC::state)
{ {
//we have to check exceptions at branches apparently (or maybe just rfi?) //we have to check exceptions at branches apparently (or maybe just rfi?)
while (CoreTiming::downcount > 0) if (Core::GetStartupParameter().bEnableDebugging)
{ {
m_EndBlock = false; // Debugging friendly version of inner loop. Tries to do the timing as similarly to the
int i; // JIT as possible. Does not take into account that some instructions take multiple cycles.
for (i = 0; !m_EndBlock; i++) while (CoreTiming::downcount > 0)
{ {
SingleStepInner(); m_EndBlock = false;
int i;
for (i = 0; !m_EndBlock; i++)
{
//2: check for breakpoint
if (BreakPoints::IsAddressBreakPoint(PC))
{
LOG(GEKKO, "Hit Breakpoint - %08x", PC);
CCPU::EnableStepping(true);
if (BreakPoints::IsTempBreakPoint(PC))
BreakPoints::Remove(PC);
Host_UpdateDisasmDialog();
return;
}
SingleStepInner();
}
CoreTiming::downcount -= i;
}
}
else
{
// "fast" version of inner loop. well, it's not so fast.
while (CoreTiming::downcount > 0)
{
m_EndBlock = false;
int i;
for (i = 0; !m_EndBlock; i++)
{
SingleStepInner();
}
CoreTiming::downcount -= i;
} }
CoreTiming::downcount -= i;
} }
CoreTiming::Advance(); CoreTiming::Advance();

View File

@ -173,10 +173,9 @@ namespace CPUCompare
void Jit64::Init() void Jit64::Init()
{ {
asm_routines.compareEnabled = ::Core::g_CoreStartupParameter.bRunCompareClient;
if (Core::g_CoreStartupParameter.bJITUnlimitedCache) if (Core::g_CoreStartupParameter.bJITUnlimitedCache)
{
CODE_SIZE = 1024*1024*8*8; CODE_SIZE = 1024*1024*8*8;
}
jo.optimizeStack = true; jo.optimizeStack = true;
jo.enableBlocklink = false; // Speed boost, but not 100% safe jo.enableBlocklink = false; // Speed boost, but not 100% safe
@ -351,12 +350,13 @@ namespace CPUCompare
void Jit64::SingleStep() void Jit64::SingleStep()
{ {
// NOT USED, NOT TESTED, PROBABLY NOT WORKING YET // NOT USED, NOT TESTED, PROBABLY NOT WORKING YET
// PanicAlert("Single");
/*
JitBlock temp_block; JitBlock temp_block;
PPCAnalyst::CodeBuffer temp_codebuffer(1); // Only room for one instruction! Single step! PPCAnalyst::CodeBuffer temp_codebuffer(1); // Only room for one instruction! Single step!
const u8 *code = DoJit(PowerPC::ppcState.pc, &temp_codebuffer, &temp_block); const u8 *code = DoJit(PowerPC::ppcState.pc, &temp_codebuffer, &temp_block);
CompiledCode pExecAddr = (CompiledCode)code; CompiledCode pExecAddr = (CompiledCode)code;
pExecAddr(); pExecAddr();*/
} }
void Jit64::Jit(u32 em_address) void Jit64::Jit(u32 em_address)

View File

@ -1,55 +0,0 @@
// Copyright (C) 2003-2008 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 "JitCore.h"
#include "JitCache.h"
#include "JitAsm.h"
#include "Jit.h"
#include "../../HW/Memmap.h"
#include "../../HW/CPU.h"
#include "../../HW/DSP.h"
#include "../../HW/GPFifo.h"
#include "../../HW/VideoInterface.h"
#include "../../HW/SerialInterface.h"
#include "../../Core.h"
namespace JitCore
{
void Init()
{
jit.Init();
asm_routines.compareEnabled = ::Core::g_CoreStartupParameter.bRunCompareClient;
}
void Shutdown()
{
jit.Shutdown();
}
void SingleStep()
{
Run();
}
void Run()
{
jit.Run();
}
} // namespace

View File

@ -1,30 +0,0 @@
// Copyright (C) 2003-2008 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 _JITCORE_H
#define _JITCORE_H
namespace JitCore
{
void Init();
void Shutdown();
void Reset();
void SingleStep();
void Run();
}
#endif

View File

@ -27,7 +27,6 @@
#include "Interpreter/Interpreter.h" #include "Interpreter/Interpreter.h"
#include "Jit64/Jit.h" #include "Jit64/Jit.h"
#include "Jit64/JitCore.h"
#include "Jit64/JitCache.h" #include "Jit64/JitCache.h"
#include "PowerPC.h" #include "PowerPC.h"
#include "PPCTables.h" #include "PPCTables.h"
@ -118,7 +117,7 @@ void Init()
// Initialize both execution engines ... // Initialize both execution engines ...
Interpreter::Init(); Interpreter::Init();
JitCore::Init(); jit.Init();
// ... but start as interpreter by default. // ... but start as interpreter by default.
mode = MODE_INTERPRETER; mode = MODE_INTERPRETER;
state = CPU_STEPPING; state = CPU_STEPPING;
@ -127,7 +126,7 @@ void Init()
void Shutdown() void Shutdown()
{ {
// Shutdown both execution engines. Doesn't matter which one is active. // Shutdown both execution engines. Doesn't matter which one is active.
JitCore::Shutdown(); jit.Shutdown();
Interpreter::Shutdown(); Interpreter::Shutdown();
} }
@ -157,7 +156,7 @@ void SingleStep()
Interpreter::SingleStep(); Interpreter::SingleStep();
break; break;
case MODE_JIT: case MODE_JIT:
JitCore::SingleStep(); jit.SingleStep();
break; break;
} }
} }
@ -171,7 +170,7 @@ void RunLoop()
Interpreter::Run(); Interpreter::Run();
break; break;
case MODE_JIT: case MODE_JIT:
JitCore::Run(); jit.Run();
break; break;
} }
Host_UpdateDisasmDialog(); Host_UpdateDisasmDialog();
@ -180,11 +179,7 @@ void RunLoop()
void Start() void Start()
{ {
// Select running mode for CPU.cpp // Select running mode for CPU.cpp
state = Core::g_CoreStartupParameter.bEnableDebugging ? CPU_RUNNINGDEBUG : CPU_RUNNING; state = CPU_RUNNING;
if (Core::bReadTrace || Core::bWriteTrace)
{
state = CPU_RUNNING;
}
Host_UpdateDisasmDialog(); Host_UpdateDisasmDialog();
} }

View File

@ -67,7 +67,6 @@ struct GC_ALIGNED64(PowerPCState)
enum CPUState enum CPUState
{ {
CPU_RUNNING = 0, CPU_RUNNING = 0,
CPU_RUNNINGDEBUG = 1,
CPU_STEPPING = 2, CPU_STEPPING = 2,
CPU_POWERDOWN = 3, CPU_POWERDOWN = 3,
}; };

View File

@ -690,7 +690,6 @@ void CCodeWindow::OnCodeStep(wxCommandEvent& event)
case IDM_STEP: case IDM_STEP:
SingleCPUStep(); SingleCPUStep();
break; break;
case IDM_STEPOVER: case IDM_STEPOVER: