From dd96f95d774a103ddf8f2cbd19d4d22701c20671 Mon Sep 17 00:00:00 2001 From: CHatingPython Date: Mon, 17 Aug 2026 11:34:37 +0200 Subject: [PATCH] fix(furvm): add JustHit executor flag --- furvm/include/furvm/executor.hpp | 9 ++++++++- furvm/src/executor.cpp | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/furvm/include/furvm/executor.hpp b/furvm/include/furvm/executor.hpp index ab0353b..0699aba 100644 --- a/furvm/include/furvm/executor.hpp +++ b/furvm/include/furvm/executor.hpp @@ -14,6 +14,8 @@ namespace furvm { enum class executor_flags : std::uint32_t { Suspended = (1 << 0), /**< Execution suspended. */ Done = (1 << 1), /**< Execution is finished. */ + + JustHit = (1 << 16), /**< Executor just hit a breakpoint. */ }; static inline executor_flags operator|(executor_flags lhs, executor_flags rhs) { @@ -34,6 +36,8 @@ private: executor(context* context) : m_context(context) {} public: + static constexpr executor_flags STATE_FLAGS = executor_flags::JustHit; + using new_frame_callback = std::function; public: /** @@ -90,7 +94,10 @@ public: void unsuspend() { m_flags = m_flags & ~executor_flags::Suspended; } - void clear_flags() { m_flags = m_frames.empty() ? executor_flags::Done : furvm::executor_flags{ 0 }; } + void clear_flags() { + m_flags = m_flags & STATE_FLAGS; + m_flags = m_frames.empty() ? executor_flags::Done : furvm::executor_flags{ 0 }; + } public: /** * @brief Pushes a new frame. diff --git a/furvm/src/executor.cpp b/furvm/src/executor.cpp index 528f071..025b621 100644 --- a/furvm/src/executor.cpp +++ b/furvm/src/executor.cpp @@ -110,6 +110,7 @@ void executor::push_frame(const mod_h& mod, function function) { } else { m_flags = m_flags | executor_flags::Done; } + m_flags = m_flags & ~executor_flags::JustHit; } struct executor::frame executor::pop_frame() { @@ -129,6 +130,7 @@ struct executor::frame executor::pop_frame() { } else { m_flags = m_flags | executor_flags::Done; } + m_flags = m_flags & ~executor_flags::JustHit; return frame; } @@ -189,12 +191,13 @@ void executor::step() { struct frame& frame = m_frames.top(); - if (frame.mod->has_breakpoint(frame.position)) { - m_flags = m_flags | executor_flags::Suspended; + if ((m_flags & executor_flags::JustHit) != executor_flags::JustHit && frame.mod->has_breakpoint(frame.position)) { + m_flags = m_flags | executor_flags::Suspended | executor_flags::JustHit; const auto& bp = frame.mod->breakpoint_at(frame.position); bp.callback(*this, bp.data); return; } + m_flags = m_flags & ~executor_flags::JustHit; instruction instr{}; frame.position += instr.read(frame.mod->bytecode_view().subview(frame.position));