Perf is a performance measurement tool for the Linux kernel.
Finding Infinite Loops
Your program is in an infinite loop. You're not sure how you triggered it, and worry that if you kill the program you may not be able to trigger this bug easily. You want to know where the infinite loop is.
- Use the -p option of perf record, supplying the process id of your program. This will instruct perf to attach to your currently-running process.
perf record -p $(pidof myprogram)
- After a few seconds of recording, kill perf with Ctrl+C
- Run perf report. The report should clearly identify which functions are being executed in the loop.