caml-list - the Caml user's mailing list
 help / Atom feed
From: Matej Kosik <>
To: Ocaml Mailing List <>
Subject: [Caml-list] a question about "ocamldebug" and the "install_printers" command
Date: Sun, 1 Dec 2019 22:13:00 +0100
Message-ID: <> (raw)

[-- Attachment #1: Type: text/plain, Size: 1811 bytes --]


I have a bug in my program.
I wanted to step through the computation with ocamldebug.
Since there are some abstract data types, I have defined some printers and took advantage of the "install_printer"
mechanism provided by "ocamldebug".

What surprised me was that the printers are invoked in some cases but not always.

The attached files represent the most simplest scenario that replicate the problem.

When I start debugging:

  ocamldebug main

the installed printers work as expected.

  rlwrap ocamldebug main
	OCaml Debugger version 4.08.1

  Executing file .ocamldebug
  Loading program... done.
  Time: 449
  Program exit.
  Breakpoint 1 at 158840: file, line 2, characters 3-53
  Time: 0
  Beginning of program.
  Time: 221 - pc: 158840 - module Main
  Breakpoint: 1
  2   <|b|>let _value = Aux.Submodule.value in
  File ./aux.cmo loaded
  (ocd) next
  Time: 222 - pc: 158860 - module Main
  3   <|b|>Aux.debug ()
  (ocd) p _value
  _value: Aux.Submodule.t = DEBUG: Aux.Submodule.pp

However, when I decent from one module to another, the printer no longer seems to be installed:

  (ocd) step
  Time: 223 - pc: 158668 - module Aux
  20   <|b|>let _value = Submodule.value in
  (ocd) next
  Time: 224 - pc: 158680 - module Aux
  21   <|b|>()
  (ocd) print _value
  _value: Submodule.t = <abstr>
  (ocd) install_printer Aux.Submodule.pp
  (ocd) print _value
  _value: Submodule.t = <abstr>

Above, I would expect to see

  _value: Aux.Submodule.t = DEBUG: Aux.Submodule.pp

Why do I see

  _value: Submodule.t = <abstr>


Is this an expected behavior?
What am I missing?

I always see


even when I try reinstall the relevant printer:

  (ocd) install_printer Aux.Submodule.pp
  (ocd) print _value

Thank you in advance for any hints,

Matej Kosik

[-- Attachment #2: --]
[-- Type: text/plain, Size: 82 bytes --]

let debug () =
  let _value = Aux.Submodule.value in
  Aux.debug ()


debug ()

[-- Attachment #3: --]
[-- Type: text/plain, Size: 300 bytes --]

module Submodule :

  type t
  val value : t
  val pp : Format.formatter -> t -> unit

end = struct

  type t = unit

  let value = ()

  let pp (fmt : Format.formatter) (_ : t) : unit =
    Format.fprintf fmt "DEBUG: Aux.Submodule.pp"


let debug () =
  let _value = Submodule.value in

[-- Attachment #4: Makefile --]
[-- Type: text/plain, Size: 201 bytes --]

main : aux.cmo main.cmo
	ocamlc -g -o main aux.cmo main.cmo

aux.cmo main.cmo : %.cmo :
	ocamlc -g -c $<

main.cmo : aux.cmo

clean :
	rm -f *.cmo main *.cmi

debug : main
	rlwrap ocamldebug main

[-- Attachment #5: .ocamldebug --]
[-- Type: text/plain, Size: 80 bytes --]

break Main.debug
goto 0
load "aux.cmo"
install_printer Aux.Submodule.pp

                 reply index

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publically to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

caml-list - the Caml user's mailing list

Archives are clonable: git clone --mirror

AGPL code for this site: git clone public-inbox