mirror of
https://github.com/izzy2lost/dolphin.git
synced 2026-06-19 01:16:48 -07:00
Merge pull request #1291 from skidau/debugger-step-out
Dolphin debugger enhancements
This commit is contained in:
@@ -113,6 +113,19 @@ void BreakPoints::Clear()
|
||||
m_BreakPoints.clear();
|
||||
}
|
||||
|
||||
void BreakPoints::ClearAllTemporary()
|
||||
{
|
||||
for (const TBreakPoint& bp : m_BreakPoints)
|
||||
{
|
||||
if (bp.bTemporary)
|
||||
{
|
||||
if (jit)
|
||||
jit->GetBlockCache()->InvalidateICache(bp.iAddress, 4, true);
|
||||
Remove(bp.iAddress);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
MemChecks::TMemChecksStr MemChecks::GetStrings() const
|
||||
{
|
||||
TMemChecksStr mcs;
|
||||
@@ -204,3 +217,87 @@ void TMemCheck::Action(DebugInterface *debug_interface, u32 iValue, u32 addr, bo
|
||||
debug_interface->BreakNow();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const bool Watches::IsAddressWatch(u32 _iAddress)
|
||||
{
|
||||
for (const TWatch& bp : m_Watches)
|
||||
if (bp.iAddress == _iAddress)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Watches::TWatchesStr Watches::GetStrings() const
|
||||
{
|
||||
TWatchesStr bps;
|
||||
for (const TWatch& bp : m_Watches)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << std::hex << bp.iAddress << " " << bp.name;
|
||||
bps.push_back(ss.str());
|
||||
}
|
||||
|
||||
return bps;
|
||||
}
|
||||
|
||||
void Watches::AddFromStrings(const TWatchesStr& bpstrs)
|
||||
{
|
||||
for (const std::string& bpstr : bpstrs)
|
||||
{
|
||||
TWatch bp;
|
||||
std::stringstream ss;
|
||||
ss << std::hex << bpstr;
|
||||
ss >> bp.iAddress;
|
||||
ss >> std::ws;
|
||||
getline(ss, bp.name);
|
||||
Add(bp);
|
||||
}
|
||||
}
|
||||
|
||||
void Watches::Add(const TWatch& bp)
|
||||
{
|
||||
if (!IsAddressWatch(bp.iAddress))
|
||||
{
|
||||
m_Watches.push_back(bp);
|
||||
}
|
||||
}
|
||||
|
||||
void Watches::Add(u32 em_address)
|
||||
{
|
||||
if (!IsAddressWatch(em_address)) // only add new addresses
|
||||
{
|
||||
TWatch pt; // breakpoint settings
|
||||
pt.bOn = true;
|
||||
pt.iAddress = em_address;
|
||||
|
||||
m_Watches.push_back(pt);
|
||||
}
|
||||
}
|
||||
|
||||
void Watches::Update(int count, u32 em_address)
|
||||
{
|
||||
m_Watches.at(count).iAddress = em_address;
|
||||
}
|
||||
|
||||
void Watches::UpdateName(int count, const std::string name)
|
||||
{
|
||||
m_Watches.at(count).name = name;
|
||||
}
|
||||
|
||||
void Watches::Remove(u32 em_address)
|
||||
{
|
||||
for (auto i = m_Watches.begin(); i != m_Watches.end(); ++i)
|
||||
{
|
||||
if (i->iAddress == em_address)
|
||||
{
|
||||
m_Watches.erase(i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Watches::Clear()
|
||||
{
|
||||
m_Watches.clear();
|
||||
}
|
||||
|
||||
@@ -44,6 +44,13 @@ struct TMemCheck
|
||||
bool write, int size, u32 pc);
|
||||
};
|
||||
|
||||
struct TWatch
|
||||
{
|
||||
std::string name = "";
|
||||
u32 iAddress;
|
||||
bool bOn;
|
||||
};
|
||||
|
||||
// Code breakpoints.
|
||||
class BreakPoints
|
||||
{
|
||||
@@ -67,6 +74,7 @@ public:
|
||||
// Remove Breakpoint
|
||||
void Remove(u32 _iAddress);
|
||||
void Clear();
|
||||
void ClearAllTemporary();
|
||||
|
||||
void DeleteByAddress(u32 _Address);
|
||||
|
||||
@@ -98,3 +106,33 @@ public:
|
||||
|
||||
void Clear() { m_MemChecks.clear(); }
|
||||
};
|
||||
|
||||
class Watches
|
||||
{
|
||||
public:
|
||||
typedef std::vector<TWatch> TWatches;
|
||||
typedef std::vector<std::string> TWatchesStr;
|
||||
|
||||
const TWatches& GetWatches() { return m_Watches; }
|
||||
|
||||
TWatchesStr GetStrings() const;
|
||||
void AddFromStrings(const TWatchesStr& bps);
|
||||
|
||||
const bool IsAddressWatch(u32 _iAddress);
|
||||
|
||||
// Add BreakPoint
|
||||
void Add(u32 em_address);
|
||||
void Add(const TWatch& bp);
|
||||
|
||||
void Update(int count, u32 em_address);
|
||||
void UpdateName(int count, const std::string name);
|
||||
|
||||
// Remove Breakpoint
|
||||
void Remove(u32 _iAddress);
|
||||
void Clear();
|
||||
|
||||
void DeleteByAddress(u32 _Address);
|
||||
|
||||
private:
|
||||
TWatches m_Watches;
|
||||
};
|
||||
@@ -18,6 +18,7 @@ public:
|
||||
virtual void ClearBreakpoint(unsigned int /*address*/){}
|
||||
virtual void ClearAllBreakpoints() {}
|
||||
virtual void ToggleBreakpoint(unsigned int /*address*/){}
|
||||
virtual void AddWatch(unsigned int /*address*/){}
|
||||
virtual void ClearAllMemChecks() {}
|
||||
virtual bool IsMemCheck(unsigned int /*address*/) {return false;}
|
||||
virtual void ToggleMemCheck(unsigned int /*address*/){}
|
||||
|
||||
@@ -131,6 +131,11 @@ void PPCDebugInterface::ToggleBreakpoint(unsigned int address)
|
||||
PowerPC::breakpoints.Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::AddWatch(unsigned int address)
|
||||
{
|
||||
PowerPC::watches.Add(address);
|
||||
}
|
||||
|
||||
void PPCDebugInterface::ClearAllMemChecks()
|
||||
{
|
||||
PowerPC::memchecks.Clear();
|
||||
|
||||
@@ -22,6 +22,7 @@ public:
|
||||
virtual void SetBreakpoint(unsigned int address) override;
|
||||
virtual void ClearBreakpoint(unsigned int address) override;
|
||||
virtual void ClearAllBreakpoints() override;
|
||||
virtual void AddWatch(unsigned int address) override;
|
||||
virtual void ToggleBreakpoint(unsigned int address) override;
|
||||
virtual void ClearAllMemChecks() override;
|
||||
virtual bool IsMemCheck(unsigned int address) override;
|
||||
|
||||
@@ -117,6 +117,15 @@ void CCPU::EnableStepping(const bool _bStepping)
|
||||
}
|
||||
else
|
||||
{
|
||||
// SingleStep so that the "continue", "step over" and "step out" debugger functions
|
||||
// work when the PC is at a breakpoint at the beginning of the block
|
||||
if (PowerPC::breakpoints.IsAddressBreakPoint(PC) && PowerPC::GetMode() != PowerPC::MODE_INTERPRETER)
|
||||
{
|
||||
PowerPC::CoreMode oldMode = PowerPC::GetMode();
|
||||
PowerPC::SetMode(PowerPC::MODE_INTERPRETER);
|
||||
PowerPC::SingleStep();
|
||||
PowerPC::SetMode(oldMode);
|
||||
}
|
||||
PowerPC::Start();
|
||||
m_StepEvent.Set();
|
||||
g_video_backend->EmuStateChange(EMUSTATE_CHANGE_PLAY);
|
||||
|
||||
@@ -174,13 +174,8 @@ bool Jit64::HandleFault(uintptr_t access_address, SContext* ctx)
|
||||
void Jit64::Init()
|
||||
{
|
||||
jo.optimizeStack = true;
|
||||
jo.enableBlocklink = true;
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockLinking ||
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU)
|
||||
{
|
||||
// TODO: support block linking with MMU
|
||||
jo.enableBlocklink = false;
|
||||
}
|
||||
EnableBlockLink();
|
||||
|
||||
jo.fpAccurateFcmp = SConfig::GetInstance().m_LocalCoreStartupParameter.bFPRF;
|
||||
jo.optimizeGatherPipe = true;
|
||||
jo.fastInterrupts = false;
|
||||
@@ -195,7 +190,7 @@ void Jit64::Init()
|
||||
|
||||
// BLR optimization has the same consequences as block linking, as well as
|
||||
// depending on the fault handler to be safe in the event of excessive BL.
|
||||
m_enable_blr_optimization = jo.enableBlocklink && SConfig::GetInstance().m_LocalCoreStartupParameter.bFastmem;
|
||||
m_enable_blr_optimization = jo.enableBlocklink && SConfig::GetInstance().m_LocalCoreStartupParameter.bFastmem && !SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging;
|
||||
m_clear_cache_asap = false;
|
||||
|
||||
m_stack = nullptr;
|
||||
@@ -212,9 +207,7 @@ void Jit64::Init()
|
||||
code_block.m_stats = &js.st;
|
||||
code_block.m_gpa = &js.gpa;
|
||||
code_block.m_fpa = &js.fpa;
|
||||
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE);
|
||||
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE);
|
||||
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE);
|
||||
EnableOptimization();
|
||||
}
|
||||
|
||||
void Jit64::ClearCache()
|
||||
@@ -521,11 +514,23 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging)
|
||||
{
|
||||
// We can link blocks as long as we are not single stepping and there are no breakpoints here
|
||||
EnableBlockLink();
|
||||
EnableOptimization();
|
||||
|
||||
// Comment out the following to disable breakpoints (speed-up)
|
||||
if (!Profiler::g_ProfileBlocks)
|
||||
{
|
||||
if (GetState() == CPU_STEPPING)
|
||||
{
|
||||
blockSize = 1;
|
||||
|
||||
// Do not link this block to other blocks While single stepping
|
||||
jo.enableBlocklink = false;
|
||||
analyzer.ClearOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE);
|
||||
analyzer.ClearOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE);
|
||||
analyzer.ClearOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE);
|
||||
}
|
||||
Trace();
|
||||
}
|
||||
}
|
||||
@@ -715,6 +720,9 @@ const u8* Jit64::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging && breakpoints.IsAddressBreakPoint(ops[i].address) && GetState() != CPU_STEPPING)
|
||||
{
|
||||
// Turn off block linking if there are breakpoints so that the Step Over command does not link this block.
|
||||
jo.enableBlocklink = false;
|
||||
|
||||
gpr.Flush();
|
||||
fpr.Flush();
|
||||
|
||||
@@ -856,3 +864,21 @@ u32 Jit64::CallerSavedRegistersInUse()
|
||||
}
|
||||
return result & ABI_ALL_CALLER_SAVED;
|
||||
}
|
||||
|
||||
void Jit64::EnableBlockLink()
|
||||
{
|
||||
jo.enableBlocklink = true;
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockLinking ||
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU)
|
||||
{
|
||||
// TODO: support block linking with MMU
|
||||
jo.enableBlocklink = false;
|
||||
}
|
||||
}
|
||||
|
||||
void Jit64::EnableOptimization()
|
||||
{
|
||||
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CONDITIONAL_CONTINUE);
|
||||
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_BRANCH_MERGE);
|
||||
analyzer.SetOption(PPCAnalyst::PPCAnalyzer::OPTION_CARRY_MERGE);
|
||||
}
|
||||
|
||||
@@ -64,6 +64,11 @@ public:
|
||||
~Jit64() {}
|
||||
|
||||
void Init() override;
|
||||
|
||||
void EnableOptimization();
|
||||
|
||||
void EnableBlockLink();
|
||||
|
||||
void Shutdown() override;
|
||||
|
||||
bool HandleFault(uintptr_t access_address, SContext* ctx) override;
|
||||
|
||||
@@ -98,9 +98,12 @@ void Jit64::lXXx(UGeckoInstruction inst)
|
||||
if (accessSize == 8 && js.next_inst.OPCD == 31 && js.next_inst.SUBOP10 == 954 &&
|
||||
js.next_inst.RS == inst.RD && js.next_inst.RA == inst.RD && !js.next_inst.Rc)
|
||||
{
|
||||
js.downcountAmount++;
|
||||
js.skipnext = true;
|
||||
signExtend = true;
|
||||
if (PowerPC::GetState() != PowerPC::CPU_STEPPING)
|
||||
{
|
||||
js.downcountAmount++;
|
||||
js.skipnext = true;
|
||||
signExtend = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(ector): Make it dynamically enable/disable idle skipping where appropriate
|
||||
@@ -109,6 +112,7 @@ void Jit64::lXXx(UGeckoInstruction inst)
|
||||
// IMHO those Idles should always be skipped and replaced by a more controllable "native" Idle methode
|
||||
// ... maybe the throttle one already do that :p
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle &&
|
||||
PowerPC::GetState() != PowerPC::CPU_STEPPING &&
|
||||
inst.OPCD == 32 &&
|
||||
(inst.hex & 0xFFFF0000) == 0x800D0000 &&
|
||||
(Memory::ReadUnchecked_U32(js.compilerPC + 4) == 0x28000000 ||
|
||||
|
||||
@@ -228,21 +228,24 @@ void Jit64::mfspr(UGeckoInstruction inst)
|
||||
// Be careful; the actual opcode is for mftb (371), not mfspr (339)
|
||||
if (js.next_inst.OPCD == 31 && js.next_inst.SUBOP10 == 371 && (nextIndex == SPR_TU || nextIndex == SPR_TL))
|
||||
{
|
||||
int n = js.next_inst.RD;
|
||||
js.downcountAmount++;
|
||||
js.skipnext = true;
|
||||
gpr.Lock(d, n);
|
||||
gpr.BindToRegister(d, false);
|
||||
gpr.BindToRegister(n, false);
|
||||
if (iIndex == SPR_TL)
|
||||
MOV(32, gpr.R(d), R(RAX));
|
||||
if (nextIndex == SPR_TL)
|
||||
MOV(32, gpr.R(n), R(RAX));
|
||||
SHR(64, R(RAX), Imm8(32));
|
||||
if (iIndex == SPR_TU)
|
||||
MOV(32, gpr.R(d), R(RAX));
|
||||
if (nextIndex == SPR_TU)
|
||||
MOV(32, gpr.R(n), R(RAX));
|
||||
if (PowerPC::GetState() != PowerPC::CPU_STEPPING)
|
||||
{
|
||||
int n = js.next_inst.RD;
|
||||
js.downcountAmount++;
|
||||
js.skipnext = true;
|
||||
gpr.Lock(d, n);
|
||||
gpr.BindToRegister(d, false);
|
||||
gpr.BindToRegister(n, false);
|
||||
if (iIndex == SPR_TL)
|
||||
MOV(32, gpr.R(d), R(RAX));
|
||||
if (nextIndex == SPR_TL)
|
||||
MOV(32, gpr.R(n), R(RAX));
|
||||
SHR(64, R(RAX), Imm8(32));
|
||||
if (iIndex == SPR_TU)
|
||||
MOV(32, gpr.R(d), R(RAX));
|
||||
if (nextIndex == SPR_TU)
|
||||
MOV(32, gpr.R(n), R(RAX));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -244,13 +244,7 @@ namespace JitILProfiler
|
||||
void JitIL::Init()
|
||||
{
|
||||
jo.optimizeStack = true;
|
||||
jo.enableBlocklink = true;
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockLinking ||
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU)
|
||||
{
|
||||
// TODO: support block linking with MMU
|
||||
jo.enableBlocklink = false;
|
||||
}
|
||||
EnableBlockLink();
|
||||
|
||||
jo.fpAccurateFcmp = false;
|
||||
jo.optimizeGatherPipe = true;
|
||||
@@ -509,11 +503,19 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging)
|
||||
{
|
||||
// We can link blocks as long as we are not single stepping and there are no breakpoints here
|
||||
EnableBlockLink();
|
||||
|
||||
// Comment out the following to disable breakpoints (speed-up)
|
||||
if (!Profiler::g_ProfileBlocks)
|
||||
{
|
||||
if (GetState() == CPU_STEPPING)
|
||||
{
|
||||
blockSize = 1;
|
||||
|
||||
// Do not link this block to other blocks While single stepping
|
||||
jo.enableBlocklink = false;
|
||||
}
|
||||
Trace();
|
||||
}
|
||||
}
|
||||
@@ -648,6 +650,9 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging && breakpoints.IsAddressBreakPoint(ops[i].address) && GetState() != CPU_STEPPING)
|
||||
{
|
||||
// Turn off block linking if there are breakpoints so that the Step Over command does not link this block.
|
||||
jo.enableBlocklink = false;
|
||||
|
||||
ibuild.EmitBreakPointCheck(ibuild.EmitIntConst(ops[i].address));
|
||||
}
|
||||
|
||||
@@ -702,3 +707,14 @@ const u8* JitIL::DoJit(u32 em_address, PPCAnalyst::CodeBuffer *code_buf, JitBloc
|
||||
|
||||
return normalEntry;
|
||||
}
|
||||
|
||||
void JitIL::EnableBlockLink()
|
||||
{
|
||||
jo.enableBlocklink = true;
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bJITNoBlockLinking ||
|
||||
SConfig::GetInstance().m_LocalCoreStartupParameter.bMMU)
|
||||
{
|
||||
// TODO: support block linking with MMU
|
||||
jo.enableBlocklink = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,6 +47,9 @@ public:
|
||||
// Initialization, etc
|
||||
|
||||
void Init() override;
|
||||
|
||||
void EnableBlockLink();
|
||||
|
||||
void Shutdown() override;
|
||||
|
||||
// Jit!
|
||||
|
||||
@@ -316,13 +316,6 @@ void EmuCodeBlock::SafeLoadToReg(X64Reg reg_value, const Gen::OpArg & opAddress,
|
||||
// The following masks the region used by the GC/Wii virtual memory lib
|
||||
mem_mask |= Memory::ADDR_MASK_MEM1;
|
||||
|
||||
#ifdef ENABLE_MEM_CHECK
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging)
|
||||
{
|
||||
mem_mask |= Memory::EXRAM_MASK;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (opAddress.IsImm())
|
||||
{
|
||||
u32 address = (u32)opAddress.offset + offset;
|
||||
@@ -519,13 +512,6 @@ void EmuCodeBlock::SafeWriteRegToReg(OpArg reg_value, X64Reg reg_addr, int acces
|
||||
// The following masks the region used by the GC/Wii virtual memory lib
|
||||
mem_mask |= Memory::ADDR_MASK_MEM1;
|
||||
|
||||
#ifdef ENABLE_MEM_CHECK
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging)
|
||||
{
|
||||
mem_mask |= Memory::EXRAM_MASK;
|
||||
}
|
||||
#endif
|
||||
|
||||
bool swap = !(flags & SAFE_LOADSTORE_NO_SWAP);
|
||||
|
||||
FixupBranch slow, exit;
|
||||
|
||||
@@ -37,6 +37,7 @@ void JitILBase::lXz(UGeckoInstruction inst)
|
||||
// Idle Skipping. This really should be done somewhere else.
|
||||
// Either lower in the IR or higher in PPCAnalyist
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bSkipIdle &&
|
||||
PowerPC::GetState() != PowerPC::CPU_STEPPING &&
|
||||
inst.OPCD == 32 && // Lwx
|
||||
(inst.hex & 0xFFFF0000) == 0x800D0000 &&
|
||||
(Memory::ReadUnchecked_U32(js.compilerPC + 4) == 0x28000000 ||
|
||||
|
||||
@@ -35,6 +35,7 @@ static volatile CPUState state = CPU_POWERDOWN;
|
||||
Interpreter * const interpreter = Interpreter::getInstance();
|
||||
static CoreMode mode;
|
||||
|
||||
Watches watches;
|
||||
BreakPoints breakpoints;
|
||||
MemChecks memchecks;
|
||||
PPCDebugInterface debug_interface;
|
||||
@@ -161,6 +162,9 @@ void Init(int cpu_core)
|
||||
state = CPU_STEPPING;
|
||||
|
||||
ppcState.iCache.Init();
|
||||
|
||||
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bEnableDebugging)
|
||||
breakpoints.ClearAllTemporary();
|
||||
}
|
||||
|
||||
void Shutdown()
|
||||
|
||||
@@ -114,6 +114,7 @@ enum CPUState
|
||||
|
||||
extern PowerPCState ppcState;
|
||||
|
||||
extern Watches watches;
|
||||
extern BreakPoints breakpoints;
|
||||
extern MemChecks memchecks;
|
||||
extern PPCDebugInterface debug_interface;
|
||||
|
||||
@@ -45,6 +45,8 @@ set(GUI_SRCS
|
||||
Debugger/MemoryWindow.cpp
|
||||
Debugger/RegisterView.cpp
|
||||
Debugger/RegisterWindow.cpp
|
||||
Debugger/WatchView.cpp
|
||||
Debugger/WatchWindow.cpp
|
||||
FifoPlayerDlg.cpp
|
||||
Frame.cpp
|
||||
FrameAui.cpp
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#include "Common/CommonTypes.h"
|
||||
#include "Common/FileUtil.h"
|
||||
#include "Common/IniFile.h"
|
||||
#include "Core/ConfigManager.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
#include "DolphinWX/WxUtils.h"
|
||||
@@ -45,9 +46,9 @@ public:
|
||||
{
|
||||
SetToolBitmapSize(wxSize(24, 24));
|
||||
|
||||
m_Bitmaps[Toolbar_Delete] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(24, 24));
|
||||
m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_breakpoint_png).ConvertToImage().Rescale(24, 24));
|
||||
m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_memcheck_png).ConvertToImage().Rescale(24, 24));
|
||||
m_Bitmaps[Toolbar_Delete] = wxBitmap(wxGetBitmapFromMemory(toolbar_delete_png).ConvertToImage().Rescale(16, 16));
|
||||
m_Bitmaps[Toolbar_Add_BP] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_breakpoint_png).ConvertToImage().Rescale(16, 16));
|
||||
m_Bitmaps[Toolbar_Add_MC] = wxBitmap(wxGetBitmapFromMemory(toolbar_add_memcheck_png).ConvertToImage().Rescale(16, 16));
|
||||
|
||||
AddTool(ID_DELETE, _("Delete"), m_Bitmaps[Toolbar_Delete]);
|
||||
Bind(wxEVT_TOOL, &CBreakPointWindow::OnDelete, parent, ID_DELETE);
|
||||
@@ -66,7 +67,7 @@ public:
|
||||
}
|
||||
|
||||
AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_Delete]);
|
||||
Bind(wxEVT_TOOL, &CBreakPointWindow::LoadAll, parent, ID_LOAD);
|
||||
Bind(wxEVT_TOOL, &CBreakPointWindow::Event_LoadAll, parent, ID_LOAD);
|
||||
|
||||
AddTool(ID_SAVE, _("Save"), m_Bitmaps[Toolbar_Delete]);
|
||||
Bind(wxEVT_TOOL, &CBreakPointWindow::Event_SaveAll, parent, ID_SAVE);
|
||||
@@ -112,7 +113,7 @@ CBreakPointWindow::CBreakPointWindow(CCodeWindow* _pCodeWindow, wxWindow* parent
|
||||
m_BreakPointListView = new CBreakPointView(this, wxID_ANY);
|
||||
|
||||
m_mgr.AddPane(new CBreakPointBar(this, wxID_ANY), wxAuiPaneInfo().ToolbarPane().Top().
|
||||
LeftDockable(false).RightDockable(false).BottomDockable(false).Floatable(false));
|
||||
LeftDockable(true).RightDockable(true).BottomDockable(false).Floatable(false));
|
||||
m_mgr.AddPane(m_BreakPointListView, wxAuiPaneInfo().CenterPane());
|
||||
m_mgr.Update();
|
||||
}
|
||||
@@ -180,32 +181,38 @@ void CBreakPointWindow::SaveAll()
|
||||
{
|
||||
// simply dump all to bp/mc files in a way we can read again
|
||||
IniFile ini;
|
||||
if (ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
||||
{
|
||||
ini.SetLines("BreakPoints", PowerPC::breakpoints.GetStrings());
|
||||
ini.SetLines("MemoryChecks", PowerPC::memchecks.GetStrings());
|
||||
ini.Save(File::GetUserPath(F_DEBUGGERCONFIG_IDX));
|
||||
}
|
||||
ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini", false);
|
||||
ini.SetLines("BreakPoints", PowerPC::breakpoints.GetStrings());
|
||||
ini.SetLines("MemoryChecks", PowerPC::memchecks.GetStrings());
|
||||
ini.Save(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini");
|
||||
}
|
||||
|
||||
void CBreakPointWindow::LoadAll(wxCommandEvent& WXUNUSED(event))
|
||||
void CBreakPointWindow::Event_LoadAll(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
LoadAll();
|
||||
return;
|
||||
}
|
||||
|
||||
void CBreakPointWindow::LoadAll()
|
||||
{
|
||||
IniFile ini;
|
||||
BreakPoints::TBreakPointsStr newbps;
|
||||
MemChecks::TMemChecksStr newmcs;
|
||||
|
||||
if (!ini.Load(File::GetUserPath(F_DEBUGGERCONFIG_IDX)))
|
||||
if (!ini.Load(File::GetUserPath(D_GAMESETTINGS_IDX) + SConfig::GetInstance().m_LocalCoreStartupParameter.GetUniqueID() + ".ini", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ini.GetLines("BreakPoints", &newbps, false))
|
||||
{
|
||||
PowerPC::breakpoints.Clear();
|
||||
PowerPC::breakpoints.AddFromStrings(newbps);
|
||||
}
|
||||
|
||||
if (ini.GetLines("MemoryChecks", &newmcs, false))
|
||||
{
|
||||
PowerPC::memchecks.Clear();
|
||||
PowerPC::memchecks.AddFromStrings(newmcs);
|
||||
}
|
||||
|
||||
|
||||
@@ -39,7 +39,8 @@ public:
|
||||
void OnAddMemoryCheck(wxCommandEvent& WXUNUSED(event));
|
||||
void Event_SaveAll(wxCommandEvent& WXUNUSED(event));
|
||||
void SaveAll();
|
||||
void LoadAll(wxCommandEvent& WXUNUSED(event));
|
||||
void Event_LoadAll(wxCommandEvent& WXUNUSED(event));
|
||||
void LoadAll();
|
||||
|
||||
private:
|
||||
DECLARE_EVENT_TABLE();
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "Core/Debugger/PPCDebugInterface.h"
|
||||
#include "Core/HW/CPU.h"
|
||||
#include "Core/HW/Memmap.h"
|
||||
#include "Core/HW/SystemTimers.h"
|
||||
#include "Core/PowerPC/Gekko.h"
|
||||
#include "Core/PowerPC/JitInterface.h"
|
||||
#include "Core/PowerPC/PowerPC.h"
|
||||
@@ -51,6 +52,7 @@
|
||||
#include "DolphinWX/Debugger/DebuggerUIUtil.h"
|
||||
#include "DolphinWX/Debugger/JitWindow.h"
|
||||
#include "DolphinWX/Debugger/RegisterWindow.h"
|
||||
#include "DolphinWX/Debugger/WatchWindow.h"
|
||||
|
||||
extern "C" // Bitmaps
|
||||
{
|
||||
@@ -92,6 +94,7 @@ CCodeWindow::CCodeWindow(const SCoreStartupParameter& _LocalCoreStartupParameter
|
||||
: wxPanel(parent, id, position, size, style, name)
|
||||
, Parent(parent)
|
||||
, m_RegisterWindow(nullptr)
|
||||
, m_WatchWindow(nullptr)
|
||||
, m_BreakpointWindow(nullptr)
|
||||
, m_MemoryWindow(nullptr)
|
||||
, m_JitWindow(nullptr)
|
||||
@@ -151,6 +154,7 @@ void CCodeWindow::OnHostMessage(wxCommandEvent& event)
|
||||
Update();
|
||||
if (codeview) codeview->Center(PC);
|
||||
if (m_RegisterWindow) m_RegisterWindow->NotifyUpdate();
|
||||
if (m_WatchWindow) m_WatchWindow->NotifyUpdate();
|
||||
break;
|
||||
|
||||
case IDM_UPDATEBREAKPOINTS:
|
||||
@@ -180,6 +184,10 @@ void CCodeWindow::OnCodeStep(wxCommandEvent& event)
|
||||
StepOver();
|
||||
break;
|
||||
|
||||
case IDM_STEPOUT:
|
||||
StepOut();
|
||||
break;
|
||||
|
||||
case IDM_TOGGLE_BREAKPOINT:
|
||||
ToggleBreakpoint();
|
||||
break;
|
||||
@@ -288,6 +296,7 @@ void CCodeWindow::SingleStep()
|
||||
{
|
||||
if (CCPU::IsStepping())
|
||||
{
|
||||
PowerPC::breakpoints.ClearAllTemporary();
|
||||
JitInterface::InvalidateICache(PC, 4, true);
|
||||
CCPU::StepOpcode(&sync_event);
|
||||
wxThread::Sleep(20);
|
||||
@@ -304,6 +313,7 @@ void CCodeWindow::StepOver()
|
||||
UGeckoInstruction inst = Memory::Read_Instruction(PC);
|
||||
if (inst.LK)
|
||||
{
|
||||
PowerPC::breakpoints.ClearAllTemporary();
|
||||
PowerPC::breakpoints.Add(PC + 4, true);
|
||||
CCPU::EnableStepping(false);
|
||||
JumpToAddress(PC);
|
||||
@@ -320,6 +330,52 @@ void CCodeWindow::StepOver()
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::StepOut()
|
||||
{
|
||||
if (CCPU::IsStepping())
|
||||
{
|
||||
PowerPC::breakpoints.ClearAllTemporary();
|
||||
|
||||
// Keep stepping until the next blr or timeout after one second
|
||||
u64 timeout = SystemTimers::GetTicksPerSecond();
|
||||
u64 steps = 0;
|
||||
PowerPC::CoreMode oldMode = PowerPC::GetMode();
|
||||
PowerPC::SetMode(PowerPC::MODE_INTERPRETER);
|
||||
UGeckoInstruction inst = Memory::Read_Instruction(PC);
|
||||
GekkoOPInfo* opinfo = GetOpInfo(inst);
|
||||
while (inst.hex != 0x4e800020 && steps < timeout) // check for blr
|
||||
{
|
||||
if (inst.LK)
|
||||
{
|
||||
// Step over branches
|
||||
u32 next_pc = PC + 4;
|
||||
while (PC != next_pc && steps < timeout)
|
||||
{
|
||||
PowerPC::SingleStep();
|
||||
++steps;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
PowerPC::SingleStep();
|
||||
++steps;
|
||||
}
|
||||
inst = Memory::Read_Instruction(PC);
|
||||
opinfo = GetOpInfo(inst);
|
||||
}
|
||||
|
||||
PowerPC::SingleStep();
|
||||
PowerPC::SetMode(oldMode);
|
||||
|
||||
JumpToAddress(PC);
|
||||
Update();
|
||||
|
||||
UpdateButtonStates();
|
||||
// Update all toolbars in the aui manager
|
||||
Parent->UpdateGUI();
|
||||
}
|
||||
}
|
||||
|
||||
void CCodeWindow::ToggleBreakpoint()
|
||||
{
|
||||
if (CCPU::IsStepping())
|
||||
@@ -443,6 +499,7 @@ void CCodeWindow::CreateMenu(const SCoreStartupParameter& core_startup_parameter
|
||||
|
||||
pDebugMenu->Append(IDM_STEP, _("Step &Into\tF11"));
|
||||
pDebugMenu->Append(IDM_STEPOVER, _("Step &Over\tF10"));
|
||||
pDebugMenu->Append(IDM_STEPOUT, _("Step O&ut\tSHIFT+F11"));
|
||||
pDebugMenu->Append(IDM_TOGGLE_BREAKPOINT, _("Toggle &Breakpoint\tF9"));
|
||||
pDebugMenu->AppendSeparator();
|
||||
|
||||
@@ -607,6 +664,7 @@ void CCodeWindow::InitBitmaps()
|
||||
// load original size 48x48
|
||||
m_Bitmaps[Toolbar_Step] = wxGetBitmapFromMemory(toolbar_add_breakpoint_png);
|
||||
m_Bitmaps[Toolbar_StepOver] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
m_Bitmaps[Toolbar_StepOut] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
m_Bitmaps[Toolbar_Skip] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
m_Bitmaps[Toolbar_GotoPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
m_Bitmaps[Toolbar_SetPC] = wxGetBitmapFromMemory(toolbar_add_memcheck_png);
|
||||
@@ -624,6 +682,7 @@ void CCodeWindow::PopulateToolbar(wxToolBar* toolBar)
|
||||
toolBar->SetToolBitmapSize(wxSize(w, h));
|
||||
WxUtils::AddToolbarButton(toolBar, IDM_STEP, _("Step"), m_Bitmaps[Toolbar_Step], _("Step into the next instruction"));
|
||||
WxUtils::AddToolbarButton(toolBar, IDM_STEPOVER, _("Step Over"), m_Bitmaps[Toolbar_StepOver], _("Step over the next instruction"));
|
||||
WxUtils::AddToolbarButton(toolBar, IDM_STEPOUT, _("Step Out"), m_Bitmaps[Toolbar_StepOut], _("Step out of the current function"));
|
||||
WxUtils::AddToolbarButton(toolBar, IDM_SKIP, _("Skip"), m_Bitmaps[Toolbar_Skip], _("Skips the next instruction completely"));
|
||||
toolBar->AddSeparator();
|
||||
WxUtils::AddToolbarButton(toolBar, IDM_GOTOPC, _("Show PC"), m_Bitmaps[Toolbar_GotoPC], _("Go to the current instruction"));
|
||||
@@ -660,6 +719,7 @@ void CCodeWindow::UpdateButtonStates()
|
||||
if (!Initialized)
|
||||
{
|
||||
ToolBar->EnableTool(IDM_STEPOVER, false);
|
||||
ToolBar->EnableTool(IDM_STEPOUT, false);
|
||||
ToolBar->EnableTool(IDM_SKIP, false);
|
||||
}
|
||||
else
|
||||
@@ -667,11 +727,13 @@ void CCodeWindow::UpdateButtonStates()
|
||||
if (!Stepping)
|
||||
{
|
||||
ToolBar->EnableTool(IDM_STEPOVER, false);
|
||||
ToolBar->EnableTool(IDM_STEPOUT, false);
|
||||
ToolBar->EnableTool(IDM_SKIP, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ToolBar->EnableTool(IDM_STEPOVER, true);
|
||||
ToolBar->EnableTool(IDM_STEPOUT, true);
|
||||
ToolBar->EnableTool(IDM_SKIP, true);
|
||||
}
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user