Outdated egg!

This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.

If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.

  1. Outdated egg!
  2. trace
    1. Introduction
    2. Requirements
    3. Documentation
      1. trace
      2. untrace
      3. trace/untrace
      4. trace-module
      5. untrace-module
      6. break
      7. unbreak
      8. continue
      9. trace-output-port
    4. trace-verbose
    5. trace-length-limit
    6. trace-call-sites
    7. trace-call-site-length-limit
    8. License
    9. Version history



The extension provides traced execution of procedures and setting breakpoints on procedure entry.

This replaces the tracing facilities of CHICKEN versions prior to 4.2.12.


advice, miscmacros



[procedure] (trace [PROCEDURE ...])

Modifies the given procedures by printing some information on entry and exit. When given no arguments, (trace) lists all currently traced procedures.

Note that PROCEDURE may be any procedure and doesn't necessarily have to be a toplevel definition.


[procedure] (untrace [PROCEDURE ...])

Removes tracing from PROCEDURE ..., which should previously have been traced with trace. When given no arguments, (untrace) removes untraces all currently traced procedures.


[procedure] (trace/untrace PROCEDURE ...)

Toggles tracing on/off for the given procedures.


[procedure] (trace-module MODULENAME ...)

Traces all exported toplevel procedures of the modules with the names given in MODULENAME .... The module must already be loaded. Note that core-library modules can not be traced.


[procedure] (untrace-module MODULENAME ...)

Untraces all currently traced exports of the given modules.


[procedure] (break [PROCEDURE ...])

Modifies the given procedures to signal a condition on entry. The condition is of the kinds exn and breakpoint and will terminate execution unless caught. In the interpreter, the condition is accessible on the toplevel using the ,exn command. Use (continue) to continue execution. If no arguments are given, (break) lists all procedures that currently have breakpoints set.

Note that PROCEDURE may be any procedure and doesn't necessarily have to be a toplevel definition.


[procedure] (unbreak [PROCEDURE ...])

Removes breakpoints from the given procedures (or from all, if no arguments are given).


[procedure] (continue [CONDITION])
[procedure] (c [CONDITION])

Continues execution from the breakpoint that signalled CONDITION, or from the last breakpoint if CONDITION is not given.


[parameter] (trace-output-port [PORT])

Specifies the port to which tracing information should be written and defaults to the value of (current-output-port).


[parameter] (trace-verbose [BOOL])

If true (the default) show a message when enabling or disabling trace- or break-points for a procedure.


[parameter] (trace-length-limit [LIMIT])

This allows you to determine the maximum length of the part of the output that shows the traced procedure plus its arguments. LIMIT is a number of characters, or #f in case you don't want to limit it (the default).


[parameter] (trace-call-sites [BOOL])

If true, show call site information in the trace, which makes it easier to see where the procedure is called from. This information is taken from the trace buffer: it shows the most recent entry in that buffer, so this only works reliably if the call sites aren't optimised away and are compiled with -d2 or higher (and -no-trace is not used).

This option defaults to #f.


[parameter] (trace-call-site-length-limit [LIMIT])

When trace-call-sites is #t, this allows you to determine the maximum length of the call site text. LIMIT is a number of characters, or #f in case you don't want to limit it.

This option defaults to 100


This code is placed into the public domain.

Version history

Added trace-length-limit and added call site tracing (thanks to Matt Welland).
Changed trace-module to only trace exported procedures, not other objects.
Fixed scrutinizer warnings about procedure call with wrong argument count (#842, thanks to Mario Goulart).
added trace-module and untrace-module
added trace/untrace and trace-verbose
handles non-local exits correctly
fixed incorrect category
initial release