The Profile Collection Toolkit (PCT) aims to help programmers understand the performance of their programs, and the programs of others. PCT pursues the goal of afterthought profiling -- profiling without any extra preparations or separate copies of binaries. PCT aims to avoid several pitfalls that prevent outright any profiling.
The toolkit provides several strategies (library and debugger-based) for collecting data, and a series of analysis scripts. PCT aims to have profiling reports that gracefully degrade with available debugging data. Depending on the collector, profiles can cover both the main program text and various shared libraries, and data can be a histogram or cover time windows or be a circular log, and so on. On Linux, a simple trick allows PCT to seamlessly merge kernel CPU time profiles with user-level CPU profiles to create whole system reports.
Late collection activation and early report generation are also a part of afterthought profiling. PCT supports simple dynamic library-based profile collection on systems with LD_PRELOAD. To activate profile collection on already running programs, we avoid hairy, system-specific code by using a debugger-controller, dbctl.
dbctl has a configuration/scripting language that allows users to specify context-specific debugger commands. These commands can, for example, write to a log file general program state, such as call stacks and function parameters. These general value samples can be culled together and analyzed providing a novel profiling capability. Alternately one may use dbctl to effect other sorts of scripted process control. dbctl was designed to handle large family trees of processes.