Skip to content

修复 Continue 后误命中已移除断点的问题#348

Closed
sumneko wants to merge 2 commits intoactboy168:masterfrom
sumneko:fix/breakpoint-continue-stale-hit-commentless
Closed

修复 Continue 后误命中已移除断点的问题#348
sumneko wants to merge 2 commits intoactboy168:masterfrom
sumneko:fix/breakpoint-continue-stale-hit-commentless

Conversation

@sumneko
Copy link
Copy Markdown
Collaborator

@sumneko sumneko commented Apr 27, 2026

问题描述

VSCode 更新后出现回归:在断点暂停期间移除该断点,再继续执行时,仍会再次命中这个已删除的断点。

根本原因

调试器从暂停态恢复执行(Continue)时,当前行级 hook 在一个调度周期内仍处于激活状态。如果断点在此时已被移除,该行的旧断点状态会在 Continue 后的第一次触发中被重复感知,导致误命中。

修复方案

CMD.run() 恢复执行时,记录当前停住的位置(source + line)。在后续断点判断(event_breakpoint)中,如果命中的正好是 Continue 前停住的那一行,则跳过本次命中并清空标记。

这是「单次跳过」策略,仅影响 Continue 后第一次遇到原停住行的情况,不会干扰同函数内其他行的断点检测。

影响

  • 修复了 Continue 后误命中已移除断点的问题
  • 同函数内多个断点仍可连续正常命中,无回归

Copilot AI review requested due to automatic review settings April 27, 2026 13:28
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread extension/script/backend/worker.lua Outdated

function CMD.run()
state = 'running'
hookmgr.break_closeline()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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'.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 call hookmgr.break_closeline() before hookmgr.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.

@sumneko sumneko changed the title Fix stale breakpoint hit after continue 修复 Continue 后误命中已移除断点的问题 Apr 27, 2026
@sumneko
Copy link
Copy Markdown
Collaborator Author

sumneko commented Apr 27, 2026

感谢审核机器人的准确指出,该意见完全成立。

原方案直接调用 hookmgr.break_closeline() 会移除当前函数作用域的 LUA_MASKLINE,导致同函数内后续断点在下一次函数调用/返回前无法被命中,引入了新的回归。

已在提交 168569f7 中修正,改为**「单次跳过」策略**:

  • Continue 时仅记录当前停住的位置(source + line)
  • 下一次断点判断中,如果命中的正好是 Continue 前停住的那一行,则跳过本次并立即清空标记
  • 后续同函数内其他行的断点不受任何影响

这样既能避免「删除断点后 Continue 误命中一次」的问题,也不会破坏同函数内多断点连续命中的能力。

@sumneko sumneko closed this Apr 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants