Module Core_kernel.Debug
Utilities for printing debug messages.
val eprint : Core_kernel__.Import.string -> Core_kernel__.Import.unit
eprint message
prints to stderrmessage
, followed by a newline and flush. This is the same asprerr_endline
.
val eprints : Core_kernel__.Import.string -> 'a -> ('a -> Sexp.t) -> Core_kernel__.Import.unit
eprints message a sexp_of_a
prints to stderrmessage
anda
as a sexp, followed by a newline and flush.
val eprint_s : Sexp.t -> Core_kernel__.Import.unit
eprint_s sexp
printssexp
to stderr, followed by a newline and a flush.
val eprintf : ('r, Core_kernel__.Import.unit, Core_kernel__.Import.string, Core_kernel__.Import.unit) Core_kernel__.Import.format4 -> 'r
eprintf message arg1 ... argn
prints to stderrmessage
, with sprintf-style format characters instantiated, followed by a newline and flush.
module Make : functor () sig ... end
Debug.Make
produces adebug
function used to wrap a function to display arguments before calling and display results after returning. Intended usage is:
val am : Source_code_position.t -> Core_kernel__.Import.unit
am
,ams
, andamf
output a source code position and backtrace to stderr.amf
accepts a printf-style format string.ams
accepts a message, value, and sexp converter for that value. Typical usage looks like:...; Debug.am [%here]; ...; Debug.amf [%here] "hello (%s, %s)" (X.to_string x) (Y.to_string y); ...; Debug.ams [%here] "hello" (x, y) <:sexp_of< X.t * Y.t >>; ...;
The
am*
functions output source code positions in the standard format "FILE:LINE:COL", which means that one can use a tool like emacs grep-mode on a buffer containing debug messages to step through one's code by stepping through the messages.
val ams : Source_code_position.t -> Core_kernel__.Import.string -> 'a -> ('a -> Sexp.t) -> Core_kernel__.Import.unit
val amf : Source_code_position.t -> ('r, Core_kernel__.Import.unit, Core_kernel__.Import.string, Core_kernel__.Import.unit) Core_kernel__.Import.format4 -> 'r
val should_print_backtrace : Core_kernel__.Import.bool Core_kernel__.Import.ref
should_print_backtrace
governs whether theam*
functions print a backtrace.