The KHEPERA library tracks changes to the AST throughout the transformation process. The tracking is performed, automatically, at the lowest levels of AST manipulation: creation, destruction, copying, and replacement of individual nodes and subtrees. This tracking is transparent, assuming that the programmer always uses the KHEPERA AST-manipulation library, either via direct calls or via the KHEPERA transformation language, to perform all AST transformations. This assumption is reasonable because use of the KHEPERA library is required to maintain AST integrity through the transformation process. Since the programmer does not have to remember to add tracking capabilities to his transformations, the overhead of implementing debugging support in a DSL processor is greatly reduced.
The tracking algorithms associate the tree being transformed (Ti in Figure 1), the transformation rule () being applied, and the specific changes made to the AST. This information can then be analyzed to answer queries about the transformation process. For example, the DSL implementor may have identified two intermediate AST s, Ti and Ti+1, and may ask for a summary of the changes between these two AST s.
On a more sophisticated level, the user may identify a node in the DSL program and request that a breakpoint be placed in the program output. An example of this is show in Figure 11. Here, the user clicked on the scalar + node in the left window. In the right window, the generated program, after 13 transformations have been applied, is displayed, showing that the breakpoint should be set on the call to the vector add function.
At this point, the user could navigate backward and forward among the transformations, viewing the particular intermediate AST s which were involved in transforming the original + into the call to add. The ability to navigate among these views is unique to the KHEPERA system and helps the user to understand how the transformations changed the original program. This is especially useful when many transformations are composed.
The tracking algorithms can also be used to understand relationships between variables in the original and transformed programs. For example, in Figure 12, the user has selected an iterator variable i which was removed from the final transformed output. In this case, both occurrences of A are marked in the final output, showing that these vectors correspond, in some way, to the use of the scalar i in the original input.
In addition to the ``forward'' tracking, described here, KHEPERA also supports reverse tracking, which can be used to determine the current execution point in source terms, or to map a compile or run-time error back to the input source.