Skip to content

WIP: feat(debugger): WP-3 consult wiring — session stops at entry and breakpoints (1.5.0) - #1878

Merged
caomengxuan666 merged 1 commit into
masterfrom
feat150/session-core
Oct 27, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
feat150/session-core

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

WIP: 1.5.0 WP-3 起步 — session-core 集成核实 + consult 接线(簇 150-wiring)

第一段:集成(核实结论:无需搬运)

150-c 的 session-core 骨架已在 master 上(feat150/slice-session-core 线已合并):src/debugger/ 的 breakpoints.rs/event.rs/gate.rs/session.rs 与 150-c 分支逐字节一致,mod.rs 仅多一处 -D warnings facade allow(master 更靠前),src/lib.rs 的模块声明在位。本簇在当前 master(58e24bf6)实测:骨架 39 测全绿、lib 基线 773/1/1 不回退(唯一失败 = ownership_unary_operators_check_existing_file,与该树基线全等)。

第二段:WP-3 接线(按 DESIGN-FINAL §4/§5/§6 与 150-c REPORT §5 八条注记)

  • 驱动层(新 src/debugger/driver.rs):SessionDriver = DebugSession + 前端 StopLoop;门控配对归驱动层(安装时 activate()、终止/脱离时 deactivate(),注记 7)。
  • 漏斗(run_debug_trap 加 SeamKind 参数,11 个调用点各传其 kind;主接缝的 Conditional/Arithmetic 由节点字段区分,注记 8):SESSION_ACTIVE 门控在 trap 动作查表之前加载(注记 1);入口停点在首次漏斗到达时按既成停点服务(DE-01/G-08,注记 4,不另造武装旗);无动作早退路径同样 consult(G-03);extdebug 否决先于 consult 决定(设计 §4.2 顺序——被否决的单元既不执行也不停车)。
  • 准入放宽:主接缝、函数入口接缝、算术 for 三子句、case 头四处为已接入 session 放宽——session 的作用域是接入本身,不走 trap 的 functrace 继承判据。子 executor(命令替换字面量)恒 debug_driver: None,DE-12 合成帧内不停。
  • consult 断点核算(注记 3):register_hit(先扣 ignore、后评条件)→ 条件用引擎自身在当前帧求值(重入卫士覆盖,设计 §5.3)→ commit_conditional_stop 提交;StepInto/StepOver 谓词在接缝求值,Finish 在返回点求值。
  • DE-04:函数返回点发 FrameReturned(Completed/EntrySkipped/EntryForceReturn 三路),状态为调用方将观察到的状态。
  • DE-07:异步停在边界轮询(run_pending_signal_traps)信号 trap 分发之后服务(注记 5)。
  • DE-09:只挂收尾侧——finish_shell + exit 内建分发点,不挂 EXIT 漏斗(注记 6),先到者胜、幂等。

P-1 定谳(先钉后落 DE-04)

GNU 5.3.20 oracle 脚本文件探针 + C 源码 execute_cmd.c:5383-5407(execute_function):入口 skip 的帧返回 DEBUG trap 的状态且不发 RETURN trap。实测分歧只有状态一半:pristine master 对状态 1/3/127 的 skip 一律返回 0(抑制一半在全部探针形状上已成立)。修复 = 漏斗 Some(status) 贯通到调用结果 + 返回点按 skip 守卫(与 C 形对齐);旧注释「函数调用状态为 EXECUTION_SUCCESS」系误读(那是 execute_cmd.c:4510 简单命令接缝的规则),已更正。6 条 p1_* 行为钉断言 GNU 结果:pristine 上两条 skip 钉在状态断言上失败,本分支 8 探针矩阵与 oracle 逐字节一致。

验收证据

  • 新增 14 测(debugger::wiring_tests:DE-01/02/03/04/07/09 + detach + 条件断点 + 6 条 P-1 钉),全绿;debugger:: 共 53 测绿。
  • lib 全量:787 passed / 1 failed / 1 ignored,失败集与该树基线全等。
  • diffcorpus 306:305 PASS,唯一失败 ps06 经隔离复跑裁定为时序 flake(pristine 二进制同形翻转;ms10 本轮通过)。
  • cargo check --lib 带 -D warnings 干净(niu CI 面);改动文件逐个 rustfmt(存量漂移 hunk 已剔除不带入);CR=0。
  • 未自合;WP-3 剩余项(步进的帧/行谓词精修、DE-05 watch 停后复查、DE-12、G-06 完整签名、WP-7 求值器等)归宿表见簇 REPORT。

Refs #497(调试器定版;本 PR 是其 WP-3 起步,不关闭)

…at breakpoints (1.5.0)

