Debug

is a module that provides functions and commands to debug faulty programs and functions.

assert-balanced

macro

Macro

                        (assert-balanced form)
                    

raises an error if the memory balance (number of allocs - number of frees) isn't 0. Requires the flag --log-memory to be passed durng compilation.

check-allocations

dynamic

Dynamic

                        (check-allocations)
                    

will check the allocations made by the program immediately, raising a SIGABRT if it fails.

leak-array

external

(Fn [a] ())

leaks some memory. This function is useful for testing tools that detect leaks.

log-memory-balance!

external

(Fn [Bool] ())

memory-balance

external

(Fn [] Long)

memory-logged

macro

Macro

                        (memory-logged form)
                    

logs all calls to memory allocation within the form. Requires the flag --log-memory to be passed during compilation.

reset-memory-balance!

external

(Fn [] ())

sanitize-addresses

dynamic

Dynamic

                        (sanitize-addresses)
                    

instructs the compiler to sanitize addresses.

This might not work on all compilers, but reasonably new versions of GCC and Clang are supported.

trace

macro

Macro

                        (trace x)
                    

prints the value of an expression to stdout, then returns its value.