CPU: Make trace-to-file toggleable at runtime and in release builds

This commit is contained in:
Connor McLaughlin
2021-01-04 01:55:15 +10:00
parent 4b7820d1e5
commit bf1d51b5d8
3 changed files with 88 additions and 21 deletions

View File

@ -39,7 +39,7 @@ union CacheControl
BitField<u32, bool, 2, 1> tag_test_mode;
BitField<u32, bool, 3, 1> dcache_scratchpad;
BitField<u32, bool, 7, 1> dcache_enable;
BitField<u32, u8, 8, 2> icache_fill_size; // actually dcache? icache always fills to 16 bytes
BitField<u32, u8, 8, 2> icache_fill_size; // actually dcache? icache always fills to 16 bytes
BitField<u32, bool, 11, 1> icache_enable;
};
@ -70,7 +70,7 @@ struct State
Reg next_load_delay_reg = Reg::count;
u32 next_load_delay_value = 0;
CacheControl cache_control{ 0 };
CacheControl cache_control{0};
// GTE registers are stored here so we can access them on ARM with a single instruction
GTE::Regs gte_regs = {};
@ -103,15 +103,33 @@ void SingleStep();
// Forces an early exit from the CPU dispatcher.
void ForceDispatcherExit();
ALWAYS_INLINE Registers& GetRegs() { return g_state.regs; }
ALWAYS_INLINE Registers& GetRegs()
{
return g_state.regs;
}
ALWAYS_INLINE TickCount GetPendingTicks() { return g_state.pending_ticks; }
ALWAYS_INLINE void ResetPendingTicks() { g_state.pending_ticks = 0; }
ALWAYS_INLINE void AddPendingTicks(TickCount ticks) { g_state.pending_ticks += ticks; }
ALWAYS_INLINE TickCount GetPendingTicks()
{
return g_state.pending_ticks;
}
ALWAYS_INLINE void ResetPendingTicks()
{
g_state.pending_ticks = 0;
}
ALWAYS_INLINE void AddPendingTicks(TickCount ticks)
{
g_state.pending_ticks += ticks;
}
// state helpers
ALWAYS_INLINE bool InUserMode() { return g_state.cop0_regs.sr.KUc; }
ALWAYS_INLINE bool InKernelMode() { return !g_state.cop0_regs.sr.KUc; }
ALWAYS_INLINE bool InUserMode()
{
return g_state.cop0_regs.sr.KUc;
}
ALWAYS_INLINE bool InKernelMode()
{
return !g_state.cop0_regs.sr.KUc;
}
// Memory reads variants which do not raise exceptions.
bool SafeReadMemoryByte(VirtualMemoryAddress addr, u8* value);
@ -132,6 +150,11 @@ void DisassembleAndPrint(u32 addr, u32 instructions_before, u32 instructions_aft
// Write to CPU execution log file.
void WriteToExecutionLog(const char* format, ...);
// Trace Routines
bool IsTraceEnabled();
void StartTrace();
void StopTrace();
// Breakpoint callback - if the callback returns false, the breakpoint will be removed.
using BreakpointCallback = bool (*)(VirtualMemoryAddress address);