Program profiling problems, and a solution via machine language rewriting

The executable binary image of a program can be mechanically rewritten to produce a second program that collects execution statistics as a side effect, while executing the same routines and producing the same primary outputs as the original program. We describe a general technique and present our experiences with several alternate profiling mechanisms. The challenges of presenting the profile information in easily-used. understandable ways are also discussed.