From 9c78f70071daa8d4d65ffe335c21af0e4b523841 Mon Sep 17 00:00:00 2001 From: Oxore Date: Sun, 25 Sep 2022 16:37:03 +0300 Subject: Impl read and write watchpoints --- m68k_debugging.cpp | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'm68k_debugging.cpp') diff --git a/m68k_debugging.cpp b/m68k_debugging.cpp index 509299d..d02e463 100644 --- a/m68k_debugging.cpp +++ b/m68k_debugging.cpp @@ -157,10 +157,28 @@ void M68KDebuggingControl::SetBreakpoint(BreakpointType type, uint32_t address, code_bkpts.push_back(Breakpoint{address, length}); } break; case BreakpointType::kWriteWatchpoint: { + const auto it = std::find_if( + write_bkpts.begin(), + write_bkpts.end(), + [&](const Breakpoint& b) { return b.offset == address && b.length == length; }); + if (it == write_bkpts.end()) + write_bkpts.push_back(Breakpoint{address, length}); } break; case BreakpointType::kReadWatchpoint: { + const auto it = std::find_if( + read_bkpts.begin(), + read_bkpts.end(), + [&](const Breakpoint& b) { return b.offset == address && b.length == length; }); + if (it == read_bkpts.end()) + read_bkpts.push_back(Breakpoint{address, length}); } break; case BreakpointType::kAccessWatchpoint: { + const auto it = std::find_if( + access_bkpts.begin(), + access_bkpts.end(), + [&](const Breakpoint& b) { return b.offset == address && b.length == length; }); + if (it == access_bkpts.end()) + access_bkpts.push_back(Breakpoint{address, length}); } break; break; case BreakpointType::kUnsupported: { @@ -182,10 +200,28 @@ void M68KDebuggingControl::RemoveBreakpoint(BreakpointType type, uint32_t addres code_bkpts.erase(it); } break; case BreakpointType::kWriteWatchpoint: { + const auto it = std::find_if( + write_bkpts.begin(), + write_bkpts.end(), + [&](const Breakpoint& b) { return b.offset == address && b.length == length; }); + if (it != write_bkpts.end()) + write_bkpts.erase(it); } break; case BreakpointType::kReadWatchpoint: { + const auto it = std::find_if( + read_bkpts.begin(), + read_bkpts.end(), + [&](const Breakpoint& b) { return b.offset == address && b.length == length; }); + if (it != read_bkpts.end()) + read_bkpts.erase(it); } break; case BreakpointType::kAccessWatchpoint: { + const auto it = std::find_if( + access_bkpts.begin(), + access_bkpts.end(), + [&](const Breakpoint& b) { return b.offset == address && b.length == length; }); + if (it != access_bkpts.end()) + access_bkpts.erase(it); } break; break; case BreakpointType::kUnsupported: { -- cgit v1.2.3