Next Previous Contents

4. Other features

4.1 The debugger

Starting with version 0.9-15, a small debugger is integrated in LPU.

The debugger can be invoked at any time within a LPU program by inserting the command `.stop', which turns LPU into `single step mode'. And - starting with version 0.9-23 - pressing `CTRL-C' while a LPU program is running, will invoke the debugger, too.

In this mode, the next instruction and a prompt are printed to STDERR before the instruction is executed. The debugger then waits for input from STDIN, terminated by the ENTER key. It then evaluates the input and executes the corresponding command.

The following debugger instructions are defined:

?

A list of all available debugger commands is printed.

a VAR = EXPR

evaluates the expression `EXPR' and stores the result into variable `VAR'.

c

prints the calling stack of all procedures.

e EXPR

evaluates the expression `EXPR' and prints the result to STDERR.

g

Go. The single step mode is disabled, and the execution of the LPU program is resumed with the current instruction. This leaves the debugger and returns control back to the runtime system.

q

Quit. Stops execution of the program and leaves LPU.

w EXPR {, EXPR }

Defines a list of EXPRessions, which shall be `watched'. For more details, see the LPU command `.watch'.

ENTER

An empty input (only the ENTER key), executes the next instruction of the program, and then comes back to the debugger before the following instruction.

The LPU command `.cont' disables the `single step mode', so that executing this instruction within the debugger is equivalent to the debugger instruction `g'.

4.2 Tracing

The debugger, which was described in the last section, is very helpful if you want to analyze what is going on in a special code section, but it is very boring if you must walk step by step through a very long program until you come to the section, where the error occurs.

This is where tracing comes in. The trace mode is enabled with the command `.tron' and disabled with the command `.troff'.

When trace mode is active, every LPU instruction is printed to STDERR, before it is executed. This should lead fast to the point where the error occurs. Now, you can place a `.stop' command at the beginning of the offending section of code and inspect what is going on with the debugger.

The command `.debug' is very useful in this respect; details are described in the section on dot commands.


Next Previous Contents