修复 Continue 后误命中已移除断点的问题#348
Conversation
There was a problem hiding this comment.
Code Review
This pull request modifies the CMD.run function in extension/script/backend/worker.lua to include a call to hookmgr.break_closeline(). A critical issue was identified where this change disables line-level hooks for the current function scope, causing a regression that prevents sequential breakpoints from being hit within the same function until a transition occurs.
|
|
||
| function CMD.run() | ||
| state = 'running' | ||
| hookmgr.break_closeline() |
There was a problem hiding this comment.
Calling hookmgr.break_closeline() here disables line-level hooks for the current function scope by removing LUA_MASKLINE from the break_mask. Since the hook mask is only re-evaluated (via break_update in the C++ backend) when entering or returning from a function, any subsequent breakpoints within the same function will be ignored until the next function transition occurs. This introduces a regression where multiple breakpoints in a single function cannot be hit sequentially after resuming execution with 'Continue'.
There was a problem hiding this comment.
Pull request overview
Fixes a debugger regression where continuing from a paused state could immediately re-hit a breakpoint that was removed while paused, by explicitly closing the current line breakpoint hook before canceling step state.
Changes:
- Update
CMD.run()to callhookmgr.break_closeline()beforehookmgr.step_cancel()to prevent a stale line-level breakpoint hook from firing after continue.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
感谢审核机器人的准确指出,该意见完全成立。 原方案直接调用 已在提交
这样既能避免「删除断点后 Continue 误命中一次」的问题,也不会破坏同函数内多断点连续命中的能力。 |
问题描述
VSCode 更新后出现回归:在断点暂停期间移除该断点,再继续执行时,仍会再次命中这个已删除的断点。
根本原因
调试器从暂停态恢复执行(Continue)时,当前行级 hook 在一个调度周期内仍处于激活状态。如果断点在此时已被移除,该行的旧断点状态会在 Continue 后的第一次触发中被重复感知,导致误命中。
修复方案
在
CMD.run()恢复执行时,记录当前停住的位置(source + line)。在后续断点判断(event_breakpoint)中,如果命中的正好是 Continue 前停住的那一行,则跳过本次命中并清空标记。这是「单次跳过」策略,仅影响 Continue 后第一次遇到原停住行的情况,不会干扰同函数内其他行的断点检测。
影响