Table of Contents
- Introduction
- Overview
- Setup
- Development
Introduction
This repository contains the dap-estgi-server for Haskell debugging based on the Debug Adapter Protocol (DAP).
dap-estgi-server/: DAP server for External STG Interpreter (DAP-ESTGi)
This library depends on two other libraries as well
dap/: Language and backend independent DAP librarydap-estgi-vscode-extension/: VSCode extension to support Haskell debugging using DAP-ESTGi server
Overview
The dap-estgi-vscode-extension turns VSCode into a Haskell debugger.
VSCode offers a nice debugger UI while the debugger features are provided by the External STG Interpreter DAP Server.
subgraph User Interface
A(VSCode) -.- |Plugin API| B(DAP ESTGi Extension)
end
B <-->|DAP via network| C(DAP ESTGi Server)
subgraph Debugger
C -.- |HS library API| D(External STG Interpreter)
end
The dap-estgi-server and dap-estgi-vscode-extension are application specific components, while the dap library is designed to be application independent to support any project that needs a simple DAP framework.
Setup
- Enable
Allow breakpoints everywhereoption in VSCode settings.
Install Haskell ESTGi Debugger Dependencies
- Run
(cd haskell-estgi-debugger ; stack install zip-cmd) - Ensure
libgmpis installed (e.g. if using homebrew,brew install gmp)
Install dap-estgi-extension
- Run
(git clone https://github.com/haskell-debugger/dap-estgi-vscode-extensi on; cd dap-estgi-vscode-extension ; npm install) - Open
dap-estgi-vscode-extensionfolder by using theFiles/Open Foldermenu. - Open the
src/extension.tsfile. - Press F5 to run the extension in a new VSCode [Extension Development Host] window.
Start dap-estgi-server
(cd dap-estgi-server ; stack run)
Note: If using Darwin OSX and you receive
external-stg-interpreter> * Missing (or bad) C library: omp
external-stg-interpreter> This problem can usually be solved by installing the system package that
external-stg-interpreter> provides this library (you may need the "-dev" version). If the library is
external-stg-interpreter> already installed but in a non-standard location then you can use the flags
external-stg-interpreter> --extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
external-stg-interpreter> library file does exist, it may contain errors that are caught by the C
external-stg-interpreter> compiler at the preprocessing stage. In this case you can re-run configure
external-stg-interpreter> with the verbosity flag -v3 to see the error messages.
Try installing libomp from brew and then running:
Compile debuggee program with GHC-WPC using stack
-
Add the following lines to debuggee's
stack.yaml:# use custom ext-stg whole program compiler GHC
compiler: ghc-9.2.7
compiler-check: match-exact
ghc-variant: wpc
setup-info:
ghc:
linux64-custom-wpc-tinfo6:
9.2.7:
url: "https://github.com/grin-compiler/foundation-pak/releases/download/ghc-9.2.7/ghc-9.2.7-x86_64-unknown-linux.tar.xz"
macosx-custom-wpc:
9.2.7:
url: "https://github.com/grin-compiler/foundation-pak/releases/download/ghc-9.2.7/ghc-9.2.7-x86_64-apple-darwin.tar.xz"
macosx-aarch64-custom-wpc:
9.2.7:
url: "https://github.com/grin-compiler/foundation-pak/releases/download/ghc-9.2.7/ghc-9.2.7-aarch64-apple-darwin.tar.xz" -
Run
stack buildi.e. build the provided sample hello world:(cd sample-program-to-debug ; stack build)
Open debuggee program in VSCode [Extension Development Host]
- Open debugge project folder by using the
Files/Open Foldermenu. - Select the debug view on the side bar
- Click to
create a launch.json file, then selectHaskell DAP ESTGi - Press F5 or the
Playbutton to start debugging