Move Memchecks support out of debug only builds
It wouldn't impact performance until at least one memcheck is enabled. Because of this, it can be used in release builds without much impact, the only thing that woudl change is the use of HasAny method instead of preprocessor conditionals. Since the perforamnce decrease comes right when the first memcheck is added and restored when the last is removed, it basically is all beneficial and works the same way.
This commit is contained in:
parent
6e488e65e3
commit
09df343247
|
@ -137,12 +137,12 @@ void PPCDebugInterface::ClearAllMemChecks()
|
||||||
|
|
||||||
bool PPCDebugInterface::IsMemCheck(unsigned int address)
|
bool PPCDebugInterface::IsMemCheck(unsigned int address)
|
||||||
{
|
{
|
||||||
return (Memory::AreMemoryBreakpointsActivated() && PowerPC::memchecks.GetMemCheck(address));
|
return (PowerPC::memchecks.HasAny() && PowerPC::memchecks.GetMemCheck(address));
|
||||||
}
|
}
|
||||||
|
|
||||||
void PPCDebugInterface::ToggleMemCheck(unsigned int address)
|
void PPCDebugInterface::ToggleMemCheck(unsigned int address)
|
||||||
{
|
{
|
||||||
if (Memory::AreMemoryBreakpointsActivated() && !PowerPC::memchecks.GetMemCheck(address))
|
if (PowerPC::memchecks.HasAny() && !PowerPC::memchecks.GetMemCheck(address))
|
||||||
{
|
{
|
||||||
// Add Memory Check
|
// Add Memory Check
|
||||||
TMemCheck MemCheck;
|
TMemCheck MemCheck;
|
||||||
|
|
|
@ -88,9 +88,7 @@ void Run()
|
||||||
// If watchpoints are enabled, any instruction could be a breakpoint.
|
// If watchpoints are enabled, any instruction could be a breakpoint.
|
||||||
if (PowerPC::GetMode() != PowerPC::MODE_INTERPRETER)
|
if (PowerPC::GetMode() != PowerPC::MODE_INTERPRETER)
|
||||||
{
|
{
|
||||||
#ifndef ENABLE_MEM_CHECK
|
if (PowerPC::breakpoints.IsAddressBreakPoint(PC) || PowerPC::memchecks.HasAny())
|
||||||
if (PowerPC::breakpoints.IsAddressBreakPoint(PC))
|
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
PowerPC::CoreMode old_mode = PowerPC::GetMode();
|
PowerPC::CoreMode old_mode = PowerPC::GetMode();
|
||||||
PowerPC::SetMode(PowerPC::MODE_INTERPRETER);
|
PowerPC::SetMode(PowerPC::MODE_INTERPRETER);
|
||||||
|
|
|
@ -316,15 +316,6 @@ void Clear()
|
||||||
memset(m_pEXRAM, 0, EXRAM_SIZE);
|
memset(m_pEXRAM, 0, EXRAM_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AreMemoryBreakpointsActivated()
|
|
||||||
{
|
|
||||||
#ifdef ENABLE_MEM_CHECK
|
|
||||||
return true;
|
|
||||||
#else
|
|
||||||
return false;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline u8* GetPointerForRange(u32 address, size_t size)
|
static inline u8* GetPointerForRange(u32 address, size_t size)
|
||||||
{
|
{
|
||||||
// Make sure we don't have a range spanning 2 separate banks
|
// Make sure we don't have a range spanning 2 separate banks
|
||||||
|
|
|
@ -11,11 +11,6 @@
|
||||||
#include "Common/CommonTypes.h"
|
#include "Common/CommonTypes.h"
|
||||||
#include "Core/PowerPC/PowerPC.h"
|
#include "Core/PowerPC/PowerPC.h"
|
||||||
|
|
||||||
// Enable memory checks in the Debug/DebugFast builds, but NOT in release
|
|
||||||
#if defined(_DEBUG) || defined(DEBUGFAST)
|
|
||||||
#define ENABLE_MEM_CHECK
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Global declarations
|
// Global declarations
|
||||||
class PointerWrap;
|
class PointerWrap;
|
||||||
namespace MMIO
|
namespace MMIO
|
||||||
|
@ -72,7 +67,6 @@ void DoState(PointerWrap& p);
|
||||||
void UpdateLogicalMemory(const PowerPC::BatTable& dbat_table);
|
void UpdateLogicalMemory(const PowerPC::BatTable& dbat_table);
|
||||||
|
|
||||||
void Clear();
|
void Clear();
|
||||||
bool AreMemoryBreakpointsActivated();
|
|
||||||
|
|
||||||
// Routines to access physically addressed memory, designed for use by
|
// Routines to access physically addressed memory, designed for use by
|
||||||
// emulated hardware outside the CPU. Use "Device_" prefix.
|
// emulated hardware outside the CPU. Use "Device_" prefix.
|
||||||
|
|
|
@ -412,31 +412,32 @@ u32 HostRead_Instruction(const u32 address)
|
||||||
|
|
||||||
static __forceinline void Memcheck(u32 address, u32 var, bool write, int size)
|
static __forceinline void Memcheck(u32 address, u32 var, bool write, int size)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MEM_CHECK
|
if (PowerPC::memchecks.HasAny())
|
||||||
TMemCheck* mc = PowerPC::memchecks.GetMemCheck(address);
|
|
||||||
if (mc)
|
|
||||||
{
|
{
|
||||||
if (CPU::IsStepping())
|
TMemCheck* mc = PowerPC::memchecks.GetMemCheck(address);
|
||||||
|
if (mc)
|
||||||
{
|
{
|
||||||
// Disable when stepping so that resume works.
|
if (CPU::IsStepping())
|
||||||
return;
|
{
|
||||||
}
|
// Disable when stepping so that resume works.
|
||||||
mc->numHits++;
|
return;
|
||||||
bool pause = mc->Action(&PowerPC::debug_interface, var, address, write, size, PC);
|
}
|
||||||
if (pause)
|
mc->numHits++;
|
||||||
{
|
bool pause = mc->Action(&PowerPC::debug_interface, var, address, write, size, PC);
|
||||||
CPU::Break();
|
if (pause)
|
||||||
// Fake a DSI so that all the code that tests for it in order to skip
|
{
|
||||||
// the rest of the instruction will apply. (This means that
|
CPU::Break();
|
||||||
// watchpoints will stop the emulator before the offending load/store,
|
// Fake a DSI so that all the code that tests for it in order to skip
|
||||||
// not after like GDB does, but that's better anyway. Just need to
|
// the rest of the instruction will apply. (This means that
|
||||||
// make sure resuming after that works.)
|
// watchpoints will stop the emulator before the offending load/store,
|
||||||
// It doesn't matter if ReadFromHardware triggers its own DSI because
|
// not after like GDB does, but that's better anyway. Just need to
|
||||||
// we'll take it after resuming.
|
// make sure resuming after that works.)
|
||||||
PowerPC::ppcState.Exceptions |= EXCEPTION_DSI | EXCEPTION_FAKE_MEMCHECK_HIT;
|
// It doesn't matter if ReadFromHardware triggers its own DSI because
|
||||||
|
// we'll take it after resuming.
|
||||||
|
PowerPC::ppcState.Exceptions |= EXCEPTION_DSI | EXCEPTION_FAKE_MEMCHECK_HIT;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 Read_U8(const u32 address)
|
u8 Read_U8(const u32 address)
|
||||||
|
@ -604,9 +605,8 @@ std::string HostGetString(u32 address, size_t size)
|
||||||
|
|
||||||
bool IsOptimizableRAMAddress(const u32 address)
|
bool IsOptimizableRAMAddress(const u32 address)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MEM_CHECK
|
if (PowerPC::memchecks.HasAny())
|
||||||
return false;
|
return false;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!UReg_MSR(MSR).DR)
|
if (!UReg_MSR(MSR).DR)
|
||||||
return false;
|
return false;
|
||||||
|
@ -745,9 +745,8 @@ void ClearCacheLine(u32 address)
|
||||||
|
|
||||||
u32 IsOptimizableMMIOAccess(u32 address, u32 accessSize)
|
u32 IsOptimizableMMIOAccess(u32 address, u32 accessSize)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MEM_CHECK
|
if (PowerPC::memchecks.HasAny())
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!UReg_MSR(MSR).DR)
|
if (!UReg_MSR(MSR).DR)
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -768,9 +767,8 @@ u32 IsOptimizableMMIOAccess(u32 address, u32 accessSize)
|
||||||
|
|
||||||
bool IsOptimizableGatherPipeWrite(u32 address)
|
bool IsOptimizableGatherPipeWrite(u32 address)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MEM_CHECK
|
if (PowerPC::memchecks.HasAny())
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
if (!UReg_MSR(MSR).DR)
|
if (!UReg_MSR(MSR).DR)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -402,12 +402,10 @@ void CheckExceptions()
|
||||||
INFO_LOG(POWERPC, "EXCEPTION_FPU_UNAVAILABLE");
|
INFO_LOG(POWERPC, "EXCEPTION_FPU_UNAVAILABLE");
|
||||||
ppcState.Exceptions &= ~EXCEPTION_FPU_UNAVAILABLE;
|
ppcState.Exceptions &= ~EXCEPTION_FPU_UNAVAILABLE;
|
||||||
}
|
}
|
||||||
#ifdef ENABLE_MEM_CHECK
|
|
||||||
else if (exceptions & EXCEPTION_FAKE_MEMCHECK_HIT)
|
else if (exceptions & EXCEPTION_FAKE_MEMCHECK_HIT)
|
||||||
{
|
{
|
||||||
ppcState.Exceptions &= ~EXCEPTION_DSI & ~EXCEPTION_FAKE_MEMCHECK_HIT;
|
ppcState.Exceptions &= ~EXCEPTION_DSI & ~EXCEPTION_FAKE_MEMCHECK_HIT;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
else if (exceptions & EXCEPTION_DSI)
|
else if (exceptions & EXCEPTION_DSI)
|
||||||
{
|
{
|
||||||
SRR0 = PC;
|
SRR0 = PC;
|
||||||
|
|
|
@ -47,12 +47,8 @@ public:
|
||||||
AddTool(ID_ADDBP, "+BP", m_Bitmaps[Toolbar_Add_BP]);
|
AddTool(ID_ADDBP, "+BP", m_Bitmaps[Toolbar_Add_BP]);
|
||||||
Bind(wxEVT_TOOL, &CBreakPointWindow::OnAddBreakPoint, parent, ID_ADDBP);
|
Bind(wxEVT_TOOL, &CBreakPointWindow::OnAddBreakPoint, parent, ID_ADDBP);
|
||||||
|
|
||||||
// Add memory breakpoints if you can use them
|
AddTool(ID_ADDMC, "+MC", m_Bitmaps[Toolbar_Add_MC]);
|
||||||
if (Memory::AreMemoryBreakpointsActivated())
|
Bind(wxEVT_TOOL, &CBreakPointWindow::OnAddMemoryCheck, parent, ID_ADDMC);
|
||||||
{
|
|
||||||
AddTool(ID_ADDMC, "+MC", m_Bitmaps[Toolbar_Add_MC]);
|
|
||||||
Bind(wxEVT_TOOL, &CBreakPointWindow::OnAddMemoryCheck, parent, ID_ADDMC);
|
|
||||||
}
|
|
||||||
|
|
||||||
AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_Delete]);
|
AddTool(ID_LOAD, _("Load"), m_Bitmaps[Toolbar_Delete]);
|
||||||
Bind(wxEVT_TOOL, &CBreakPointWindow::Event_LoadAll, parent, ID_LOAD);
|
Bind(wxEVT_TOOL, &CBreakPointWindow::Event_LoadAll, parent, ID_LOAD);
|
||||||
|
|
|
@ -261,9 +261,7 @@ void CWatchView::OnMouseDownR(wxGridEvent& event)
|
||||||
|
|
||||||
if (row != 0 && row != (int)(PowerPC::watches.GetWatches().size() + 1) && (col == 1 || col == 2))
|
if (row != 0 && row != (int)(PowerPC::watches.GetWatches().size() + 1) && (col == 1 || col == 2))
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_MEM_CHECK
|
|
||||||
menu.Append(IDM_ADDMEMCHECK, _("Add memory &breakpoint"));
|
menu.Append(IDM_ADDMEMCHECK, _("Add memory &breakpoint"));
|
||||||
#endif
|
|
||||||
menu.Append(IDM_VIEWMEMORY, _("View &memory"));
|
menu.Append(IDM_VIEWMEMORY, _("View &memory"));
|
||||||
}
|
}
|
||||||
PopupMenu(&menu);
|
PopupMenu(&menu);
|
||||||
|
|
Loading…
Reference in New Issue