hackwaly / ocamlearlybird

OCaml debug adapter

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breakpoints not hit when using WSL

edcarroll opened this issue · comments

commented

I've been trying to get this to work with WSL under Windows 10, using OCaml 4.04.2, Opam 2.0.1, and the latest version of VSCode.

I got Opam 2 working on WSL by using opam init --disable-sandboxing, and the earlybird server runs without issue, though when I try to pause at a breakpoint nothing happens - the program successfully runs, exits and outputs in the debug console, and the earlybird server stays running.

However, if I run VSCode within WSL using a running X server, it will successfully stop on the provided breakpoints. I wonder if there is something I am doing wrong in the Windows setup?

Any pointers you have would be much appreciated!


My main.ml file:

let square n = n * n;;

print_string ("Hello, world!\n" ^ string_of_int (square 5));;

My launch task (in launch.json):

{
    "name": "launch",
    "type": "ocaml-debugger",
    "request": "launch",
    "preLaunchTask": "build",
    "console": "internalConsole",
    "program": "${workspaceFolder}/main",
    "windows": {
        "program": "${command:extension.vscode-wsl-workspaceFolder}/main",
    },
    "env": {
        "OCAMLRUNPARAM": "b"
    }
}

My build task (in tasks.json):

{
    "label": "build",
    "type": "shell",
    "windows": {
        "options": {
            "shell": {
                "executable": "C:\\WINDOWS\\System32\\bash.exe",
                "args": [
                    "-ic"
                ]
            }
        },
    },
    "command": "make all",
    "problemMatcher": [
        "$ocamlc"
    ],
    "group": {
        "kind": "build",
        "isDefault": true
    },
    "presentation": {
        "reveal": "never"
    }
},

My makefile:

## Variables ##

OCAMLC = ocamlc
OCAMLC_OPTS = -g

## Commands

all: 
	${OCAMLC} ${OCAMLC_OPTS} ./main.ml -o ./main

I guess the stopOnEntry option doesn't work, too.

If you want to debug with ocamlearlybird in debug server mode. Add debugServer option into your launch configuration.

{
    "name": "launch",
    "type": "ocaml-debugger",
    "request": "launch",
    "preLaunchTask": "build",
    "console": "internalConsole",
    "program": "${workspaceFolder}/main",
    "windows": {
        "program": "${command:extension.vscode-wsl-workspaceFolder}/main",
    },
    "env": {
        "OCAMLRUNPARAM": "b"
    },
    "debugServer": 4711
}

First, you need start earlybird in server mode at port 4711 separated.

$> ocamlearlybird --server --port=4711 

Then you can press F5, to debug your ocaml bytecode with ocamlearlybird debug server.

commented

Thank you for getting back to me so soon 😄

Sorry - I copied the wrong launch json, I have been using the debugServer option, as well as running the server with ocamlearlybird --server --port=4711 in WSL - yet it still refuses to pause on any breakpoints.

When doing the same thing, except that VSCode is running in the Ubuntu instance in WSL, I get the breakpoints hit.

I tried the stopOnEntry, and am getting no change unfortunately.

How did you get your bytecode runs without crash the debug server? I've tested in my VM, it crash the debug server, because earlybird in WSL doesn't handle windows style path.

Fatal error: exception Unix.Unix_error(Unix.ENOENT, "open", "C:\\Users\\wenyuxiang\\Desktop\\ocaml-debug/a.out")
Raised by primitive operation at file "src/unix/lwt_unix.cppo.ml", line 235, characters 14-31
Re-raised at file "ocaml_debug_adapter/agent_initialized.ml", line 98, characters 4-1023
Re-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-23
commented

I'm using the WSL workspaceFolder extension, and have added this into my launch json:

"windows": {
    "program": "${command:extension.vscode-wsl-workspaceFolder}/main",
},

The issue possibly caused by the path style. This extension is not considered to support WSL at first, and I'm busy for other things. So, pull requests are welcome!

image

commented

The same problem with me. I have a project in wsl2, the debugger skipped any breakpoints, just run normally and exit, the stopOnEntry is worked.
Here is my launch.json

{
  "name": "OCaml earlybird (experimental)",
  "type": "ocaml.earlybird",
  "request": "launch",
  "program": "${workspaceFolder}/analysis/_build/default/src/Cli.bc",
  "arguments": [
      "test",
	"./tests/src/Pipe.res"
  ],
  "cwd": "${workspaceFolder}/analysis",
  "env": {
     "LD_LIBRARY_PATH": "${workspaceFolder}/analysis/_build/default/vendor/ext"
  },
  "stopOnEntry": true,
  "console": "integratedTerminal",
  "onlyDebugGlob": "<${workspaceFolder}/**/*>",
  "yieldSteps": 1024,
}

The break point is unverified.
image

image