Part 1 (integration): the 150-c session-core skeleton needed no
port — it is already on master (58e24bf), byte-identical to the
150-c branch for breakpoints.rs/event.rs/gate.rs/session.rs, with
mod.rs strictly ahead (the -D warnings facade allows). Verified
on this tree: the 39 skeleton tests pass and the lib baseline is
unchanged (773/1/1, failure = ownership_unary_operators only).

Part 2 (WP-3 wiring, per DESIGN-FINAL sections 4/5/6 and the
150-c REPORT section 5 notes):

- debugger/driver.rs (new): SessionDriver pairs a DebugSession
  with a frontend StopLoop; gate pairing lives with the driver
  (activate at install, deactivate at termination/detach).
- The funnel (executor/trap_exec.rs run_debug_trap) takes a
  SeamKind and consults the session: the SESSION_ACTIVE gate is
  loaded before the trap-action lookup (note 1), the entry stop
  is served at the first funnel arrival as an already-established
  stop (DE-01/G-08, note 4), the no-action early return still
  consults (G-03), and the extdebug veto precedes the consult
  (design 4.2 order). All 11 funnel call sites pass their kind;
  the main seam's Conditional/Arithmetic distinction comes from
  the node's own fields (note 8).
- Admission widened for attached sessions at the main seam, the
  function-entry seam, the arithmetic-for clauses, and the case
  head — a session's scope is the attachment, not the functrace
  inheritance the trap path checks. Child executors never carry
  a driver (DE-12 stays a later package).
- The consult does the breakpoint accounting of note 3:
  register_hit (ignore before condition) -> condition evaluated
  through the engine itself in the current frame under the
  re-entrancy guard (design 5.3) -> commit_conditional_stop;
  stepping predicates for StepInto/StepOver are evaluated at the
  seam; Finish is evaluated at the return site.
- DE-04: frame returns are emitted at the function return site
  for the Completed / EntrySkipped / EntryForceReturn routes,
  with the status the caller will observe.
- DE-07: an asynchronous stop is serviced at the boundary poll
  (run_pending_signal_traps), after signal-trap dispatch
  (note 5).
- DE-09: the session learns the final status from the finish
  side only — finish_shell and the exit builtin's dispatch —
  never from the EXIT funnel (note 6); the first speaker wins.
- Executor gains a debug_driver field (None in both struct
  literals: init and the command-substitution child).

P-1 adjudicated before landing DE-04 (GNU 5.3.20 oracle, script
files; C source execute_cmd.c:5383-5407 execute_function): an
entry-skipped frame returns the DEBUG trap's status and never
fires the RETURN trap. The suppression already held
observationally; the status did not — a skipped call returned 0
for trap statuses 1/3/127. The fix carries the funnel's
Some(status) to the call's result and guards the RETURN-trap
site with the skip, making the site match the C shape; the old
comment claiming EXECUTION_SUCCESS for this seam was corrected
(that rule is execute_cmd.c:4510, the simple-command seam). Six
behavior pins (p1_*) assert the GNU outcomes; on pristine master
the two skip pins fail on the status assertion, on this branch
the full 8-probe matrix matches the oracle byte-for-byte.

Tests: 14 new tests in debugger::wiring_tests (DE-01/02/03/04/
07/09 acceptance + detach + 6 P-1 pins). Lib: 787 passed / 1
failed / 1 ignored — the failure set equals the tree baseline.
diffcorpus 306: 305 pass, sole failure ps06 adjudicated a
timing flake (isolated re-runs flip on the pristine binary too;
ms10 passed). cargo check --lib with -D warnings is clean.
@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 27, 2026 14:48
@caomengxuan666
caomengxuan666 merged commit bb360a9 into master Oct 27, 2026
10 of 11 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
WIP: test(debugger): quote sourced-script path in wiring tests — clears #1878 goldens red (8 wiring tests)
SpookyWaste pushed a commit to SpookyWaste/rubash that referenced this pull request Oct 29, 2026
The 8 debugger::wiring_tests that have failed only in the
Windows goldens job since unixwin#1878 all drive the debuggee through
sourced_script(), which interpolated the temp script's native
path into the driver input unquoted: `. C:\Users\...`. In a
bare word the lexer treats `\` as an escape, every separator
was eaten, `.` never found the file, and each debuggee exited
status 1 having executed nothing (de01's status assertion at
wiring_tests.rs:142 — left 1, right 0).

Quote the path at the helper, the single interpolation point
all nine call sites share — the same harness shape the api
consumer tests were fixed with in unixwin#1883. No product code
changes; the debuggee scripts and their status semantics are
untouched.
@caomengxuan666
caomengxuan666 deleted the feat150/session-core branch October 30, 2026 01:41
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.

1 participant