Skip to content

feat(debuggers): name why a stopped GDB or Rizin session accepts no commands - #11185

Merged
morluto merged 5 commits into
mainfrom
feat/gdb-session-stop-reasons
Nov 15, 2026
Merged

morluto merged 5 commits into
mainfrom
feat/gdb-session-stop-reasons

Conversation

@morluto

@morluto morluto commented Nov 15, 2026 •

Copy link
Copy Markdown
Owner

Summary

Refs #10508 (Phase 6.1). A stopped GDB or Rizin debug session now states why it stopped as a code, beside the unchanged reason text, so agents and tests do not match the prose.

Problem and expected behavior

  • Why a session stopped (shutdown, close in progress, stdin failure, output correlation failure, command deadline or cancellation, process exit) existed only as closed_reason / details.reason prose. 13 GDB tests matched that prose.
  • Expected: the session owner records a code where it stops the session, and every projection (stopped-session error, in-flight protocol failure, startup protocol failure, status) reports it.

Change and scope

  • DebuggerSessionStop = {code, reason}; 8 codes: input-stream-failure, output-correlation-failure, command-deadline, command-cancelled, server-shutdown, close-requested, process-exited, stopped.
  • GDB and Rizin protocolError (and Rizin's retained stopReason) hold the stop instead of a string; #failProtocol takes the code. Both managers are changed together because they share stoppedDebuggerSessionError.
  • Docs: docs/reverse-engineering-tools.md names the fields and codes.
  • Not included: converting the Rizin test suite; the close-refusal "inferior disposition" text (owned by ownedDebuggerSession.ts cleanup, not a session stop).

Follow the contribution scope.
Unresolved scope, authority, side effects, or required verification block
integration. Link the required maintainer scope decision for new providers or
capabilities involving target execution, injection, mutation, or protection
recovery; ordinary fixes within existing boundaries may state "not applicable".
Draft PRs may leave the scope decision pending and the readiness and merge checklists
unchecked. Maintainers can help resolve open questions.

Contract and boundary impact

  • Semantic owner and earliest changed stage: DebuggerSessionStop / DEBUGGER_SESSION_STOP_CODES (src/domain/debuggerSessionErrors.ts) owns the reason; each manager's protocolError and #stopReason now produce it at the site that stops the session (#failProtocol(session, code, message), deadline and cancellation paths), and stoppedDebuggerSessionError projects the code
  • Contribution scope fit and linked maintainer decision: Phase 6.1 ([Design] Assert structured remediation facts instead of guidance prose #10508); additive field shape chosen by the coordinator
  • CLI and MCP/tool-catalog contract: additive: gdb_session_status and rizin_debug_session_status gain optional closed_reason_code; stopped-session and protocol-failure errors gain details.diagnostics.session_stop. Reason text unchanged
  • Provider, bridge, target-format, or platform compatibility: none
  • Evidence, artifact, provenance, or reconstruction contract: none
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): none; no lifecycle or cleanup ordering changed, only the stored reason's type
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact (CI generates and validates ignored catalogs and skills/; edit authored instructions in .agents/skills/reverse-engineer-anything/ and never commit build outputs): two status output schemas gain an optional field; scripts/verify/advertised-schemas/summary.json digests updated

Expected effects (check known effects; use documentation-only on its own).
Unchecked items do not establish absence; leave uncertainties visible.

  • Read existing files or captured data.
  • Launch or attach to a process.
  • Inject instrumentation or run scripts/code.
  • Change process memory, registers, files, or configuration.
  • Contact network services.
  • Recover protected code or work around protections.
  • Documentation or usability only; no target interaction.
  • Not sure yet; investigation or maintainer guidance needed.

Evidence and regression coverage

  • Tests added or updated: GdbSessionManagerCoverage.test.ts: 13 prose matches on stop reasons ("REA is shutting down", "close_gdb_session started releasing", stdin stream/write failure, "input stream is closed", "timed out", "MI line exceeding ...", closed_reason text) now assert diagnostics.session_stop or closed_reason_code; injected fake-failure texts stay asserted as carried provenance
  • Base reproduction or other evidence: with the source reverted to base, 14 tests in GdbSessionManagerCoverage fail (13 converted + 1 that also fails on base, below)
  • User-visible CLI/MCP output (if applicable): a command queued behind close now fails with details.reason: "close_gdb_session started releasing this session, ..." and details.diagnostics: {"session_stop": "close-requested"}; status reports closed_reason_code: "close-requested"
  • Remaining proof gaps: no real GDB or Rizin run (fake spawner and fixture processes only). Rizin tests are not converted in this PR; they still pass unchanged

For boundary fixes, identify the applicable boundary regressions
and lifecycle regressions
covered by the evidence above, and explain relevant gaps.

For evidence-bearing changes:

  • Observed, derived, and inferred claims remain distinguishable.
  • Artifact identity, source provenance, and failed attempts remain preserved.
  • Unsupported, incomplete, unavailable, or uncertain outcomes remain visible.

Validation performed

  • npm run test:focused -- tests/boundary/providers/GdbSessionManagerCoverage.test.ts tests/boundary/providers/GdbSessionManagers.test.ts: 219 passed, 1 failed (base: same 219 / 1). Warm wall / CPU (user+sys): before 6.8 / 3.8 s, after 6.6 / 3.5 s.

  • The failing case, "handles a start signal that becomes aborted during listener registration", also fails with base source on this macOS host, so it is not caused by this change.

  • Same GDB coverage file with the source reverted to base: 14 failed, 192 passed.

  • npm run test:focused -- all 20 GDB/Rizin test files under tests/ (including MCP): 410 passed, 10 skipped, 3 failed. The 3 failures (the GDB case above and two RizinDebugSessionCoverage.part1 start/cancellation cases) also fail with base source on this host.

  • npm run test:focused -- tests/boundary/mcp/advertisedDialect.test.ts tests/boundary/mcp/outputSchemaProfile.test.ts tests/boundary/mcp/mcpSchemaValidation.test.ts tests/boundary/mcp/generatedToolCatalog.test.ts: 55 passed.

  • npm run verify:advertised-schemas -- --update-summary after rebasing on main: gdb_session_status and rizin_debug_session_status output digests changed (committed); npm run verify:advertised-schemas then passed (Rust engines not installed locally).

  • Review follow-up (5282348): both start paths keep the stop code; new case "keeps the stop code on a startup stream failure whose cleanup is incomplete". npm run test:focused -- tests/boundary/providers/GdbSessionManagerCoverage.test.ts: 206 passed, 1 failed (the base-failing case above).

  • npm run check:fast, npm run docs:check: passed.

  • Rebased on main after refactor(verify): keep each counted guard's baseline in its own file #11316 and the per-tool advertised summaries. npm run verify:advertised-schemas -- --update-summary changed scripts/verify/advertised-schemas/tools/gdb_session_status.json and rizin_debug_session_status.json (committed in 34ad457). Rust engines are not installed locally.

  • Review follow-up (c7b36d8): a timed-out gdb_console command whose cleanup is incomplete, and Rizin's retained cleanup failure after a timed-out or exited command, now carry diagnostics.session_stop. npm run test:focused -- tests/boundary/providers/GdbSessionManagerCoverage.test.ts tests/boundary/providers/RizinDebugSessionCoverage.part4.test.ts passed 226 tests. With the source change reverted, the 2 strengthened cases fail.

  • npm run check:fast passed.

  • command — result

Compatibility, safety, and release

  • Breaking changes or migration steps: none (additive)
  • Real Hopper/Ghidra, browser, or OS coverage: macOS host only; GDB sessions are Linux-only in production, so these tests use the fake/fixture paths
  • Package or release metadata impact: none
  • Security, privacy, process, or containment review: none

Author readiness

Human owner:

  • I reviewed the final diff and relevant existing code, understand the change and its edge cases, and take responsibility for the complete PR, including AI-assisted work.
  • I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps.
  • I declare this PR ready for initial maintainer review.

Before merge

  • This PR addresses a concrete problem or an agreed enhancement.
  • Material scope and authority questions are resolved, and any required maintainer scope decision covers the final diff.
  • The PR has one focused outcome and the title follows type(scope): outcome.
  • Related issue is linked, or the reason for not linking one is stated above.
  • Tests cover changed observable behavior and meaningful failure paths.
  • Owning docs, contracts, and generated metadata are updated where needed.
  • User-visible CLI/MCP changes include representative output.
  • I checked the final diff for secrets, unrelated cleanup, and unsupported claims.

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-15T14:01:05.912553Z
We couldn’t complete this review. Comment @codex review to try again.
80db626 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@morluto
morluto force-pushed the feat/gdb-session-stop-reasons branch from 80db626 to 68ed918 Compare November 15, 2026 14:04
@greptile-apps

greptile-apps Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5 Tier: plus

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

Adds stable stop codes to GDB and Rizin sessions without replacing their reason text.

  • Stopped GDB and Rizin sessions show a code for why they stopped.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A["Debugger stop: code and reason"] --> B["Session status"]
  B --> C["closed_reason and closed_reason_code"]
  A --> D["Stopped-session or protocol error"]
  D --> E["diagnostics.session_stop"]
  D --> F{"Cleanup incomplete?"}
  F -->|Composed Rizin failure| G["primary_error retains the stop diagnostic"]
Loading

Reviews (4) · Last reviewed commit: "Merge branch 'main' into feat/gdb-sessio..." · Reviewed by Greptile

Comment thread src/contracts/gdbToolContracts.ts Resolved
Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
Comment thread src/rizin/RizinDebugSessionManager.ts Resolved
Comment thread src/gdb/GdbSessionManager.ts Resolved
…up is incomplete

A GDB console command that reached its deadline while its owned process could not be confirmed stopped returned a capability error without details.diagnostics.session_stop, although the session had recorded command-deadline. Rizin's retained cleanup failure after a timed-out or exited command omitted it the same way. Both now carry the session's stop code, read from the recorded stop (GDB) and the session's stop-reason owner (Rizin). The unreachable second command-deadline assignment in the GDB timer is removed.
@morluto
morluto force-pushed the feat/gdb-session-stop-reasons branch from 5282348 to c7b36d8 Compare November 15, 2026 16:35
@morluto

morluto commented Nov 15, 2026

Copy link
Copy Markdown
Owner Author

@greptileai please review the latest commit: the branch was rebased on main after #11316 split the guard baselines into per-guard files, and the latest score predates that push.

@morluto
morluto merged commit 6510264 into main Nov 15, 2026
15 checks passed
@morluto
morluto deleted the feat/gdb-session-stop-reasons branch November 15, 2026 19:59
@morluto morluto added area: cli CLI adapter and one-shot commands enhancement New feature or request provider: gdb Analysis provider / engine: gdb provider: rizin Analysis provider / engine: rizin labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: cli CLI adapter and one-shot commands enhancement New feature or request provider: gdb Analysis provider / engine: gdb provider: rizin Analysis provider / engine: rizin

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant