[ANN] ocamlearlybird 1.0.0 beta1

Hi, all

I’m pleased to annonce that ocamlearlybird 1.0.0~beta1 just released. Will soon be available on opam.

ocamlearlybird is a debug adapter for OCaml language. It can let you debug your ocaml program in vscode like debugging javascript.

This is a big step that we toward 1.0.0. We solved lots of issues and tested with realy ocaml projects such as utop, ocamlformat, and so on. And certainly, it can debug ocamlearlybird itself.

I’m so sorry. Because of my network issue. I can’t upload screen record video to demo it. So, try yourself!

NOTES.

  • New version only support OCaml 4.11. If you need other versions support, please let me know.
  • Dune-release do not support 1.0.0~beta1 version string. So we released 1.0.0 as 1.0.0~beta1 on opam.

KNOWN ISSUES:

  • Continue run command may hit on last removed breakpoint once when debug utop.
21 Likes

Since the post has edited over 3 times. I can’t edit it anyway. I uploaded demo video here:

8 Likes

This looks outstanding! Will definitely reach for it next time I need a stepping debugger and will report on how I get on.

Hopefully some dune integration/visibility will come along eventually so that e.g. one can just pick a debug target from the set of executables described in a project’s dune files?

And just out of curiosity, what is the meaning of the “earlybird” naming?

1 Like

Yes, dune integration is planned.

It’s source from Chinese Proverbs “早起的鸟儿有虫吃” - translated text “Early birds had worms”.

/cc @cdaringe

3 Likes

Excellent! This is the first time I’ve successfully launched a debugger in ocaml on my own program :slight_smile:

The debugger attached on my first attempt! :tada:

This forum certainly isn’t an issue reporting venue, but

  • step into is still a bit jumpy, vs line by line when expected
  • check out the Variables pane–looks like Envaux_hack is filling the space. I wasn’t able to inspect my memory. perhaps something i messed up.

Anyway, great work

1 Like
  • Inspect problem:Try clean and rebuild
  • Step problem:You should use next instead of step in

This is great, thanks for your work!

I have one question: is it possible to change the way variables are displayed in the inspector by providing some custom printing functions? Right now, instances of my custom datatypes are just rendered as <<opaque>>. Also, I cannot see the elements within a list of strings (with type Base.String.t list):

There’s no way to use custom printers for now. But it’s in plan. And I wonder why it’s shown as <<opaque>>. If the underlying string type isn’t hidden. It should shown as string. Could you please paste the .mli of your custom datatypes here?

Regarding the rendering of string lists, I think the problem happens when I am using the JaneStreet standard library and the type inferred by merlin is Base.String.t instead of just string. For example, in the snippet below:

open Base

let () = 
  let list1 = [String.make 3 'a'] in
  let list2 = ["aaa"] in
  let array = [|"aaa"|] in
  ()

list1 is not inspectable but list2 is. Coincidentally, merlin displays the type of list1 as Base.String.t and the type of list2 as string.

Also, as revealed by this screenshot, inspecting arrays does not work. When I try to expand it, the debugger freezes (see the icon with circling dots). I also replicated the problem with other types of arrays.

Thank you for reporting. I’ll address them these days.

1 Like

I still wasn’t able to use this. I tried several projects, different systems, but everytime I start a debug session on VSCode nothing happens, the program doesn’t run, the buttons do nothing, no stack variables shown.

Have you installed earlybird on opam? And what will output if you exec ocamlearlybird in your shell?

I have it installed. When I start the debug session it runs the ocamlearlybird command in the integrated terminal but nothing happens and no output is given.

You may installed the old version. Please do opam update and opam upgrade earlybird.

The earlybird version I have installed is the latest one.

OCaml 4.11 is the only supported version. Do you use other versions?

Run ocamlearlybird serve --verbosity=debug --port=4712 on your shell. And add debugServer: 4712 to your launch configration.

Paste logs of ocamlearlybird here, then I can see what happened.

Yes, I’m using 4.11. Here you have the logs ocamlearlybird: [INFO] Debug adapter server listening at port 4712ocamlearlybi - Pastebin.com
It seems that he’s connecting and even pausing at breakpoints, but in the interface nothing happens. It says the call stack is paused on entry, and shows no variables nor call stack.

A stupid guess: there are two “OCaml Debugger” extensions by hackwaly; could it be you have the wrong one? (iiuc, the one with no icon and less downloads is the right one)

1 Like

I see it paused at entry. Do next or run button have no effects? “Stop on entry” is a bit different from other debuggers. It didn’t run any instruction and give you a chance to peek loaded modules and set breakpoints on them. So no callstacks and variables is expected result.

I have the correct version of the plugin installed. Now I got it, I was defining breakpoints on the source code instead of using the loaded scripts. Now I’m able to use everything.