Oppolzer - Informatik / Stanford Pascal Compiler


Home       Lebenslauf       Schwerpunkte       Kenntnisse       Seminare       Kunden       Projekte       Produkte       Blog       Stanford Pascal       Kontakt

The Stanford Pascal Compiler / Evolution Steps

Back to Compiler main page

Improving PASSNAP for the NODEBUG case

When creating new features for the compiler or the P-Code translator, there are often situations when one of the two passes crashes during execution.

The compiler modules cannot be translated using the debug switch (D+), because they deliberately access arrays outside of the defined bounds in some cases etc., and this is not allowed for D+ modules.

So there was no chance up until now to get readable dumps from PASSNAP, when one of the compiler passes crashes.

I wanted to change this, so I did the following extensions to the P-Code translator:

Of course, all the relevant compiler passes and library modules have been recompiled, and PASSNAP was adjusted to the new module layout.

BTW: the following library modules are considered part of the "standard" Pascal runtime and should be used together with every Pascal program, although not every module will be needed in every single case:

To get good diagnose information in case of a runtime error in one of the compiler passes, I changed the PASRUNC EXEC (which runs the compiler) so that it calls the compiler passes using the following LOAD statement:

LOAD &1 PASMONN PASSNAP PASLIBX PASSTRX (ORIGIN 20580 RESET $PASENT CLEAR

The following file shows a PASSNAP output in the NODEBUG case. The Fibonacci program was changed to NODEBUG; in this case, a subrange domain error would not occur, so I inserted a check for the variable being positive, and if not, I wrote an explicit snapshot using $PASSNAP.

New Snapshot output in the NODEBUG case

If you look at the stack segment outputs, you will see that every stack segment starts with the 72 byte system save area; you can see the backward pointer at offset 4, the forward pointer at offset 8, RET address and EPA address at 12 and 16 and then the registers 0 to 12, starting from offset 20.

You can locate Pascal variables in the hex format dump of the STATIC CSECTs and stack segments by using the offsets printed in the compiler listing. The starting addresses of the areas are printed in the hex dump, too; but it is also the address where the hex dump starts printing hex digits. You only need to add the offset of the variable to the starting address of the relevant area.

Back to Compiler main page