BiglooA ``practical Scheme compiler''User manual for version 3.1aMay 2008

16. Bigloo A ``practical Scheme compiler'' User manual for version 3.1a May 2008 -- Tracing

main page

top: | Bigloo A ``practical Scheme compiler'' User manual for version 3.1a May 2008

Tracing

Chapters

Bigloo provides a trace facility whose is intended for simple debugging tasks. It is a replacement for user `display`s that clutters the source code. Here is a typical example using it:

    (define (foo x)
       (with-trace 1 'foo
          (let loop ((n x))
    	 (with-trace 2 'loop
    	    (trace-item "n=" n)
    	    (when (> n 0)
    	       (let liip ((m n))
    		  (with-trace 2 'liip
    		     (trace-item "m=" m))
    		  (when (> m 0)
    		     (liip (- m 1))))
    	       (loop (- n 1)))))))

    (foo 3)

which produces the following output:

    + foo
      |--+ loop
      |  |- n=3
      |  |--+ liip
      |  |  |- m=3
      |  |--+ liip
      |  |  |- m=2
      |  |--+ liip
      |  |  |- m=1
      |  |--+ liip
      |  |  |- m=0
      |  |--+ loop
      |  |  |- n=2
      |  |  |--+ liip
      |  |  |  |- m=2
      |  |  |--+ liip
      |  |  |  |- m=1
      |  |  |--+ liip
      |  |  |  |- m=0
      |  |  |--+ loop
      |  |  |  |- n=1
      |  |  |  |--+ liip
      |  |  |  |  |- m=1
      |  |  |  |--+ liip
      |  |  |  |  |- m=0
      |  |  |  |--+ loop
      |  |  |  |  |- n=0

Traces generation is controlled by a set of functions and parameters (see Parameters). The functions are described in this chapter.

with-trace level label . body | bigloo syntax

The variable `level` is the level of a trace. It is a positive integer. It enables simple filtering for traces. A trace is displayed if and only if the debugging level used to compile or to execute the program is greater than the trace level. The variable `label` is a label, .e.i., an identifier denoting the trace. This identifier will be displayed in debug mode. The variable `body` is the body of the form, that is, the expression to be evaluated.
Unless a trace is activated `(with-trace lv la body)` (when its level `lv` is greater than the current debug level) is equivalent to `(begin body)`. When traces are activated, before executing `body`.
The debugging level is controlled by two parameters: `bigloo-debug` and `bigloo-compiler-debug` (see Parameters).

trace-item . args | bigloo function

This function displays all its arguments. It has to be used nested in a `with-trace` form.

trace-bold s | bigloo function

trace-string s | bigloo function

These two functions are provided for convenience. They returns strings made of their parameters.

trace-color color . args | bigloo function

The `color` argument is a positive integer. This function returns a string which is the representation of `args` and that appears on the terminal in color `color`.
Colors can be enable or disabled using the `bigloo-trace-color` parameter (see Parameters).

trace-margin | bigloo function

trace-margin-set! | bigloo function

The `trace-margin` parameter is used to control the characters that are displayed in the margin of a trace. Usual applications should not use this. However, it may be convenient to set the margin by hands in some context. For instance, it can be used to distinguished threads in a multi-threaded application such as:

    (make-thread (lambda ()
                    (trace-margin-set! (trace-color 1 "="))
                    ...))
    (make-thread (lambda ()
                    (trace-margin-set! (trace-color 2 "="))
                    ...))

trace-port | bigloo function

trace-port-set! | bigloo function

These functions return and set the output port used by traces.

This Html page has been produced by Skribe.
Last update Wed May 28 08:36:19 2008.