I’m having trouble running gprof on OS X. The file test.c is:
#include <stdio.h>
int main() {
printf("Hello, World!\n");
return 0;
}
and my terminal looks like:
$ gcc -pg test.c
$ gcc -pg -o test test.c
$ ./test
Hello, World!
$ gprof test
gprof: file: test is not of the host architecture
Edit: also, it doesn’t generate the file gmon.out.
What’s going on here?
The series of events here is supposed to work as follows:
-pgoption-pgoptiongmon.outfilegprofThe problem is that step 4 never happens. There’s very little information out about this specific failure. The general consensus over the past few years seems to be that Apple would rather use shark instead, and they’ve been very lax about fixing bugs and such with
gprof.In short: Install Xcode,
man shark