Repository navigation
WIP: fix(debugger): 函数值 DEBUG trap 下 consult 改读 seam 到达快照 (niubash#681) - #2037
Merged
Merged
Conversation
…p runs Fixes unixwin/niubash#681 The funnel's order is the design's (debugger-full-design.md 4.2/9.1): the user's DEBUG trap runs in full, then the debugger consult decides about the seam. The consult read its (file, line) from the ambient line stamp AFTER the action ran. A function exit deliberately restamps that cell to the function's definition line (function_calls.rs, for the RETURN trap's reads), so a trap action ending in a function call — the bare-name form `trap "omh" DEBUG` that oh-my-niu's preexec dispatch uses — made every later consult adjudicate the seam against the trap function's definition line: line breakpoints silently never matched, or replayed at the stale line wearing the seam's command text (the pkg9 A2 B6 shape). Actions ending in a builtin looked fine only because a simple command's execution refreshes the stamp. GNU establishes the seam's line in the caller before run_debug_trap (execute_cmd.c) and runs the action inside save/restore_parser_state (trap.c _run_trap_internal), so the post-action line state is the seam's by construction. Mirror that guarantee: run_debug_trap snapshots the seam's (location, depth) at funnel arrival — only while the session gate is armed, so the debugger-off path is unchanged — and threads it through debugger_consult into debugger_consult_at_seam. Trap variable effects, the extdebug veto order, the entry stop, and the async/exception sites (which read the stamp when no action intervenes) are untouched. Regression pins: tests/issue681_debug_trap_coexist.rs — the function-valued minimal form (with a trap-firing count, proving the trap still runs in full), the action-tail-call mechanism form, the B6 anti-replay form, and the string-builtin control.
Member
Author
|
CI 首轮(head 7b9dfe0):Rust tests / Rust tests (macOS) / GNU regression goldens / Cross-target (darwin, linux/android) / Shell functionality / API ledger tripwire 全 pass。唯一红 = niubash canary 的 本地门(构建槽排队中): |
Line 3 of the control program is `echo two`, not `echo one` — the pin as first written asserted a pairing no correct engine produces. Caught by direct in-cell runs of the test binary (3 passed / 1 failed, deterministically) after an earlier queued build reported a green that the on-disk binary does not reproduce; the direct runs are the evidence of record.
Member
Author
|
本地门回填(本视图工件背书):
宿主级 PTY 复验(本簇 niu 对修复后 rubash 构建):进行中,结果续报。 |
Member
Author
|
宿主级 PTY 复验完成(修复后 rubash 二进制 = niu
原始 transcript 存工区 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes unixwin/niubash#681
问题
函数值 DEBUG trap(
trap "omh" DEBUG,oh-my-niu 的默认 preexec 接线形状)装载后,--debug的行断点静默丢失;若 trap 函数的定义行恰有断点,停点会错位重放在定义行、横幅挂着当前命令的文本(pkg9 A2 的 B6 形)。根因
漏斗
run_debug_trap的次序按设计(debugger-full-design §4.2/§9.1)是「用户 trap 完整跑完 → debugger consult」,但 consult 在debugger_consult_at_seam里读的是动作执行之后的环境行戳(debugger_location()读__RUBASH_CURRENT_LINE)。函数调用退出时有一处刻意的 GNU 保真回戳(function_calls.rs:函数体跑完把行戳重戳为函数定义行,供 RETURN trap 读),于是动作以函数调用结尾时,consult 拿着 trap 函数的定义行去 adjudicate 当前 seam 的断点——永不命中(静默丢失)或错位命中(B6)。动作以 builtin 结尾时简单命令执行把行戳刷回,表面正常,故字符串/builtin 动作(B2 形)不受影响。GNU 对照(bash 5.3.20 + C 源码):seam 的行在调用方于
run_debug_trap前确立,动作在save_parser_state/restore_parser_state(trap.c_run_trap_internal)内执行,动作后行状态按构造回到 seam。修复
run_debug_trap在漏斗到达时(session arm 时、entry stop 与动作执行之前)快照本 seam 的(location, depth),经debugger_consult透传给debugger_consult_at_seam使用。trap 的变量效应次序、extdebug 否决、entry stop、异步停与异常点路径均不动;debugger-off 路径零新增成本(快照只在 gate arm 时取)。回归钉
tests/issue681_debug_trap_coexist.rs(4 钉):函数值最小形(含 trap 实跑计数,证 §9.1 的「trap 完整跑完」不被 consult 修复吞掉)/ 动作尾调用机制形 / B6 反重放形 / 字符串 builtin 对照。门账
cargo test --lib debugger::子集(回填实数);修复前同靶 3 红 1 绿(回填)。完整报告:
~/workspace/fix-681-debugtrap/REPORT.md(集群工区,含 GNU oracle 逐项与二分矩阵)。