[PR #5124] [MERGED] fix(gdb): accept GDB's built-in p, s, d and t aliases #6775

Closed
opened 2026-11-01 21:42:58 +00:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/morluto/rea/pull/5124
Author: @bercedev
Created: 10/18/2026
Status: ✅ Merged
Merged: 10/22/2026
Merged by: @morluto

Base: main ← Head: fix/gdb-builtin-aliases


📝 Commits (1)

  • 959a2a1 fix(gdb): accept GDB's built-in p, s, d and t aliases

📊 Changes

2 files changed (+42 additions, -2 deletions)

View changed files

📝 src/gdb/GdbSessionManager.ts (+20 -2)
📝 tests/boundary/providers/GdbSessionManagerCoverage.test.ts (+22 -0)

📄 Description

Summary

Fixes #5098.

debug-with-gdb refused p 1, s and d 1 (and t 1) as commands that could invalidate the verified inferior output route, while print 1, step, delete 1 and thread 1 went through. They are the same commands.

Problem and expected behavior

gdbOneShotCommandMayInvalidateDetachProof and commandMayChangeInferiorOutput read the first word as a possible abbreviation, so p matched python, s matched source, d matched define, and t matched tty. GDB resolves its built-in aliases before abbreviations, so those words never mean the dangerous commands. Expected: accept an alias wherever its full spelling is accepted, and keep refusing real abbreviations.

Change and scope

A small map of GDB's built-in aliases that shadow those prefixes (d→delete, p→print, s→step, t→thread), and one helper, gdbCommandWord, that both checks now use for the first word. I asked GDB 18.1 (gdb -nx -batch -ex "help <word>") about every prefix of source, define, alias, python and tty: only these four resolve to a different command. The rest resolve to the dangerous command itself (so, py, tt) or are ambiguous (de, pyt, al), and stay refused.

t is not in the issue; it fails the same way through the tty prefix, so I included it.

Follow the contribution scope. Unresolved scope, authority, side effects, or required verification block integration. Ordinary fix within existing boundaries: not applicable.

Contract and boundary impact

  • Semantic owner and earliest changed stage: GDB console command classification in src/gdb/GdbSessionManager.ts.
  • Contribution scope fit and linked maintainer decision: ordinary fix, not applicable.
  • CLI and MCP/tool-catalog contract: no schema change; four alias spellings are accepted where their full spellings already were.
  • Provider, bridge, target-format, or platform compatibility: GDB only.
  • Evidence, artifact, provenance, or reconstruction contract: none.
  • Target selection, authority, upstream behavior, and cleanup details (if applicable): the commands that can change the output route (python/py, source, define, alias, tty, set inferior-tty, redirections, ; and newlines) are still refused.
  • Generated metadata (docs/public/product-catalog.json), package, or installation impact: none.

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, one new table for the one-shot check (aliases and full spellings accepted; py, pyt, so, de, and p 1; python ... refused) and two rows for commandMayChangeInferiorOutput (t 1 accepted, tt /dev/pts/2 refused).

  • Base reproduction or other evidence: on main, 5 of the new cases fail (t 1 in the first table, p 1, s, d 1, t 1 in the second). The issue's CLI-boundary probe, with a manager that stops at startup:

    command      main                          this PR
    p 1          invalid_request, starts=0     unreadable_output, starts=1
    s            invalid_request, starts=0     unreadable_output, starts=1
    d 1          invalid_request, starts=0     unreadable_output, starts=1
    t 1          invalid_request, starts=0     unreadable_output, starts=1
    print 1      unreadable_output, starts=1   unreadable_output, starts=1
    py print(1)  invalid_request, starts=0     invalid_request, starts=0
    
  • User-visible CLI/MCP output (if applicable): the alias spellings now reach GDB startup instead of invalid_request.

  • Remaining proof gaps: not run against a live GDB inferior; the alias resolution itself was checked against GDB 18.1.

Validation performed

In a Node 24.18.0 container (with procps) and no network, after npm ci:

  • npx vitest run tests/boundary/providers/GdbSessionManagerCoverage.test.ts: 163 passed; on main with the new tests, 5 failed (the cases above).
  • npx tsc --noEmit: no errors.
  • oxlint on the changed source file: 19 warnings, 0 errors, the same 19 as on main.
  • oxfmt --check on the changed files: clean.

Compatibility, safety, and release

  • Breaking changes or migration steps: none.
  • Real Hopper/Ghidra, browser, or OS coverage: GDB 18.1 on Arch-based Linux for alias resolution; no live debugging session.
  • Package or release metadata impact: none.
  • Security, privacy, process, or containment review: the refusal set for output-route changes is unchanged apart from the four alias words, which GDB never reads as those commands.

Author readiness

Human owner: @bercedev

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

Note: I used Claude Code while working on this.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/morluto/rea/pull/5124 **Author:** [@bercedev](https://github.com/bercedev) **Created:** 10/18/2026 **Status:** ✅ Merged **Merged:** 10/22/2026 **Merged by:** [@morluto](https://github.com/morluto) **Base:** `main` ← **Head:** `fix/gdb-builtin-aliases` --- ### 📝 Commits (1) - [`959a2a1`](https://github.com/morluto/rea/commit/959a2a1790615ba35f38734f74a960e9cc6c2bd0) fix(gdb): accept GDB's built-in p, s, d and t aliases ### 📊 Changes **2 files changed** (+42 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `src/gdb/GdbSessionManager.ts` (+20 -2) 📝 `tests/boundary/providers/GdbSessionManagerCoverage.test.ts` (+22 -0) </details> ### 📄 Description ## Summary Fixes #5098. `debug-with-gdb` refused `p 1`, `s` and `d 1` (and `t 1`) as commands that could invalidate the verified inferior output route, while `print 1`, `step`, `delete 1` and `thread 1` went through. They are the same commands. ## Problem and expected behavior `gdbOneShotCommandMayInvalidateDetachProof` and `commandMayChangeInferiorOutput` read the first word as a possible abbreviation, so `p` matched `python`, `s` matched `source`, `d` matched `define`, and `t` matched `tty`. GDB resolves its built-in aliases before abbreviations, so those words never mean the dangerous commands. Expected: accept an alias wherever its full spelling is accepted, and keep refusing real abbreviations. ## Change and scope A small map of GDB's built-in aliases that shadow those prefixes (`d`→delete, `p`→print, `s`→step, `t`→thread), and one helper, `gdbCommandWord`, that both checks now use for the first word. I asked GDB 18.1 (`gdb -nx -batch -ex "help <word>"`) about every prefix of `source`, `define`, `alias`, `python` and `tty`: only these four resolve to a different command. The rest resolve to the dangerous command itself (`so`, `py`, `tt`) or are ambiguous (`de`, `pyt`, `al`), and stay refused. `t` is not in the issue; it fails the same way through the `tty` prefix, so I included it. Follow the [contribution scope](https://github.com/morluto/rea/blob/main/CONTRIBUTING.md#contribution-scope). Unresolved scope, authority, side effects, or required verification block integration. Ordinary fix within existing boundaries: not applicable. ## Contract and boundary impact - Semantic owner and earliest changed stage: GDB console command classification in `src/gdb/GdbSessionManager.ts`. - Contribution scope fit and linked maintainer decision: ordinary fix, not applicable. - CLI and MCP/tool-catalog contract: no schema change; four alias spellings are accepted where their full spellings already were. - Provider, bridge, target-format, or platform compatibility: GDB only. - Evidence, artifact, provenance, or reconstruction contract: none. - Target selection, authority, upstream behavior, and cleanup details (if applicable): the commands that can change the output route (`python`/`py`, `source`, `define`, `alias`, `tty`, `set inferior-tty`, redirections, `;` and newlines) are still refused. - Generated metadata (`docs/public/product-catalog.json`), package, or installation impact: none. 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`, one new table for the one-shot check (aliases and full spellings accepted; `py`, `pyt`, `so`, `de`, and `p 1; python ...` refused) and two rows for `commandMayChangeInferiorOutput` (`t 1` accepted, `tt /dev/pts/2` refused). - Base reproduction or other evidence: on `main`, 5 of the new cases fail (`t 1` in the first table, `p 1`, `s`, `d 1`, `t 1` in the second). The issue's CLI-boundary probe, with a manager that stops at startup: ```text command main this PR p 1 invalid_request, starts=0 unreadable_output, starts=1 s invalid_request, starts=0 unreadable_output, starts=1 d 1 invalid_request, starts=0 unreadable_output, starts=1 t 1 invalid_request, starts=0 unreadable_output, starts=1 print 1 unreadable_output, starts=1 unreadable_output, starts=1 py print(1) invalid_request, starts=0 invalid_request, starts=0 ``` - User-visible CLI/MCP output (if applicable): the alias spellings now reach GDB startup instead of `invalid_request`. - Remaining proof gaps: not run against a live GDB inferior; the alias resolution itself was checked against GDB 18.1. ## Validation performed In a Node 24.18.0 container (with procps) and no network, after `npm ci`: - `npx vitest run tests/boundary/providers/GdbSessionManagerCoverage.test.ts`: 163 passed; on `main` with the new tests, 5 failed (the cases above). - `npx tsc --noEmit`: no errors. - `oxlint` on the changed source file: 19 warnings, 0 errors, the same 19 as on `main`. - `oxfmt --check` on the changed files: clean. ## Compatibility, safety, and release - Breaking changes or migration steps: none. - Real Hopper/Ghidra, browser, or OS coverage: GDB 18.1 on Arch-based Linux for alias resolution; no live debugging session. - Package or release metadata impact: none. - Security, privacy, process, or containment review: the refusal set for output-route changes is unchanged apart from the four alias words, which GDB never reads as those commands. ## Author readiness <!-- The human owner completes these declarations before requesting review. The PR author is the owner by default. A different owner must explicitly accept ownership on this PR. AI agents must leave these declarations to a human to dictate to them or there could be catastrophic consequences for many users of REA. Draft PRs may leave them unchecked. These declarations record initial readiness when opening the PR for review; later pushes do not require a new human sign-off. Keep the description and validation evidence current as the work changes. See CONTRIBUTING.md#pull-request-ownership-and-readiness. --> Human owner: @bercedev - [x] 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. - [x] I checked the evidence above, confirmed it supports the current change, and recorded meaningful validation gaps. - [x] I declare this PR ready for initial maintainer review. ## Before merge <!-- Draft PRs may leave pending items unchecked. Resolve material scope and authority questions before integration. --> - [ ] 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. Note: I used Claude Code while working on this. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-01 21:42:58 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
morluto/rea#6775
No description provided.