Using gprof 2.28 and gcc 6.3.0 in Ubuntu 17.04 on a variety of sample programs I get empty output for every category. If I run gprof -i on one example program I get:
1 histogram record
2 call-graph records
0 basic-block count records
My compilation looks something like this:
cc -g -c sem_test.c -pg
cc -o sem_test sem_test.o -lpthread -pg
Or this:
gcc -g3 -O0 -Wall -std=gnu99 -pg -fprofile-arcs -fno-inline -fno-reorder-functions sem_test.c -o sem_test -lpthread -pg
Both have the same results.
I notice that my gmon.out file is only 687 bytes which seems low.
sem_test.c
does almost nothing, or that what it does is almost exclusively waiting for something from the system, like a semaphore or I/O. gprof can only take samples every .01 seconds, which is like every 10^7 instructions, and that only when the program is actually computing, not waiting. – Mike Dunlavey