| 1 | // Commander X16 Emulator — Debug Adapter Protocol (DAP) Server |
| 2 | // Speaks DAP over TCP for direct IDE integration (VS, VS Code, etc.) |
| 3 | // Transport: Content-Length framed JSON over TCP, default port 9009 |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | // The server needs cJSON, which is optional at configure time. When it is not |
| 14 | // available the emulator is built without it and every entry point below |
| 15 | // becomes a no-op, so callers -- the CPU loop, the debugger, the store path -- |
| 16 | // do not have to be littered with #ifdefs for a feature they only notify. |
| 17 | |
| 18 | |
| 19 | static inline int |
| 20 | static inline int |
| 21 | static inline void |
| 22 | static inline bool |
| 23 | static inline bool |
| 24 | static inline void |
| 25 | static inline void |
| 26 | static inline void |
| 27 | static inline void |
| 28 | static inline void |
| 29 | |
| 30 | |
| 31 | |
| 32 | // Start listening on the given port. Returns 0 on success, -1 on error. |
| 33 | int ; |
| 34 | |
| 35 | // Poll for client commands. Non-blocking. |
| 36 | // Returns: 0 = no action, 1 = mode was changed by a remote command |
| 37 | int ; |
| 38 | |
| 39 | // Send DAP "stopped" event to the connected client. |
| 40 | // reason: "breakpoint", "step", "user", etc. |
| 41 | void ; |
| 42 | |
| 43 | // Returns true if a debug client is currently connected. |
| 44 | bool ; |
| 45 | |
| 46 | // Returns true if the DAP server is enabled (--debugport was used). |
| 47 | bool ; |
| 48 | |
| 49 | // Forward text to a connected DAP client's debug console (OutputEvent). No-op |
| 50 | // if no client is connected. category is "console"/"stdout"/"stderr"/etc. |
| 51 | void ; |
| 52 | |
| 53 | // Breakpoint bookkeeping hooks driven by the shared runtime-load handler when a |
| 54 | // module is (re)loaded. No-ops when no DAP client is connected. |
| 55 | void ; |
| 56 | void ; |
| 57 | |
| 58 | // Breakpoints are owned, not reconstructed. debug_core records which of -bp, |
| 59 | // the SDL debugger's F9, and the four kinds this file can ask for wants each |
| 60 | // entry, so a client session can clear everything it asked for with |
| 61 | // debug_bp_clear_owner() and nothing else is disturbed. Ask the core; do not |
| 62 | // rebuild that ownership out here from per-table flags or address refcounts. |
| 63 | // |
| 64 | // KNOWN LIMITATION, and a deliberate one: the core is the single source of |
| 65 | // truth for what is ARMED, but each front end owns its own VIEW. A breakpoint |
| 66 | // the user sets with F9 does not appear in a connected client's UI, and one the |
| 67 | // user deletes with F9 may be sent again by the client -- DAP's setBreakpoints |
| 68 | // replaces a source's whole list from the client's own model, and the |
| 69 | // specification tells clients to keep using their own properties rather than |
| 70 | // the adapter's. Emitting `breakpoint` events with reason `new`/`removed` would |
| 71 | // paper over this in VS Code specifically, but nothing in the protocol requires |
| 72 | // a client to act on them, so the divergence is documented rather than faked. |
| 73 | |
| 74 | // The machine has resumed. Called from the debugger's own execution control, so |
| 75 | // that a local F5/F10/F11 is accounted for the same way a DAP continue is: the |
| 76 | // next stop is then reported once, rather than suppressed as a duplicate of a |
| 77 | // halt that is already over. |
| 78 | void ; |
| 79 | |
| 80 | // Clean shutdown — close sockets, free resources. |
| 81 | void ; |
| 82 | |
| 83 | // HAS_DAP |
| 84 | |
| 85 | |