Skip to content

Comments

Feature/vscode debugger#166

Draft
highbyte wants to merge 104 commits intomasterfrom
feature/vscode-debugger
Draft

Feature/vscode debugger#166
highbyte wants to merge 104 commits intomasterfrom
feature/vscode-debugger

Conversation

@highbyte
Copy link
Owner

Major features and changes:

1. Debug Adapter
A debug adapter library to enable debugging from VSCode. It supports both source level debugging via CC65 toolchain .dbg files, and disassembly debugging when source and .dbg files are not available.

2. Debug Adapter hosts
The Avalonia Desktop app hosts the Debug Adapter (enabled via command line option) and exposes TCP endpoint for debug client connections.

Also a generic debug console app that hosts the Debug Adapter and debug clients connect via traditional STDIN/STDOUT.

3. VSCode debugger extension
A VSCode debugger extension that connects to one of the Debug Adapter hosts above.

Implements minimal viable debugger with:
- Debug Adapter Protocol (DAP) server in C#
- Address-based breakpoints
- Step/continue/pause execution
- Register and flag inspection
- Disassembly view at current PC
- VSCode extension integration

New projects:
- src/apps/Highbyte.DotNet6502.DebugAdapter - DAP server
- vscode-extension/ - VSCode extension files

Features:
- Launch .prg files from VSCode
- Set breakpoints at memory addresses
- View CPU state (PC, SP, A, X, Y, flags)
- Step through 6502 instructions
- Disassembly in call stack view

Limitations (MVP):
- No source-level debugging
- Address-only breakpoints
- No memory inspection
- No conditional breakpoints
- Add .vscode/launch.json for Extension Development Host
- Add .vscode/tasks.json for npm compile task
- Fix documentation to clarify F5 workflow:
  1. Open vscode-extension folder in VSCode
  2. Press F5 to launch Extension Development Host
  3. In new window, open folder with .prg file
- Update TESTING.md, DEVELOPMENT.md, README.md, MVP-COMPLETE.md
- Fix: .vscode directory now at correct path (vscode-extension/.vscode)
- Add build-test-program.ps1: PowerShell script to assemble test-program.asm using ACME
- Add launch.json.example: Sample debug configuration for test-program.prg
- Add QUICK-TEST.md: Step-by-step guide for testing the debugger
- Add test-program.prg: Pre-built binary (17 bytes) for immediate testing
- Uses ACME assembler at user's specified path
- Create vscode-extension-test/ folder for testing the debugger
- This folder has its own .vscode/launch.json for 6502 debugging
- Prevents confusion with vscode-extension/.vscode/launch.json (for extension dev)
- Add README explaining the two-folder structure
- Update QUICK-TEST.md to use the test folder

Workflow:
1. Main window: Open vscode-extension/, press F5 → Extension Dev Host
2. Dev Host window: Open vscode-extension-test/, press F5 → Debug 6502 program
- Removed test-program.asm, test-program.prg, build-test-program.ps1
- Removed launch.json.example
- These files now only exist in vscode-extension-test/ folder
- Keeps extension source folder clean and focused on extension code
- Avoids confusion about which folder to use for testing
- Use frame ID 0 (standard for top frame) instead of 1
- Add PC address to stack frame name for clarity
- Add presentationHint to frames and scopes
- Validate frameId in scopes request
- Add KNOWN-ISSUES.md explaining Variables panel behavior

The Variables panel clearing after each step is normal VSCode/DAP
behavior, not a bug. All debuggers work this way.
Current state:
- Added padding with synthetic addresses when VS Code requests instructions before 0x0000
- Added padding at end when we run out of instructions
- Behavior: Initial stop at 0x060e focuses on 0x05bf (incorrect), but highlights 0x0000 (correct)
- Subsequent stepping correctly highlights and focuses on the right addresses
- Memory addresses in disassembly still corrupted (0x0000-0x0033 then jumps to 0x0538)

This is a checkpoint - the least incorrect state seen so far.
…ble commands to work similar to ACME assembler.
…g a 6502 assembly program via the VSCode extension.
…bugger to TcpDebugServerManager and DebugAdapterLogic
…tations) before an instruction is executed instead of after. Fixes issue that prevented breakpoint being set on first instruction in a program.
… the emulated system and not just the cpu (makes sure C64 raster scan line is calculated between steps, etc.).

Breaking: Removes passing unnecessary SystemRunner instance to ISystem interface methods ExecuteOneFrame and ExecuteOneInstruction.
…el, and REPL. Enable setting CPU registers and flags via Variables and REPL.
…e, .data, .rodata etc). Default assume code.
… to location of .dbg file.

Fix startup so debugging is possible from first instruction executed (C64 kernal for example).
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
7.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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