* [Caml-list] a question about "ocamldebug" and the "install_printers" command
@ 2019-12-01 21:13 Matej Kosik
0 siblings, 0 replies; only message in thread
From: Matej Kosik @ 2019-12-01 21:13 UTC (permalink / raw)
To: Ocaml Mailing List
[-- 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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-01 21:13 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-01 21:13 [Caml-list] a question about "ocamldebug" and the "install_printers" command Matej Kosik
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).