hackwaly/ocamlearlybird

Start an OCaml Debug Session renders error

cdaringe opened this issue · 4 comments

problem

ctrl+shift+p and attempting to start a session yields a pop up error.

research

jumping into the extension host logs shows:

[2021-10-29 22:42:11.261] [exthost] [error] TypeError: Cannot read property 'scheme' of undefined
// ...snip snip snip...
Code.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:103:33550)
	at /Users/myuser/.vscode/extensions/hackwaly.ocamlearlybird-1.2.0/extension.js:72:39 // eyes
	at Pipe.onStreamRead (internal/stream_base_commons.js:188:23) ocamlearlybird.startDebug

by editting the JS, i discovered that uri is not defined:

context.subscriptions.push(vscode.commands.registerCommand('ocamlearlybird.startDebug', async (uri) => {
const folder = vscode.workspace.getWorkspaceFolder(uri);

Further debugging showed me that I could use:

const uri = vscode.window.activeTextEditor.document.uri;

to acquire a Uri!

i wasn't able to fully get into a debugging state yet though.

I'm trying to debug a local version of the jsoo compiler, a la:

    {
        "name": "js_of_ocaml.bc",
        "type": "ocamlearlybird",
        "request": "launch",
        "stopOnEntry": true,
        "yieldSteps": 4096,
        "arguments": ["compile", "/tmp/dummy.ml"],
        "program": "/Users/myuser/src/js_of_ocaml/_build/default/compiler/bin-js_of_ocaml/js_of_ocaml.bc",
    },

but:

  • i'm not sure if earlybird supports arguments yet? i did ocamlearlybird --help, and it suggested not (haven't checked the src yet)
  • running the above starts and exits, but yields no output to discern why the debug session failed

thanks for your time!

This command is not designed to manually call it in command plates. It is used to implement context menu on bytecode file. And if you debug in this way. You will lost the chance to specify arguments to debuggee program.

The recommended way is using launch configuration to debug. Just click the start debug button in debug pannel or press F5.

Thanks for the feedback.

I can certainly use the other methods.

However, if it is not supported from command palette, why register the command?

  "contributes": {
    "commands": [
      {
        "command": "ocamlearlybird.startDebug",
        "title": "Start an OCaml Debug Session"
      },

Any reason to not support it? I can send the PR :)

If it's explicitly forbidden, one could remove it from the palette, but i think it would be quite nice to have a executable file open and jump right into a debug session!

not critical though