Source Level Traps

The Tesla Language compiler wrote an architecture independent intermediate text file that was passed on to a variety of code generators. I preprocessed this file to insert traps between every source statement and handled the traps with a simple and effective source level debugger.

Tesla generated three-address code in clusters separated by source-line boundaries. In scope variables and types could also be discovered.

I implemented the traps as a subroutine call to a register-preserving handler. Each trap was followed by several words of literal data.

The handler could inspect the literal data to determine the source line number and the address of a shared parameter block describing in scope variables.

The handler would adjust the return address so as to skip the fix-sided literal parameter data.

The handler would lock the bus and turn off interrupts to prevent any other processes from advancing while in the trap handler.

The handler printed line numbers as they were encountered and then paused for possible user intervention.

A space would resume execution until the next trap.

A dot would nop out the trap and then resume execution until the next remaining trap.

A "p" would print all in scope variables.

For example, stepping through the first few iterations of a loop and then printing the loop result might go like this:

6 7 8 9 10 11 8 9 10 11 8.9.10.11.12p count: 9 result: 12