[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help-using gnu's gprof for getting profiling information
From: |
Stepan Kasal |
Subject: |
Re: help-using gnu's gprof for getting profiling information |
Date: |
Thu, 1 Apr 2004 10:51:05 +0200 |
User-agent: |
Mutt/1.4.1i |
Hello,
On Tue, Mar 30, 2004 at 08:11:00PM -0600, Rakesh M. Patel wrote:
> I am using gnu's gprof ...
OK, I tried it with a source file similar to your one:
$ cat test_prog.c
int increment(int x)
{
int y = 0;
int i = 0;
for(i = 0; i < 100; i++)
x=x+1;
return x;
}
main() {
int d;
increment(d);
}
Then I run these commands:
$ gcc-2.95 -o test_prog test_prog.c -g -pg -a
$ rm bb.out; ./test_prog
$ perl /usr/share/doc/binutils/gprof/bbconv.pl <bb.out >BB-DATA
$ gprof -A -l test_prog gmon.out BB-DATA
And the output was as expected:
*** File /home/kasal/test_prog.c:
int increment(int x)
1,1 -> {
int y = 0;
int i = 0;
101,1 -> for(i = 0; i < 100; i++)
100 -> x=x+1;
1 -> return x;
1 -> }
There are several pitfalls though:
1) It seems that new versions of gcc (3.2.3, 3.3, at least) don't
support -a.
2) OTOH, when the gcc is too old, like mine gcc-2.95.4, it outputs
the basic-block details into separate file bb.out; you have to transform
it by bbconv.pl, as described in the gprof manual.
3) You have to remove the old copy of bb.out before running the test program;
the results cumulate otherwise.
4) It might be better to use gprof without `-x', the output shows mor clearly
which lines are ``merged together''.
You might avoid the bb.out hassle by using a suitable version of compiler,
perhaps gcc 3.0.x. I haven't tried this.
Hope this helps,
Stepan Kasal
- Re: help-using gnu's gprof for getting profiling information,
Stepan Kasal <=