fix(furvm): add JustHit executor flag

This commit is contained in:
2026-08-17 11:34:37 +02:00
parent 70cbb003f2
commit dd96f95d77
2 changed files with 13 additions and 3 deletions
+8 -1
View File
@@ -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<void(executor&)>;
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.
+5 -2
View File
@@ -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));