History editing and tab completion for ocamldebug

Here’s the PR.

I tested it and it works.

Unlike with my last PR, where I facepalm-ed heavily, I don’t think the functionality exists in ocamldebug as of right now!

It has been addressed before with a much simpler workflow: request: ocamldebug: toggle to previous commands with arrow keys? · Issue #9382 · ocaml/ocaml · GitHub; there’s prior (rejected) art trying to do something similar to the toplevel in Add optional editline support by jwatzman · Pull Request #241 · ocaml/ocaml · GitHub; cf. also the use of rlwrap around the toplevel added in Makefile: a 'runtop' target to build and run the toplevel by gasche · Pull Request #344 · ocaml/ocaml · GitHub.

It’s worth either searching (or getting Claude et al to search) for prior art before letting it code, just as it’s worth doing that when coding artisanally!

Incidentally, from https://claude.ai/share/db110dc6-7e53-4f54-8087-e92236239eb4:

How can I get command line history and tab completion in ocamldebug?

Using rlwrap (recommended)

The simplest approach is to wrap ocamldebug with rlwrap:

bash

rlwrap ocamldebug your_program
1 Like

I see no difference between coding artisanally, something I’ve been doing for 30+ years, and using AI to code for me.

With one big fat caveat… It’s my own responsibility to supervise the AI and make sure it produces great code, the kind of code I would have written artisanally! I own the resulting code and I’m responsible for it.

And AI can produce solid OCaml code, something that I have discovered recently.

No, I do not want to use workarounds like rlwrap. I want proper editing and history browsing, like in lldb and gdb.

Yes, I am upset that the DWARF PR has been rejected in 2016 and that I’m forced to use 0xCaml which has it implemented in 2025. I’m grateful to Jane St for their efforts but would rather use stock OCaml instead.

Would I fork ocamldebug as suggested in the PR review? Probably. Development of earlybird has stalled and it may be the best focus of my debugging attention.