@@ -47,7 +47,77 @@ Arbitrary Watch expressions:
4747
4848![ Watch expressions] ( images/watch_expressions.png )
4949
50- ### Requirements
50+ ## Usage
51+
52+ To use the ` cc65-dbg ` extension for debugging your 6502/65816 binaries in VSCode,
53+ configure your ` .vscode/launch.json ` file with one of the following templates:
54+
55+ ### Launch a Debug Session
56+
57+ To start the emulator and begin debugging automatically:
58+
59+ ``` json
60+ {
61+ "type" : " cc65-dbg" ,
62+ "request" : " launch" ,
63+ "name" : " Debug file" ,
64+ "program" : " hello_world.bin" ,
65+ "command" : " /usr/local/bin/emu" ,
66+ "args" : [" --dap" ],
67+ "stopOnEntry" : true ,
68+ "cwd" : " ${workspaceFolder}" ,
69+ "trace" : true
70+ }
71+ ```
72+
73+ * ` program ` : The binary file to debug.
74+ * ` command ` : Path to your emulator binary.
75+ * ` args ` : Enter whatever arguments your emulator needs to enable DAP server.
76+ * ` stopOnEntry ` : Set to ` true ` to halt at program start.
77+ * ` cwd ` : Working directory.
78+ * ` trace ` : Enables DAP message logging for troubleshooting.
79+
80+ ### Attach to a Running Emulator
81+
82+ To attach the debugger to an emulator already running with DAP server port open:
83+
84+ ``` json
85+ {
86+ "type" : " cc65-dbg" ,
87+ "request" : " attach" ,
88+ "name" : " Attach running" ,
89+ "program" : " hello_world.bin" ,
90+ "address" : " ws://localhost:4567/debug/" ,
91+ "trace" : true
92+ }
93+ ```
94+
95+ * ` program ` : Binary used by the running emulator (for symbols).
96+ * ` address ` : WebSocket DAP endpoint of the emulator.
97+
98+ ### CMake Integration (Recommended for CMake Projects)
99+
100+ You can streamline your workflow by integrating with VSCode's CMake Tools extension:
101+
102+ ``` json
103+ {
104+ "type" : " cc65-dbg" ,
105+ "request" : " launch" ,
106+ "name" : " Build & Debug" ,
107+ "program" : " ${command:cmake.launchTargetPath}" ,
108+ "command" : " /usr/local/bin/emu" ,
109+ "args" : [" --dap" , " ${command:cmake.launchTargetPath}" ],
110+ "stopOnEntry" : true ,
111+ "cwd" : " ${workspaceFolder}" ,
112+ "trace" : true ,
113+ "preLaunchTask" : " CMake: build"
114+ }
115+ ```
116+
117+ * Automatically uses the current CMake build target for ` program ` .
118+ * Builds the project before launching via ` preLaunchTask ` .
119+
120+ ## Requirements
51121
52122> ⚠️ Following is a deviation from Debug Adapter Protocol, used to simplify
53123> the DAP-debugger implementation for 8-bit machine emulators.
@@ -66,11 +136,11 @@ for the pack is being received.
66136
67137[ 3 ] : https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source
68138
69- ### Emulators
139+ ## Emulators
70140
71141List of emulators supporting this variation of DAP:
72142
73- - Emu <img src =" https://raw.githubusercontent.com/X65/emu/main/emu.gif " alt =" Emu " > — The [ X65 Computer] ( https://x65.zone/ ) Emulator.
143+ * Emu <img src =" https://raw.githubusercontent.com/X65/emu/main/emu.gif " alt =" Emu " > — The [ X65 Computer] ( https://x65.zone/ ) Emulator.
74144
75145If you know any other, please [ create a PR] [ 4 ] with an update to the list.
76146
@@ -80,7 +150,7 @@ If you know any other, please [create a PR][4] with an update to the list.
80150
81151This extension builds on code from:
82152
83- - [ Alchemy65] ( https://github.com/AlchemicRaker/alchemy65 )
84- - [ db65xx] ( https://github.com/tmr4/db65xx )
153+ * [ Alchemy65] ( https://github.com/AlchemicRaker/alchemy65 )
154+ * [ db65xx] ( https://github.com/tmr4/db65xx )
85155
86156Kudos to its authors!
0 commit comments