We use the Sage++ class library and restructuring toolkit to manipulate pC++ programs and insert the necessary profiler instrumentation code at the beginning of each function. The Instrumentor consists of three phases: 1) read the parsed internal representation of the program, 2) manipulate the program representation by adding profiling code according to an instrumentation command file, and 3) write the new program back to disk. Sage++ provides all the necessary support for this type of program restructuring.
By default, every function in the pC++ input files is profiled. However, the user can specify the set of functions to instrument with the help of an instrumentation command file. The file contains a sequence of instrumentation commands for including/excluding functions from the instrumentation process based on the file or class in which they are declared, or simply by their name. Filenames, classes, and functions can be specified as regular expressions.