A preprocessor-based instrumentation technique wherein source code is
provided to a compiler that exposes data structures such as symbols,
types, expressions, etc. during the construction of the syntax tree in
order to analyze where possible defects might make it desirable to
instrument the code. Once a possible defect is detected in a segment of
code, information is stored in a PI file detailing what line or lines of
code to add, remove, or alter so that the code is instrumented to monitor
the code segments at runtime. The PI file and source code are then
provided to a preprocessor that uses the information in the PI file to
insert instrumentation into the source code prior to the construction of
a syntax tree. The now instrumented source code is used to build an
instrumented syntax tree, which is then compiled so as to produce
executable object code.