The debugger is a very versatile tool and may be used to list the program statements executed or even the instructions. For long running programs, using the debugger to produce a trace is not practical. Indeed, the program will run perhaps as much as 100 times or more slower than usual.
Specialized tools exist for efficiently generating traces.
When the program exits, the content of all these counters is written to a file. Then, special tools are used to correlate this information with the C or assembly source code.