-
Notifications
You must be signed in to change notification settings - Fork 215
Description
Proposal: Add Native Debug Adapter Protocol (DAP) Support to Harbour Debugger
Summary
This Issue proposes adding a transport-agnostic interface to the Harbour debugger to enable native Debug Adapter Protocol (DAP) support.
With this enhancement, Harbour applications could be debugged directly from modern editors such as VSCode, JetBrains IDEs, Eclipse, or any other DAP-compatible tool — without replacing the existing terminal debugger.
The approach is backwards-compatible, opt-in, and requires only minimal extensions to the current debugger architecture.
Problem
Harbour includes a mature and powerful debugger (debugger.prg), but today it is only accessible through terminal interfaces. As a result:
- There is no native way to debug Harbour code from modern IDEs.
- Developers cannot attach to remote processes running on servers, containers, or embedded devices.
- New developers often perceive Harbour as lacking modern tooling support.
Implementing DAP enables Harbour to integrate with any standard debugging client while preserving and reusing the existing debugger engine.
Motivation
Adding DAP support would bring several benefits:
-
Modern Development Workflow
Debugging directly inside VSCode or JetBrains lowers the entry barrier for new developers. -
Remote Debugging
Enables attaching to Harbour applications over TCP/WebSocket. -
Reuse of Existing Debugger Engine
No need to create a new debugger — only to expose existing capabilities through transports. -
Cross-Platform
Works on Windows, Linux and macOS. -
Ecosystem Compatibility
Any DAP-compliant editor becomes a Harbour-capable debugger.
Proposed Architectural Approach (High-Level)
This proposal follows a minimal and additive strategy:
1. Add New Debugger Activation Modes
Example:
HB_DBG_ACTIVATE_STDIOHB_DBG_ACTIVATE_DAP
These modes would activate the debugger in “remote/transported” mode rather than terminal mode.
2. Create Transport-Agnostic Hooks
Introduce small send/receive abstractions inside the debugger so communication can be routed through:
- STDIO
- TCP sockets
- WebSockets
- Any custom transport
This requires only lightweight additions (e.g., setting function pointers or callbacks).
3. Add a Basic DAP Command Handler
At this stage, only essential commands are required:
- initialize
- launch / attach
- setBreakpoints
- continue / next / stepIn
- stackTrace
- scopes / variables
- evaluate
This can be expanded incrementally.
4. Keep Terminal Debugger Fully Intact
Existing behaviour remains unchanged unless a DAP/STDIO mode is explicitly activated.
Implementation Plan (Phased)
Phase 1 — STDIO Transport
- JSON-over-stdio communication
- Minimal command set
- Allows local debugging from any DAP client
Phase 2 — Full DAP Support
- Complete DAP request/response/event coverage
- Editor extension for VSCode (optional)
Phase 3 — Remote Transports
- TCP server for remote debugging
- WebSocket transport for browser-based tools
- Attach support
Backward Compatibility
This proposal is 100% additive:
- The default debugger continues operating exactly as it does today.
- No behavioural changes occur unless the new modes are explicitly requested.
- The terminal UI remains untouched.
Example of Expected Usage (Conceptual)
Local (STDIO) Debugging
harbour app.prg -debug=stdioDAP Server
harbour app.prg -debug=dap:port=4712VSCode Launch Configuration
{
"type": "harbour",
"request": "launch",
"name": "Debug Harbour",
"program": "${workspaceFolder}/app.prg",
"transport": "stdio"
}Prototype Availability
A working prototype demonstrating the feasibility of this architecture exists.
I am willing to contribute a full implementation and help maintain the feature if this proposal is accepted.
Request for Feedback
I would appreciate input from the maintainers and community on:
- Whether this direction aligns with Harbour’s architecture
- Any concerns regarding integration into
debugger.prg - Suggestions for transport API design
- Interest in accepting a PR for this feature