yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::emu::BreakpointManager Class Reference

Manages CPU and SPC700 breakpoints for debugging. More...

#include <breakpoint_manager.h>

Collaboration diagram for yaze::emu::BreakpointManager:

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
 

Detailed Description

Manages CPU and SPC700 breakpoints for debugging.

Provides comprehensive breakpoint support including:

  • Execute breakpoints (break when PC reaches address)
  • Read breakpoints (break when memory address is read)
  • Write breakpoints (break when memory address is written)
  • Access breakpoints (break on read OR write)
  • Conditional breakpoints (break when expression is true)

Inspired by Mesen2's debugging capabilities.

Definition at line 26 of file breakpoint_manager.h.

Member Enumeration Documentation

◆ Type

Enumerator
EXECUTE 
READ 
WRITE 
ACCESS 
CONDITIONAL 

Definition at line 28 of file breakpoint_manager.h.

◆ CpuType

Enumerator
CPU_65816 
SPC700 

Definition at line 36 of file breakpoint_manager.h.

Constructor & Destructor Documentation

◆ BreakpointManager()

yaze::emu::BreakpointManager::BreakpointManager ( )
default

◆ ~BreakpointManager()

yaze::emu::BreakpointManager::~BreakpointManager ( )
default

Member Function Documentation

◆ AddBreakpoint()

uint32_t yaze::emu::BreakpointManager::AddBreakpoint ( uint32_t address,
Type type,
CpuType cpu,
const std::string & condition = "",
const std::string & description = "" )

◆ RemoveBreakpoint()

void yaze::emu::BreakpointManager::RemoveBreakpoint ( uint32_t id)

Remove a breakpoint by ID.

Definition at line 36 of file breakpoint_manager.cc.

References breakpoints_, and LOG_INFO.

Referenced by yaze::emu::InternalEmulatorAdapter::RemoveBreakpoint(), and yaze::emu::Emulator::RenderModernCpuDebugger().

◆ SetEnabled()

void yaze::emu::BreakpointManager::SetEnabled ( uint32_t id,
bool enabled )

Enable or disable a breakpoint.

Definition at line 44 of file breakpoint_manager.cc.

References breakpoints_, and LOG_INFO.

Referenced by yaze::emu::Emulator::RenderModernCpuDebugger(), and yaze::emu::InternalEmulatorAdapter::ToggleBreakpoint().

◆ ShouldBreakOnExecute()

bool yaze::emu::BreakpointManager::ShouldBreakOnExecute ( uint32_t pc,
CpuType cpu )

Check if execution should break at this address.

Parameters
pcCurrent program counter
cpuWhich CPU is executing
Returns
true if breakpoint hit

Definition at line 53 of file breakpoint_manager.cc.

References breakpoints_, EvaluateCondition(), EXECUTE, last_hit_, and LOG_INFO.

Referenced by yaze::emu::Emulator::Initialize().

Here is the call graph for this function:

◆ ShouldBreakOnMemoryAccess()

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.

Parameters
addressMemory address being accessed
is_writeTrue if write, false if read
valueValue being read/written
pcCurrent program counter (for logging)
Returns
true if breakpoint hit

Definition at line 78 of file breakpoint_manager.cc.

References ACCESS, breakpoints_, EvaluateCondition(), last_hit_, LOG_INFO, READ, and WRITE.

Here is the call graph for this function:

◆ GetAllBreakpoints()

std::vector< BreakpointManager::Breakpoint > yaze::emu::BreakpointManager::GetAllBreakpoints ( ) const

◆ GetBreakpoints()

std::vector< BreakpointManager::Breakpoint > yaze::emu::BreakpointManager::GetBreakpoints ( CpuType cpu) const

Get breakpoints for specific CPU.

Definition at line 137 of file breakpoint_manager.cc.

References breakpoints_.

◆ ClearAll() [1/2]

void yaze::emu::BreakpointManager::ClearAll ( )

Clear all breakpoints.

Definition at line 151 of file breakpoint_manager.cc.

References breakpoints_, last_hit_, and LOG_INFO.

Referenced by yaze::emu::Emulator::ReloadRuntimeRom().

◆ ClearAll() [2/2]

void yaze::emu::BreakpointManager::ClearAll ( CpuType cpu)

Clear all breakpoints for specific CPU.

Definition at line 158 of file breakpoint_manager.cc.

References breakpoints_, CPU_65816, and LOG_INFO.

◆ GetLastHit()

const Breakpoint * yaze::emu::BreakpointManager::GetLastHit ( ) const
inline

Get the last breakpoint that was hit.

Definition at line 123 of file breakpoint_manager.h.

References last_hit_.

◆ ResetHitCounts()

void yaze::emu::BreakpointManager::ResetHitCounts ( )

Reset hit counts for all breakpoints.

Definition at line 173 of file breakpoint_manager.cc.

References breakpoints_, and yaze::emu::BreakpointManager::Breakpoint::hit_count.

◆ EvaluateCondition()

bool yaze::emu::BreakpointManager::EvaluateCondition ( const std::string & condition,
uint32_t pc,
uint32_t address,
uint8_t value )
private
Todo
Implement proper expression evaluation

Definition at line 179 of file breakpoint_manager.cc.

Referenced by ShouldBreakOnExecute(), and ShouldBreakOnMemoryAccess().

Member Data Documentation

◆ breakpoints_

std::unordered_map<uint32_t, Breakpoint> yaze::emu::BreakpointManager::breakpoints_
private

◆ next_id_

uint32_t yaze::emu::BreakpointManager::next_id_ = 1
private

Definition at line 132 of file breakpoint_manager.h.

Referenced by AddBreakpoint().

◆ last_hit_

const Breakpoint* yaze::emu::BreakpointManager::last_hit_ = nullptr
private

The documentation for this class was generated from the following files: