How to programmatically observe program execution?
wmf: DTrace and SystemTap can insert probes in code if you're only interested in certain parts. If you want basic-block-level or instruction-level coverage, look at Pin, DynamoRIO, or Valgrind.