Skip to content

Commit e6c93c5

Browse files
committed
Clean up debugging docs and investigation logs
1 parent 3ee1fa4 commit e6c93c5

4 files changed

Lines changed: 17 additions & 19 deletions

File tree

docs/DAP_BACKEND_IMPLEMENTATION_PLAN.md

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
<chatName="DAP backend plan"/>
2-
31
## Goal & constraints (grounded in current code)
42

53
Implement a real **`lldb-dap` Debug Adapter Protocol backend** that plugs into the existing debugger architecture without changing MCP tool names/schemas. The DAP backend remains **opt-in only** via `XCODEBUILDMCP_DEBUGGER_BACKEND=dap` (current selection logic in `src/utils/debugger/debugger-manager.ts`).
@@ -185,7 +183,7 @@ export class DapTransport {
185183
- Backend may still serialize higher-level operations if stateful.
186184

187185
**Side effects**
188-
- Adds a long-lived child process per session.
186+
- Add a long-lived child process per session.
189187
- Requires careful memory management in the framing buffer (ensure you slice consumed bytes).
190188

191189
---
@@ -273,12 +271,12 @@ export async function createDapBackend(opts?: {
273271
4) `configurationDone` if required by lldb-dap behavior (plan for it even if no-op)
274272
5) mark attached
275273

276-
- `detach()`:
274+
- `detach()`
277275
- send `disconnect` with `terminateDebuggee: false` (do not kill app)
278276
- dispose transport / kill process
279277

280-
- `dispose()`:
281-
- best-effort cleanup; **must not throw** (important because `DebuggerManager.createSession` calls dispose on attach failure)
278+
- `dispose()`
279+
- best-effort cleanup; **must not throw** (important because `DebuggerManager.createSession` calls dispose to clean up on attach failure)
282280

283281
**Method mappings (MCP tools → DebuggerManager → DapBackend)**
284282

@@ -439,8 +437,8 @@ private enqueue<T>(work: () => Promise<T>): Promise<T> { ... }
439437
```
440438

441439
**Reasoning**
442-
- Prevent races like:
443-
- addBreakpoint + removeBreakpoint in parallel reissuing `setBreakpoints` inconsistently.
440+
- Prevent races such as:
441+
- addBreakpoint + removeBreakpoint in parallel, reissuing `setBreakpoints` inconsistently.
444442

445443
---
446444

@@ -453,7 +451,7 @@ private enqueue<T>(work: () => Promise<T>): Promise<T> { ... }
453451
### Where to log
454452
- `DapTransport`:
455453
- `log('debug', ...)` for raw events (optionally gated by env)
456-
- `log('error', ...)` on process exit while requests pending
454+
- `log('error', ...)` on process exit while requests are pending
457455
- `DapBackend`:
458456
- minimal `info` logs on attach/detach
459457
- `debug` logs for request mapping (command names, not full payloads unless opted in)
@@ -514,7 +512,7 @@ New: `src/utils/debugger/__tests__/debugger-manager-dap.test.ts`
514512
## Docs updates (grounded in existing docs)
515513

516514
### 1) Update `docs/DAP_BACKEND_IMPLEMENTATION_PLAN.md`
517-
Replace/extend the existing outline with:
515+
Replace/extend the existing outline with the following:
518516
- finalized module list (`dap/types.ts`, `dap/transport.ts`, discovery helper)
519517
- breakpoint strategy (stateful re-issue `setBreakpoints`)
520518
- explicit mapping table per MCP tool
@@ -568,6 +566,6 @@ Add a section “DAP Backend (lldb-dap)”:
568566
---
569567

570568
## Critical “don’t miss” requirements
571-
- `dispose()` in DAP backend and transport must be **best-effort and never throw**, because `DebuggerManager.createSession()` will call dispose on attach failure.
569+
- `dispose()` in DAP backend and transport must be **best-effort and never throw** because `DebuggerManager.createSession()` will call dispose on attach failure.
572570
- Avoid any use of default executors/spawners in tests; ensure `createDapBackend()` accepts injected `executor` + `spawner`.
573571
- Breakpoint removal requires stateful re-application with `setBreakpoints` / `setFunctionBreakpoints`; plan for breakpoint registries from day one.

docs/DEBUGGING_ARCHITECTURE.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,13 +190,13 @@ Annotated example (simplified):
190190
- `XCODEBUILDMCP_LLDB> `
191191
3. Parser behavior:
192192
- Sentinel marks the end of the command output payload.
193-
- Prompt is used to trim the buffer so the next command starts cleanly.
193+
- Prompt is used to trim the buffer, so the next command starts cleanly.
194194

195195
### Output parsing and sanitization
196196

197197
- `handleData()` appends to an internal buffer, and `checkPending()` scans for the sentinel regex
198198
`/(^|\\r?\\n)__XCODEBUILDMCP_DONE__(\\r?\\n)/`.
199-
- Output is the buffer up to the sentinel. The remainder is trimmed to the next prompt if present.
199+
- Output is the buffer up to the sentinel. The remainder is trimmed to the next prompt, if present.
200200
- `sanitizeOutput()` removes prompt echoes, sentinel lines, the `script print(...)` lines, and empty
201201
lines, then `runCommand()` returns `trimEnd()` output.
202202

@@ -253,7 +253,7 @@ processes. Tests should inject a mock `InteractiveSpawner` into `createLldbCliBa
253253
### xcodebuild (Build/Launch Context)
254254

255255
- Debugging assumes a running simulator app.
256-
- The typical flow is build and launch via simulator tools (for example `build_sim`),
256+
- The typical flow is to build and launch via simulator tools (for example `build_sim`),
257257
which uses `executeXcodeBuildCommand` to invoke `xcodebuild` (or `xcodemake` when enabled).
258258
- After launch, `debug_attach_sim` attaches LLDB to the simulator process.
259259

docs/investigations/issue-154-screenshot-downscaling.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,25 @@ Investigation started; initial context gathered from the issue description. Cont
99

1010
## Investigation Log
1111

12-
### 2025-01-XX - Initial assessment
12+
### 2026-01-04 - Initial assessment
1313
**Hypothesis:** Screenshot pipeline always emits full-resolution images and lacks an opt-in scaling path.
1414
**Findings:** Issue describes full-res screenshots and requests optional downscaling. No code inspected yet.
1515
**Evidence:** GitHub issue #154 body.
1616
**Conclusion:** Needs codebase investigation.
1717

18-
### 2025-01-XX - Context builder attempt
18+
### 2026-01-04 - Context builder attempt
1919
**Hypothesis:** Use automated context discovery to map screenshot capture flow.
2020
**Findings:** `context_builder` failed due to Gemini CLI usage error in this environment.
2121
**Evidence:** Tool error output in session (Gemini CLI usage/help text).
2222
**Conclusion:** Proceeding with manual code inspection.
2323

24-
### 2025-01-XX - Screenshot capture implementation
24+
### 2026-01-04 - Screenshot capture implementation
2525
**Hypothesis:** Screenshot tool stores and returns full-resolution PNGs.
2626
**Findings:** The `screenshot` tool captures a PNG, then immediately downscales/optimizes via `sips` to max 800px width, JPEG format, quality 75%, and returns the JPEG. Optimization is always attempted; on failure it falls back to original PNG.
2727
**Evidence:** `src/mcp/tools/ui-testing/screenshot.ts` (sips `-Z 800`, `format jpeg`, `formatOptions 75`).
2828
**Conclusion:** The current implementation already downscales by default; the gap is configurability (opt-in/out, size/quality controls) and documentation.
2929

30-
### 2025-01-XX - Git history check
30+
### 2026-01-04 - Git history check
3131
**Hypothesis:** Recent commits might have added/changed screenshot optimization behavior.
3232
**Findings:** Recent history shows tool annotations and session-awareness changes, but no indication of configurable screenshot scaling.
3333
**Evidence:** `git log -n 5 -- src/mcp/tools/ui-testing/screenshot.ts`.

docs/investigations/issue-describe-ui-empty-after-debugger-resume.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# RCA: describe_ui returns empty tree after debugger resume
22

33
## Summary
4-
When the app is stopped under LLDB (breakpoints hit), the `describe_ui` tool frequently returns an empty accessibility tree (0x0 frame, no children). This is not caused by a short timing gap after resume. The root cause is that the process is still stopped (or immediately re-stopped) due to active breakpoints, so AX snapshotting cannot retrieve a live hierarchy.
4+
When the app is stopped under LLDB (breakpoints hit), the `describe_ui` tool frequently returns an empty accessibility tree (0x0 frame, no children). This is not because of a short timing gap after resume. The root cause is that the process is still stopped (or immediately re-stopped) due to active breakpoints, so AX snapshotting cannot retrieve a live hierarchy.
55

66
## Impact
77
- UI automation appears "broken" after resuming from breakpoints.

0 commit comments

Comments
 (0)