6.5 Debugger

A debugger is a tool which helps you to find programming errors. The idea of a debugger is that you can follow the programs execution interactively. At each time point you get informed about:

Code has to be compiled differently to make all information accessible to the debugger. This may have a lot of consequences. For instance, it may happen that an error does no more occur or that new errors arise.

You can use the debugger from the interactive user interface. It sees all those chunks of codes that were fed after the debugger was started. This means that you may have to fed some code again in order to recompile it so that it becomes accessible to the debugger.

You can also use the debugger to observe error free programs. Try it for instance with the following program to see the stack of procedure calls that is computed.

%%    {Factorial N} = N * ... * 1
 
declare fun{Factorial N}
           if N==0
           then 1  
           else N*{Factorial N-1}
           end 
        end 
{Inspect {Factorial 3}}
{Inspect {Factorial 1111}}

Next use the debugger to find the error in the following program:

declare C = {NewCell unit}
{Inspect {Access C}}
{Assign C 5}
declare Old in {Exchange C Old Old+1}
{Inspect Old}


Denys Duchier, Claire Gardent and Joachim Niehren
Version 1.3.99 (20050412)