caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Matej Kosik <mail@matej-kosik.net>
To: Ocaml Mailing List <caml-list@inria.fr>
Subject: [Caml-list] a question about "ocamldebug" and the "install_printers" command
Date: Sun, 1 Dec 2019 22:13:00 +0100	[thread overview]
Message-ID: <83147091-b2de-7176-2b2d-80552c76314c@matej-kosik.net> (raw)

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

Hi,

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:

  make
  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 main.ml, 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>

instead?

Is this an expected behavior?
What am I missing?

I always see

  <abstr>

even when I try reinstall the relevant printer:

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

Thank you in advance for any hints,

Cordially,
--
Matej Kosik

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

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

;;

debug ()

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

module Submodule :
sig

  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"

end

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 : %.ml
	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 --]

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

                 reply	other threads:[~2019-12-01 21:13 UTC|newest]

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

Reply instructions:

You may reply publicly 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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=83147091-b2de-7176-2b2d-80552c76314c@matej-kosik.net \
    --to=mail@matej-kosik.net \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).