hackwaly / ocamlearlybird

OCaml debug adapter
MIT License
208 stars 23 forks source link

How to debug ocamlearlybird? #8

Closed villesau closed 5 years ago

villesau commented 5 years ago

There were good instructions for it in "how to debug Flow" issue, but looks like the issue got removed. How can I debug ocamlearlybird when debugging flow?

villesau commented 5 years ago

Ok, so:

  1. in ocamlearlybird there is vscode run config Debug
  2. run that
  3. add line "debugServer": 4711, to your application config that you use for debugging purposes. In my case:
        {
            "name": "OCaml-earlybird-debug",
            "type": "ocaml-debugger",
            "request": "launch",
            "program": "${workspaceFolder}/bin/flow",
            "console": "internalConsole",
            "debugServer": 4711,
            "stopOnEntry": false,
            "arguments": ["check", "${workspaceFolder}/local-test/test.js", "--max-workers=0", "--verbose-indent", "--merge-timeout=10000"]
          }
  1. run that config in other vscode window

ps. feel free to use this as an example in Readme.

villesau commented 5 years ago

btw, i'm often getting

ocamlearlybird: internal error, uncaught exception:
                Unix.Unix_error(Unix.EADDRINUSE, "bind", "")
                Raised by primitive operation at unknown location
                Called from file "src/unix/lwt_unix.cppo.ml", line 1631, characters 52-74
                Called from file "src/unix/lwt_io.ml", line 1615, characters 4-22
                Called from file "src/unix/lwt_io.ml", line 1674, characters 4-88
                Called from file "ocaml_debug_adapter/main.ml", line 23, characters 16-138
                Called from file "src/core/lwt.ml", line 2101, characters 16-20
                Called from file "ocaml_debug_adapter/main.ml", line 33, characters 4-57
                Called from file "src/core/lwt.ml", line 3008, characters 28-29
                Called from file "src/unix/lwt_main.ml", line 42, characters 8-18
                Called from file "cmdliner_term.ml", line 25, characters 19-24
                Called from file "cmdliner.ml", line 116, characters 32-39

when rerunning debugger. I guess that the debug server is not gracefully closed when session ends.

hackwaly commented 5 years ago

Yes, it's wired and tough. I haven't find a solution for it right now. Do you have any clue?

villesau commented 5 years ago

Unfortunately I'm too unfamiliar with OCaml and vscode debugging stuff in overall :/