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"
>
</File>
<File
RelativePath=".\Src\PowerPC\Jit64\JitCore.cpp"
>
</File>
<File
RelativePath=".\Src\PowerPC\Jit64\JitCore.h"
>
</File>
<File
RelativePath=".\Src\PowerPC\Jit64\JitRegCache.cpp"
>

View File

@ -44,7 +44,7 @@ public:
private:
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);

View File

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

View File

@ -27,7 +27,9 @@
#include "../Debugger/Debugger_BreakPoints.h"
using namespace PowerPC;
namespace {
namespace
{
static bool g_Branch;
static Common::Event m_StepEvent;
static Common::Event *m_SyncEvent;
@ -53,51 +55,21 @@ void CCPU::Run()
while (true)
{
switch(PowerPC::state) {
reswitch:
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);
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:
//1: wait for step command..
m_StepEvent.Wait();
//1: wait for step command..
if (state == CPU_POWERDOWN)
return;
if (state != CPU_STEPPING)
goto reswitch;
//2: check for cpu compare
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()
{
EnableStepping(true);

View File

@ -17,9 +17,11 @@
#include "../../HW/Memmap.h"
#include "../../HW/CPU.h"
#include "../../Host.h"
#include "../PPCTables.h"
#include "Interpreter.h"
#include "../../Debugger/Debugger_SymbolMap.h"
#include "../../Debugger/Debugger_Breakpoints.h"
#include "../../CoreTiming.h"
#include "../../Core.h"
#include "PowerPCDisasm.h"
@ -134,6 +136,36 @@ void Run()
while (!PowerPC::state)
{
//we have to check exceptions at branches apparently (or maybe just rfi?)
if (Core::GetStartupParameter().bEnableDebugging)
{
// Debugging friendly version of inner loop. Tries to do the timing as similarly to the
// JIT as possible. Does not take into account that some instructions take multiple cycles.
while (CoreTiming::downcount > 0)
{
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;
@ -144,6 +176,7 @@ void Run()
}
CoreTiming::downcount -= i;
}
}
CoreTiming::Advance();

View File

@ -173,10 +173,9 @@ namespace CPUCompare
void Jit64::Init()
{
asm_routines.compareEnabled = ::Core::g_CoreStartupParameter.bRunCompareClient;
if (Core::g_CoreStartupParameter.bJITUnlimitedCache)
{
CODE_SIZE = 1024*1024*8*8;
}
jo.optimizeStack = true;
jo.enableBlocklink = false; // Speed boost, but not 100% safe
@ -351,12 +350,13 @@ namespace CPUCompare
void Jit64::SingleStep()
{
// NOT USED, NOT TESTED, PROBABLY NOT WORKING YET
// PanicAlert("Single");
/*
JitBlock temp_block;
PPCAnalyst::CodeBuffer temp_codebuffer(1); // Only room for one instruction! Single step!
const u8 *code = DoJit(PowerPC::ppcState.pc, &temp_codebuffer, &temp_block);
CompiledCode pExecAddr = (CompiledCode)code;
pExecAddr();
pExecAddr();*/
}
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 "Jit64/Jit.h"
#include "Jit64/JitCore.h"
#include "Jit64/JitCache.h"
#include "PowerPC.h"
#include "PPCTables.h"
@ -118,7 +117,7 @@ void Init()
// Initialize both execution engines ...
Interpreter::Init();
JitCore::Init();
jit.Init();
// ... but start as interpreter by default.
mode = MODE_INTERPRETER;
state = CPU_STEPPING;
@ -127,7 +126,7 @@ void Init()
void Shutdown()
{
// Shutdown both execution engines. Doesn't matter which one is active.
JitCore::Shutdown();
jit.Shutdown();
Interpreter::Shutdown();
}
@ -157,7 +156,7 @@ void SingleStep()
Interpreter::SingleStep();
break;
case MODE_JIT:
JitCore::SingleStep();
jit.SingleStep();
break;
}
}
@ -171,7 +170,7 @@ void RunLoop()
Interpreter::Run();
break;
case MODE_JIT:
JitCore::Run();
jit.Run();
break;
}
Host_UpdateDisasmDialog();
@ -180,11 +179,7 @@ void RunLoop()
void Start()
{
// Select running mode for CPU.cpp
state = Core::g_CoreStartupParameter.bEnableDebugging ? CPU_RUNNINGDEBUG : CPU_RUNNING;
if (Core::bReadTrace || Core::bWriteTrace)
{
state = CPU_RUNNING;
}
Host_UpdateDisasmDialog();
}

View File

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

View File

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