This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Basic block profiling info for gprof
On 5/24/07, Nick Clifton <nickc@redhat.com> wrote:
Hi Mohamed,
> But compiling a code similar to the one given as a example in
> gprof.info and using gporf i am not getting any basic block profiling
> info.This is what i did
>
> a) $ gcc -g -pg 1.c
>
> After executing
>
> b) gprof -i
>
> c) gprof -l -A -x > output.gmon
>
> This is not providing any basic block profiling information.
What information does it produce ?
For gprof -i
File `gmon.out' (version 1) contains:
1 histogram record
1 call-graph record
0 basic-block count records
gprof -l -A -x > output.gmon produces the following for the test
case that i have given below
unsigned long updcrc(unsigned char* s, unsigned n)
1 -> {
register unsigned long c;
static unsigned long crc = (unsigned long)0xffffffffL;
1 -> if (s == NULL) {
1 -> c = 0xffffffffL;
} else {
1 -> c = crc;
1 -> if (n) do {
1 -> c = 0xfff + n;
1 -> } while (--n);
}
1 -> crc = c;
1 -> return c ^ 0xffffffffL;
1 -> }
This is wrong as the else block is executed at least 4 times (n = 4)
Which version of gcc are you using ?
I am using gcc 4.1.0
Which version of gprof are you using ?
GNU gprof 2.16.91.0.6
Is this a cross compiler or a native compiler ?
native compiler
For which target was the compiler configured ?
i386-redhat-linux
> Does gprof produce any basic block profiling information?
It should do. There may be a bug somewhere or possibly you need to
modify the procedure you followed. If you can provide a full test case
we may be able to investigate further.
The test case given below is a almost similar to the one given in
gprof.info in http://www.gnu.org/software/binutils/manual/gprof-2.9.1/html_chapter/gprof_5.html#SEC18
unsigned long updcrc(unsigned char* s, unsigned n)
{
register unsigned long c;
static unsigned long crc = (unsigned long)0xffffffffL;
if (s == NULL) {
c = 0xffffffffL;
} else {
c = crc;
if (n) do {
c = 0xfff + n;
} while (--n);
}
crc = c;
return c ^ 0xffffffffL;
}
int main()
{
char name[10]="Hello";
int k = 4;
unsigned long ret;
ret = updcrc(name,k);
printf("%lu\n",ret);
return 0;
}
Thanks for your time,
Regards,
Shafi