Manages CPU and SPC700 breakpoints for debugging. More...
#include <breakpoint_manager.h>
Classes | |
struct | Breakpoint |
Public Types | |
enum class | Type { EXECUTE , READ , WRITE , ACCESS , CONDITIONAL } |
enum class | CpuType { CPU_65816 , SPC700 } |
Public Member Functions | |
BreakpointManager ()=default | |
~BreakpointManager ()=default | |
uint32_t | AddBreakpoint (uint32_t address, Type type, CpuType cpu, const std::string &condition="", const std::string &description="") |
Add a new breakpoint. | |
void | RemoveBreakpoint (uint32_t id) |
Remove a breakpoint by ID. | |
void | SetEnabled (uint32_t id, bool enabled) |
Enable or disable a breakpoint. | |
bool | ShouldBreakOnExecute (uint32_t pc, CpuType cpu) |
Check if execution should break at this address. | |
bool | ShouldBreakOnMemoryAccess (uint32_t address, bool is_write, uint8_t value, uint32_t pc) |
Check if execution should break on memory access. | |
std::vector< Breakpoint > | GetAllBreakpoints () const |
Get all breakpoints. | |
std::vector< Breakpoint > | GetBreakpoints (CpuType cpu) const |
Get breakpoints for specific CPU. | |
void | ClearAll () |
Clear all breakpoints. | |
void | ClearAll (CpuType cpu) |
Clear all breakpoints for specific CPU. | |
const Breakpoint * | GetLastHit () const |
Get the last breakpoint that was hit. | |
void | ResetHitCounts () |
Reset hit counts for all breakpoints. | |
Private Member Functions | |
bool | EvaluateCondition (const std::string &condition, uint32_t pc, uint32_t address, uint8_t value) |
Private Attributes | |
std::unordered_map< uint32_t, Breakpoint > | breakpoints_ |
uint32_t | next_id_ = 1 |
const Breakpoint * | last_hit_ = nullptr |
Manages CPU and SPC700 breakpoints for debugging.
Provides comprehensive breakpoint support including:
Inspired by Mesen2's debugging capabilities.
Definition at line 26 of file breakpoint_manager.h.
|
strong |
Enumerator | |
---|---|
EXECUTE | |
READ | |
WRITE | |
ACCESS | |
CONDITIONAL |
Definition at line 28 of file breakpoint_manager.h.
|
strong |
Enumerator | |
---|---|
CPU_65816 | |
SPC700 |
Definition at line 36 of file breakpoint_manager.h.
|
default |
|
default |
uint32_t yaze::emu::BreakpointManager::AddBreakpoint | ( | uint32_t | address, |
Type | type, | ||
CpuType | cpu, | ||
const std::string & | condition = "" , |
||
const std::string & | description = "" |
||
) |
Add a new breakpoint.
address | Memory address or PC value |
type | Breakpoint type |
cpu | Which CPU to break on |
condition | Optional condition string |
description | Optional user-friendly description |
Definition at line 9 of file breakpoint_manager.cc.
References yaze::emu::BreakpointManager::Breakpoint::address, breakpoints_, yaze::emu::BreakpointManager::Breakpoint::condition, yaze::emu::BreakpointManager::Breakpoint::cpu, CPU_65816, yaze::emu::BreakpointManager::Breakpoint::description, yaze::emu::BreakpointManager::Breakpoint::enabled, yaze::emu::BreakpointManager::Breakpoint::hit_count, yaze::emu::BreakpointManager::Breakpoint::id, LOG_INFO, next_id_, and yaze::emu::BreakpointManager::Breakpoint::type.
Referenced by yaze::emu::Emulator::RenderModernCpuDebugger(), and yaze::test::EmulatorTestSuite::RunBreakpointManagerTest().
void yaze::emu::BreakpointManager::RemoveBreakpoint | ( | uint32_t | id | ) |
Remove a breakpoint by ID.
Definition at line 33 of file breakpoint_manager.cc.
References breakpoints_, and LOG_INFO.
Referenced by yaze::emu::Emulator::RenderModernCpuDebugger(), and yaze::test::EmulatorTestSuite::RunBreakpointManagerTest().
void yaze::emu::BreakpointManager::SetEnabled | ( | uint32_t | id, |
bool | enabled | ||
) |
Enable or disable a breakpoint.
Definition at line 41 of file breakpoint_manager.cc.
References breakpoints_, and LOG_INFO.
Referenced by yaze::emu::Emulator::RenderModernCpuDebugger().
bool yaze::emu::BreakpointManager::ShouldBreakOnExecute | ( | uint32_t | pc, |
CpuType | cpu | ||
) |
Check if execution should break at this address.
pc | Current program counter |
cpu | Which CPU is executing |
Definition at line 49 of file breakpoint_manager.cc.
References breakpoints_, EvaluateCondition(), EXECUTE, last_hit_, and LOG_INFO.
Referenced by yaze::emu::Emulator::Initialize(), and yaze::test::EmulatorTestSuite::RunBreakpointManagerTest().
bool yaze::emu::BreakpointManager::ShouldBreakOnMemoryAccess | ( | uint32_t | address, |
bool | is_write, | ||
uint8_t | value, | ||
uint32_t | pc | ||
) |
Check if execution should break on memory access.
address | Memory address being accessed |
is_write | True if write, false if read |
value | Value being read/written |
pc | Current program counter (for logging) |
Definition at line 74 of file breakpoint_manager.cc.
References ACCESS, breakpoints_, EvaluateCondition(), last_hit_, LOG_INFO, READ, and WRITE.
std::vector< BreakpointManager::Breakpoint > yaze::emu::BreakpointManager::GetAllBreakpoints | ( | ) | const |
Get all breakpoints.
Definition at line 116 of file breakpoint_manager.cc.
References breakpoints_.
Referenced by yaze::emu::Emulator::RenderModernCpuDebugger(), and yaze::test::EmulatorTestSuite::RunBreakpointManagerTest().
std::vector< BreakpointManager::Breakpoint > yaze::emu::BreakpointManager::GetBreakpoints | ( | CpuType | cpu | ) | const |
Get breakpoints for specific CPU.
Definition at line 128 of file breakpoint_manager.cc.
References breakpoints_.
void yaze::emu::BreakpointManager::ClearAll | ( | ) |
Clear all breakpoints.
Definition at line 140 of file breakpoint_manager.cc.
References breakpoints_, last_hit_, and LOG_INFO.
void yaze::emu::BreakpointManager::ClearAll | ( | CpuType | cpu | ) |
Clear all breakpoints for specific CPU.
Definition at line 146 of file breakpoint_manager.cc.
References breakpoints_, CPU_65816, and LOG_INFO.
|
inline |
Get the last breakpoint that was hit.
Definition at line 123 of file breakpoint_manager.h.
References last_hit_.
void yaze::emu::BreakpointManager::ResetHitCounts | ( | ) |
Reset hit counts for all breakpoints.
Definition at line 161 of file breakpoint_manager.cc.
References breakpoints_, and yaze::emu::BreakpointManager::Breakpoint::hit_count.
|
private |
Definition at line 167 of file breakpoint_manager.cc.
Referenced by ShouldBreakOnExecute(), and ShouldBreakOnMemoryAccess().
|
private |
Definition at line 131 of file breakpoint_manager.h.
Referenced by AddBreakpoint(), ClearAll(), ClearAll(), GetAllBreakpoints(), GetBreakpoints(), RemoveBreakpoint(), ResetHitCounts(), SetEnabled(), ShouldBreakOnExecute(), and ShouldBreakOnMemoryAccess().
|
private |
Definition at line 132 of file breakpoint_manager.h.
Referenced by AddBreakpoint().
|
private |
Definition at line 133 of file breakpoint_manager.h.
Referenced by ClearAll(), GetLastHit(), ShouldBreakOnExecute(), and ShouldBreakOnMemoryAccess().