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

PASSNAP prints heap variables allocated by NEW and ALLOC

Heap variables allocated by the standard procedure NEW are printed by PASSNAP. If PASSNAP encounters a pointer variable during variable processing, it checks the value, that is: the address in the pointer variable. If it lies between the bounds of the allocated heap storage, it prints the contents of the heap storage; because pointers in Pascal are typed, this is done in the same way as for every other variable, that is: the variable is shown in Pascal notation.

Checking for heap boundaries is easy, because the "classical" heap in Stanford Pascal is a contiguous area of storage which is allocated in its maximum size at program start time.

Heap variables allocated by the new ALLOC function were not shown, because the addresses are outside the bounds of the "classical" Pascal heap storage.

I changed PASSNAP, so that, after checking for "classical" heap, it checks for ALLOC areas, too. This was done by creating a new function called CHKALLOC, which is implemented in PASLIBX. It walks through the list of heap segments and looks if the given address lies within one of the allocated heap segments; if so, it returns the address of the area, if the area is the beginning of an allocated segment and the address of the HANC, if the address is another address inside the HANC. In all other cases (address not in heap), it returns NIL. So a result, which is not NIL tells, that the address lies inside a heap segment and the heap storage can be accessed and printed.

PASSNAP was further extended

Here you have an example of a new Snapshot output; it was issued from a test version of the storage management routines in PASLIBX which did a SNAPSHOT at a certain place.

You will also see that the variables in this example come from separate modules (from PASLIBX and from the main module, which is called TESTDBG; the CSECT name is $PASMAIN).

Snapshot output with heap storage and multiple modules

Back to Compiler main page