hackwaly / vscode-ocaml-debugger

OCaml debugger for VS Code
14 stars 4 forks source link

How to debug Flow? #5

Closed villesau closed 5 years ago

villesau commented 5 years ago

Flow has issue of debugging, and people has succeeded to debug it with certain configurations: https://github.com/facebook/flow/issues/4181

Anyhow, with vscode-ocaml-debugger I have not been able to start debug session with flow. Looks like nothing happens with following config, just endless blue loading bar appears and thats it:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "OCaml",
            "type": "ocaml-debugger",
            "request": "launch",
            "program": "${workspaceFolder}/bin/flow",
            "console": "internalConsole",
            "stopOnEntry": false,
            "arguments": ["check", "${workspaceFolder}/my-own-test/test.js", "--max-workers", "0"]
          }
    ]
}

Would be nice to see some logging if there is e.g something that goes wrong.

hackwaly commented 5 years ago

I have not enough time to address your issue. You can use ocaml-debugger to debug ocaml-debugger to debug flow to check out what happens.

First you need clone git@github.com:hackwaly/ocamlearlybird.git, Use vscode open the project folder. Then use this configuration to debug ocamlearlybird.

    {
      "name": "Debugger",
      "type": "ocaml-debugger",
      "request": "launch",
      "program": "${workspaceRoot}/_build/default/ocaml_debug_adapter/main.bc",
      "arguments": ["--server", "--port=4712"],
      "preLaunchTask": "build",
      "console": "internalConsole",
      "env": {
        "OCAMLRUNPARAM": "b"
      }
    },

Then use the debugged ocamlearlybird to debug flow:

        {
            "name": "OCaml",
            "type": "ocaml-debugger",
            "request": "launch",
            "program": "${workspaceFolder}/bin/flow",
            "console": "internalConsole",
            "stopOnEntry": false,
            "arguments": ["check", "${workspaceFolder}/my-own-test/test.js", "--max-workers", "0"],
            "debugServer": 4712
          }
villesau commented 5 years ago

Hi @hackwaly,

In sessiom.ml Initialize_command gets following args:

screenshot 2018-12-11 at 20 48 53

and Launch_command gets following args:

screenshot 2018-12-11 at 20 52 08

Also noticed that the program is apparently launched with ocamlrun command? Something like: ocamlrun bin/flow check my-own-test/test.js --max-workers 0 but when running that manually I'm getting:

Fatal error: unknown C primitive `unix_waitpid'

Maybe this is the culprit? Taking the ocamlrun off runs the program fine. I'm trying to debug on macOS.

E: When downgrading Ocaml from 4.06.0 to 4.05.0, the error changes to:

Fatal error: unknown C primitive `caml_floatarray_create'
hackwaly commented 5 years ago

Looks like this issue https://github.com/ocaml-community/utop/issues/34

hackwaly commented 5 years ago

@villesau This should be fixed as I removed the unnecessary ocamlrun. Track progress https://github.com/ocaml/opam-repository/pull/13149

villesau commented 5 years ago

@hackwaly Nice, thanks! Works like a charm now!