ocaml / ocaml/dune

Byte target can't be debugged with ocamldebug

Open
#4,347 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

build
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

Expected Behavior

dune build should produce a byte target for https://github.com/disposedtrolley/hello_ocaml which is able to be debugged with ocamldebug. A breakpoint should be able to be set on line 2 of the helloworld module.

Actual Behavior

While dune build is able to build a .bc file, it seems to be missing debug symbols. For example, attempting to set a breakpoint on line 2 of helloworld.ml results in:

hello_ocaml · (main) ⟩ ocamldebug _build/default/helloworld.bc                         ~/p/o/hello_ocaml 2
        OCaml Debugger version 4.12.0

(ocd) break @helloworld 2
Loading program... done.
Can't find any event there.
(ocd)

When the project is built with ocamlc -g helloworld.ml, the resulting a.out file can be debugged with ocamldebug correctly.

Reproduction

  • PR with a reproducing test:
  1. Clone https://github.com/disposedtrolley/hello_ocaml
  2. Run dune build
  3. Run ocamldebug _build/default/helloworld.bc
  4. Type break @helloworld 2
  5. Observe that the debugger outputs "Can't find any event there."

Specifications

  • Version of dune (output of dune --version): 2.8.4
  • Version of ocaml (output of ocamlc --version) 4.12.0
  • Operating system (distribution and version): Fedora 33 (x86), macOS 11.2 (arm64)

Additional information

I've tried this with OCaml 4.12 (on macOS with Apple Silicon) and 4.10.2 (on macOS with Apple Silicon and Fedora 33 x86).

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the hello_ocaml project using dune build, then run ocamldebug _build/default/helloworld.bc and the breakpoint command against helloworld.ml. Compare this with the ocamlc -g helloworld.ml result; done means a breakpoint can be set on line 2 of the helloworld module.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.