Skip to content

Fix DCC GDB/MI debugging integration - #38

Merged
davidly merged 1 commit into
davidly:mainfrom
gloveboxes:fix/dcc-mi-debugging
Aug 21, 2026
Merged

davidly merged 1 commit into
davidly:mainfrom
gloveboxes:fix/dcc-mi-debugging

Conversation

@gloveboxes

Copy link
Copy Markdown
Contributor

Summary

Improve ntvcm's DCC GDB/MI integration after end-to-end testing with the current MIR-based DCC emitter and VS Code's OpenDebugAD7 adapter.

This fixes source lookup and stepping edge cases, supports line-oriented CP/M input while debugging interactive programs, handles runtime-sized VLA watches, and substantially expands the cross-toolchain debugger regression suite.

User-visible fixes

  • Emit a real absolute MI fullname for source records while preserving the recorded file value.
  • Resolve relative source records against the loaded program location.
  • Match source paths case-insensitively on Windows and macOS, including uppercase CP/M/editor names such as CHATC11.C against chatc11.c metadata.
  • Avoid carrying a preceding function's closing-brace source record across a shared function boundary when stepping into the next function.
  • Display runtime-sized VLA types as [] and allow indexed watch access when the static outer dimension is unknown (0 in DCC metadata).
  • Require exact --interpreter=mi / -interpreter=mi option spelling so similarly prefixed CP/M arguments cannot accidentally start the MI server.

Interactive CP/M input

The Debug Console is owned by GDB/MI, so plain text is normally treated as a debugger expression. This PR adds an explicit target-input bridge:

-exec input 10*3
-exec input /bye

When a CP/M program requests input through blocking console input or a BDOS 6 polling loop, ntvcm reports a normal step stop. -exec input <text> then:

  1. queues the text plus CP/M Return;
  2. resumes execution atomically; and
  3. runs until the next breakpoint, input request, or program exit.

This was validated against the interactive DCC CALC app, including breakpoints immediately after the BDOS polling loop.

Normal-mode isolation

  • Target-input routing is gated by g_miMode.
  • x80.cxx and x80.hxx are unchanged by this branch.
  • The emulated instruction loop and cycle accounting are untouched.
  • Normal-mode CPU diagnostics, output, and instruction cycle totals match clean main.

Regression coverage

Expand tests/debugger_mi.py to validate both emitted metadata and debugger behavior:

  • strict parsing of every DCCDBG 2 record class;
  • linked code address bounds, function ranges, variable lifetimes, struct IDs, flags, and dimensions;
  • source breakpoints and duplicate-address behavior;
  • absolute and relative program/source paths, dotted directories, quoting, and metadata capacity warnings;
  • multi-module relocation order and aggregate globals;
  • nested source lines and shared function-boundary stepping;
  • recursive frames and frame selection;
  • scalar locals, globals, pointers, function pointers, arrays, VLAs, structs, unions, bit-fields, lexical shadowing, and variable assignment;
  • target input through direct MI and VS Code OpenDebugAD7;
  • adapter disassembly and instruction stepping;
  • exact MI option activation.

The old fixed entry-byte assertion was also replaced with a protocol-level four-byte hex assertion so the MI memory-read test does not depend on a particular DCC backend encoding.

Validation

Passed locally on macOS:

  • ./mmac.sh
  • python3 tests/debugger_mi.py --dcc-root /Users/dave/GitHub/dcc --ntvcm ./ntvcm
  • the same suite with VS Code's installed OpenDebugAD7 via --adapter
  • the direct MI suite under AddressSanitizer and UndefinedBehaviorSanitizer
  • python3 tests/cyclecheck.py ./ntvcm
  • CPUTEST.COM (CPU TESTS OK)
  • sustained normal-mode 8080EXER.COM comparison against clean main: identical output and 23,835,739,337 emulated cycles

Notes

The test suite remains cross-toolchain by design: it builds compact DCC fixtures, loads their generated .COM/.DBG pairs into ntvcm, and exercises the same MI protocol used by VS Code.

@davidly
davidly merged commit 924d4eb into davidly:main Aug 21, 2026
1 check passed
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.

2 participants