hackwaly / ocamlearlybird

OCaml debug adapter
MIT License
208 stars 23 forks source link

Fatal error when attempting to debug Dune project #17

Closed andersfischernielsen closed 4 years ago

andersfischernielsen commented 4 years ago

Awesome project! :+1:

I'm seeing the following error when I'm trying to build an executable that is built using dune:

$ ocamlearlybird --server --port=4711
Fatal error: exception Failure("No debug symbols.")
Raised at file "debug_adapter_protocol/rpc.ml", line 93, characters 4-420
Re-raised at file "debug_adapter_protocol/rpc.ml", line 126, characters 4-84
Re-raised at file "debug_adapter_protocol/rpc.ml", line 144, characters 4-96
Re-raised at file "ocaml_debug_adapter/main.ml", line 11, characters 2-98

The failure shows up as soon as I hit the "Start Debugging" button in VSCode.

This is my launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug",
            "type": "ocaml-debugger",
            "request": "launch",
            "program": "${workspaceRoot}/bin/eba", <--  also fails using "_build/default/src/eba.exe"
            "console": "internalConsole",
            "dotMerlins": ["${workspaceRoot}/src/.merlin"],
            "noDebug": false,
            "stopOnEntry": true,
            "env": {
              "OCAMLRUNPARAM": "v"
            },
            "debugServer": 4711
          }
    ]
}

Debug symbols should be available. This is my dune file:

(executable
 (name eba)
 (package eba)
 (public_name eba)
 (libraries batteries cil ocamlgraph smart_print cmdliner dolog fpath))
(env
  (_
    (flags (:standard -g -warn-error -A))))

If it helps, the project I'm trying to debug is: https://github.com/andersfischernielsen/eba

andersfischernielsen commented 4 years ago

Got it to work!

andersfischernielsen commented 4 years ago

For others: My Dune target needed to be eba.bc instead of eba.exe. Then the launch file needed to be set to debug the resulting .bc file.