# Ocamldebug using dune

**URL:** <https://discuss.ocaml.org/t/ocamldebug-using-dune/15595>\
**Category:** Learning\
**Created:** [November 12, 2024, 1:05am UTC](https://discuss.ocaml.org/t/ocamldebug-using-dune/15595 "2024-11-12T01:05:27Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![jmid](https://avatars.discourse-cdn.com/v4/letter/j/eada6e/32.png) [@jmid](https://discuss.ocaml.org/u/jmid)\
**Post date:** [November 12, 2024, 11:36am UTC](https://discuss.ocaml.org/t/ocamldebug-using-dune/15595/3 "2024-11-12T11:36:26Z")

</div>

Elaborating a bit more on the initial reply:

First, note that `ocamldebug` only works with the bytecode backend.  
So remember to include the following line in your `dune` file

```auto
 (modes byte)

```

as [in the other post you linked to](https://discuss.ocaml.org/t/using-ocamldebug-with-dune/7878). Then pass the name of the bytecode executable to `ocamldebug`, e.g., `ocamldebug _build/default/merge_sort_mutable.bc`.

As for breakpoints, `dune` renames the main module under the hood to avoid name clashes. This can be controlled with [the option `wrapped_executables` in dune-project](https://dune.readthedocs.io/en/stable/reference/dune-project/wrapped_executables.html).  
You may therefore have to set a breakpoint on the renamed module with:

```auto
break @Dune __exe__ Main 21

```

Notice the `Dune __exe__ ` prefix with double, not single underscores.

I haven’t checked how your usage of the same name `merge_sort_mutable` for both a public `executable` and a `library` plays together with the above renaming. For a start, I would probably play it safe myself and use, e.g., `(public_name main)` until I got it working…

Finally, I also recommend having a look [at the ocamldebug chapter of the OCaml manual](https://ocaml.org/manual/5.2/debugger.html).

---

_[View the full topic](https://discuss.ocaml.org/t/ocamldebug-using-dune/15595)._
