Manages memory watchpoints for debugging. More...
#include <watchpoint_manager.h>
Classes | |
| struct | AccessLog |
| struct | Watchpoint |
Public Member Functions | |
| WatchpointManager ()=default | |
| ~WatchpointManager ()=default | |
| uint32_t | AddWatchpoint (uint32_t start_address, uint32_t end_address, bool track_reads, bool track_writes, bool break_on_access=false, const std::string &description="") |
| Add a memory watchpoint. | |
| void | RemoveWatchpoint (uint32_t id) |
| Remove a watchpoint. | |
| void | SetEnabled (uint32_t id, bool enabled) |
| Enable or disable a watchpoint. | |
| bool | OnMemoryAccess (uint32_t pc, uint32_t address, bool is_write, uint8_t old_value, uint8_t new_value, uint64_t cycle_count) |
| Check if memory access should break/log. | |
| std::vector< Watchpoint > | GetAllWatchpoints () const |
| Get all watchpoints. | |
| std::vector< AccessLog > | GetHistory (uint32_t address, int max_entries=100) const |
| Get access history for a specific address. | |
| void | ClearAll () |
| Clear all watchpoints. | |
| void | ClearHistory () |
| Clear history for all watchpoints. | |
| bool | ExportHistoryToCSV (const std::string &filepath) const |
| Export access history to CSV. | |
Private Member Functions | |
| bool | IsInRange (const Watchpoint &wp, uint32_t address) const |
Private Attributes | |
| std::unordered_map< uint32_t, Watchpoint > | watchpoints_ |
| uint32_t | next_id_ = 1 |
Manages memory watchpoints for debugging.
Watchpoints track memory accesses (reads/writes) and can break execution when specific memory locations are accessed. This is crucial for:
Inspired by Mesen2's memory debugging capabilities.
Definition at line 26 of file watchpoint_manager.h.
|
default |
|
default |
| uint32_t yaze::emu::WatchpointManager::AddWatchpoint | ( | uint32_t | start_address, |
| uint32_t | end_address, | ||
| bool | track_reads, | ||
| bool | track_writes, | ||
| bool | break_on_access = false, |
||
| const std::string & | description = "" |
||
| ) |
Add a memory watchpoint.
| start_address | Starting address of range to watch |
| end_address | Ending address (inclusive), or same as start for single byte |
| track_reads | Track read accesses |
| track_writes | Track write accesses |
| break_on_access | Pause emulation when accessed |
| description | User-friendly description |
Definition at line 11 of file watchpoint_manager.cc.
References yaze::emu::WatchpointManager::Watchpoint::break_on_access, yaze::emu::WatchpointManager::Watchpoint::description, yaze::emu::WatchpointManager::Watchpoint::enabled, yaze::emu::WatchpointManager::Watchpoint::end_address, yaze::emu::WatchpointManager::Watchpoint::id, LOG_INFO, next_id_, yaze::emu::WatchpointManager::Watchpoint::start_address, yaze::emu::WatchpointManager::Watchpoint::track_reads, yaze::emu::WatchpointManager::Watchpoint::track_writes, and watchpoints_.
Referenced by yaze::test::EmulatorTestSuite::RunWatchpointManagerTest().
| void yaze::emu::WatchpointManager::RemoveWatchpoint | ( | uint32_t | id | ) |
Remove a watchpoint.
Definition at line 35 of file watchpoint_manager.cc.
References LOG_INFO, and watchpoints_.
| void yaze::emu::WatchpointManager::SetEnabled | ( | uint32_t | id, |
| bool | enabled | ||
| ) |
Enable or disable a watchpoint.
Definition at line 43 of file watchpoint_manager.cc.
References LOG_INFO, and watchpoints_.
| bool yaze::emu::WatchpointManager::OnMemoryAccess | ( | uint32_t | pc, |
| uint32_t | address, | ||
| bool | is_write, | ||
| uint8_t | old_value, | ||
| uint8_t | new_value, | ||
| uint64_t | cycle_count | ||
| ) |
Check if memory access should break/log.
| pc | Current program counter |
| address | Memory address being accessed |
| is_write | True for write, false for read |
| old_value | Previous value at address |
| new_value | New value (for writes) or value read |
| cycle_count | Current CPU cycle |
Definition at line 51 of file watchpoint_manager.cc.
References yaze::emu::WatchpointManager::AccessLog::address, yaze::emu::WatchpointManager::AccessLog::cycle_count, yaze::emu::WatchpointManager::AccessLog::description, yaze::emu::WatchpointManager::AccessLog::is_write, IsInRange(), yaze::emu::WatchpointManager::Watchpoint::kMaxHistorySize, LOG_INFO, yaze::emu::WatchpointManager::AccessLog::new_value, yaze::emu::WatchpointManager::AccessLog::old_value, yaze::emu::WatchpointManager::AccessLog::pc, and watchpoints_.
Referenced by yaze::test::EmulatorTestSuite::RunWatchpointManagerTest().

| std::vector< WatchpointManager::Watchpoint > yaze::emu::WatchpointManager::GetAllWatchpoints | ( | ) | const |
| std::vector< WatchpointManager::AccessLog > yaze::emu::WatchpointManager::GetHistory | ( | uint32_t | address, |
| int | max_entries = 100 |
||
| ) | const |
Get access history for a specific address.
| address | Address to query |
| max_entries | Maximum number of entries to return |
Definition at line 107 of file watchpoint_manager.cc.
References IsInRange(), and watchpoints_.
Referenced by yaze::test::EmulatorTestSuite::RunWatchpointManagerTest().

| void yaze::emu::WatchpointManager::ClearAll | ( | ) |
Clear all watchpoints.
Definition at line 127 of file watchpoint_manager.cc.
References LOG_INFO, and watchpoints_.
| void yaze::emu::WatchpointManager::ClearHistory | ( | ) |
Clear history for all watchpoints.
Definition at line 132 of file watchpoint_manager.cc.
References LOG_INFO, and watchpoints_.
| bool yaze::emu::WatchpointManager::ExportHistoryToCSV | ( | const std::string & | filepath | ) | const |
Export access history to CSV.
| filepath | Output file path |
Definition at line 139 of file watchpoint_manager.cc.
References LOG_INFO, and watchpoints_.
|
inlineprivate |
Definition at line 129 of file watchpoint_manager.h.
References yaze::emu::WatchpointManager::Watchpoint::end_address, and yaze::emu::WatchpointManager::Watchpoint::start_address.
Referenced by GetHistory(), and OnMemoryAccess().
|
private |
Definition at line 125 of file watchpoint_manager.h.
Referenced by AddWatchpoint(), ClearAll(), ClearHistory(), ExportHistoryToCSV(), GetAllWatchpoints(), GetHistory(), OnMemoryAccess(), RemoveWatchpoint(), and SetEnabled().
|
private |
Definition at line 126 of file watchpoint_manager.h.
Referenced by AddWatchpoint().