0

In ocamltop (after loading my file), I can run the following commands

#cd "/afs/csail.mit.edu/u/j/jgross/coq-HoTT/";;
#directory "/afs/csail.mit.edu/u/j/jgross/coq-HoTT/";;
#directory "/afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev";;
#use "dev/include";;
#trace <some_function>

But I cannot trace functions which are not exported, so I'd like to step through functions with ocamldebug instead. However, when I try to print what I want to see, I get things like f : Term.constr = <abstr>. So I would like to install the printers from the include file., which starts with

#cd ".";;
#use "base_include";;

#install_printer  (* pp_stdcmds *) pppp;;

#install_printer  (* pattern *) pppattern;;
#install_printer  (* glob_constr *) ppglob_constr;;

#install_printer  (* constr *) ppconstr;;
#install_printer  (* constr_substituted *) ppsconstr;;

and base_include looks approximately like

#cd".";;
#directory "parsing";;
#directory "interp";;
...

#directory "+camlp4";; (* lazy solution: add both of camlp4/5 so that *)
#directory "+camlp5";; (* Gramext is found in top_printers.ml *)

#use "top_printers.ml";;
#use "vm_printers.ml";;

#install_printer  (* identifier *) ppid;;
...

(* Open main files *)

open Names
open Term
open Typeops
open Term_typing
open Univ
...

So in ocamldebug, I try

(ocd) directory /afs/csail.mit.edu/u/j/jgross/coq-HoTT/
Directories : /afs/csail.mit.edu/u/j/jgross/coq-HoTT/ ...
(ocd) directory /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev
Directories : /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev ...
(ocd) use /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/include
Unknown command.
(ocd) source /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/include
Syntax error.
(ocd) source "/afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/include"
Syntax error.
(ocd) load_printer /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/include
Error during code loading: /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/include is not a bytecode object file
(ocd) load_printer top_printers.ml
Error during code loading: /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/top_printers.ml is not a bytecode object file
(ocd) load_printer top_printers
Cannot find file top_printers
(ocd) shell ls /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/
base_db           dynlink.cmx        ocamldebug-coq             set_raw_db         vm_printers.cmi
base_include      dynlink.ml         ocamldebug-coq.template    TODO               vm_printers.cmo
db                dynlink.ml.d       ocamldoc                   tools              vm_printers.ml
db_printers.ml    dynlink.o          ocamlopt_shared_os5fix.sh  top_printers.cmi   vm_printers.ml.d
db_printers.ml.d  header             printers.cma               top_printers.cmo
doc               include            printers.mllib             top_printers.ml
dynlink.cmi       macosify_accel.sh  printers.mllib.d           top_printers.ml.d
dynlink.cmo       Makefile.oug       README                     v8-syntax
(ocd) load_printer top_printers.cmi
Error during code loading: /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/top_printers.cmi is not a bytecode object file
(ocd) load_printer top_printers.cmo
Error during code loading: error while linking /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/top_printers.cmo.
Reference to undefined global `Pp'
(ocd) directory +camlp5
...
(ocd) directory +camlp4
...
(ocd) load_printer top_printers.cmo
Error during code loading: error while linking /afs/csail.mit.edu/u/j/jgross/coq-HoTT/dev/top_printers.cmo.
Reference to undefined global `Pp'

So how do I load these printers. (For reference, the directory structure is that of https://github.com/HoTT/coq.)

Jason Gross
  • 5,928
  • 1
  • 26
  • 53
  • I think you are close. `Pp` is located in the `coq` distribution under `lib/`, not in camlp4/5 --I am assuming that was the intent of including those directories? – nlucaroni Sep 27 '13 at 15:59
  • Yes. And when I traced the chain back up to the first undefined global, I ended up needing to `load_printer str`. And then I looked at the README, and discovered that I could just `source db` instead, and that would do everything for me. – Jason Gross Sep 27 '13 at 21:48

1 Answers1

0

It seems you are trying to use toplevel directives (lines beginning with #) in ocamldebug, which doesn't know anything about those. You have to speak to ocamldebug using debugger commands, for details of which see the ocamldebug documentation.

Loading and installing a printer looks something like this:

directory dependencies
load_printer "printers.cmo"
install_printer Printers.pp_thing

Note the explicit module names - there is no #use and no open. Also note that ocamldebug will search its list of directories for the dependencies of printers.cmo. If you get undefined global errors, you may need to add some entries to that list.

Once everything is working you won't want to type all of that junk again. Put it all in a file, say printers.debug, and load that with the source command:

source printers.debug
gsg
  • 9,167
  • 1
  • 21
  • 23