gprof

Hello,

I cannot get gprof to give me reasonable output in QNX 6.2.1.

I compile my program with the appropriate cc flags, produce the gmon.out
file, but gprof shows 0% for every function.

Has anyone got any idea why?

Thanks in advance,

Robert.

Hi Robert,

Were you logged in as ‘root’ when you ran your program?
Timers are privileged so you must have root permissions.

Regards,
Barry

“Robert Muil” <r.muil@crcmining.com.au> wrote in message
news:cd7hio$5qf$1@inn.qnx.com

Hello,

I cannot get gprof to give me reasonable output in QNX 6.2.1.

I compile my program with the appropriate cc flags, produce the gmon.out
file, but gprof shows 0% for every function.

Has anyone got any idea why?

Thanks in advance,

Robert.

Barry,

Thank you for the suggestion, but unfortunately that did not help.

I still get 0% for everything.

Robert.

“OS Support” <os@qnx.com> wrote in message news:cd8n9m$4pg$1@inn.qnx.com

Hi Robert,

Were you logged in as ‘root’ when you ran your program?
Timers are privileged so you must have root permissions.

Regards,
Barry

“Robert Muil” <> r.muil@crcmining.com.au> > wrote in message
news:cd7hio$5qf$> 1@inn.qnx.com> …
Hello,

I cannot get gprof to give me reasonable output in QNX 6.2.1.

I compile my program with the appropriate cc flags, produce the gmon.out
file, but gprof shows 0% for every function.

Has anyone got any idea why?

Thanks in advance,

Robert.
\

Would it be possible for you to post a small example program
along with your compile options that demonstrates the problem.

Thanks,
Barry

“Robert Muil” <r.muil@crcmining.com.au> wrote in message
news:cdcjgj$39i$1@inn.qnx.com

Barry,

Thank you for the suggestion, but unfortunately that did not help.

I still get 0% for everything.

Robert.

“OS Support” <> os@qnx.com> > wrote in message
news:cd8n9m$4pg$> 1@inn.qnx.com> …
Hi Robert,

Were you logged in as ‘root’ when you ran your program?
Timers are privileged so you must have root permissions.

Regards,
Barry

“Robert Muil” <> r.muil@crcmining.com.au> > wrote in message
news:cd7hio$5qf$> 1@inn.qnx.com> …
Hello,

I cannot get gprof to give me reasonable output in QNX 6.2.1.

I compile my program with the appropriate cc flags, produce the
gmon.out
file, but gprof shows 0% for every function.

Has anyone got any idea why?

Thanks in advance,

Robert.


\

“OS Support” <os@qnx.com> wrote in message news:cdggit$2e0$1@inn.qnx.com

Would it be possible for you to post a small example program
along with your compile options that demonstrates the problem.

Thanks,
Barry

gproftest.c:

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void do_something (void) {
int ii;

for (ii = 0; ii < 1000; ii++) {
usleep (1000);
printf (".");
fflush (stdout);
}
}

int main (int argc, char **argv) {
printf (“doing something”);
do_something ();
printf ("\n");
return 0;
}

Compiled with:
cc -w9 -p -g gproftest.c -o gproftest

Run (as super user) with:
…/gproftest

Profiled with:
gprof gproftest gmon.out |less

Robert.

“Robert Muil” <> r.muil@crcmining.com.au> > wrote in message
news:cdcjgj$39i$> 1@inn.qnx.com> …
Barry,

Thank you for the suggestion, but unfortunately that did not help.

I still get 0% for everything.

Robert.

“OS Support” <> os@qnx.com> > wrote in message
news:cd8n9m$4pg$> 1@inn.qnx.com> …
Hi Robert,

Were you logged in as ‘root’ when you ran your program?
Timers are privileged so you must have root permissions.

Regards,
Barry

“Robert Muil” <> r.muil@crcmining.com.au> > wrote in message
news:cd7hio$5qf$> 1@inn.qnx.com> …
Hello,

I cannot get gprof to give me reasonable output in QNX 6.2.1.

I compile my program with the appropriate cc flags, produce the
gmon.out
file, but gprof shows 0% for every function.

Has anyone got any idea why?

Thanks in advance,

Robert.




\

Robert Muil wrote:

I cannot get gprof to give me reasonable output in QNX 6.2.1.
I compile my program with the appropriate cc flags, produce the
gmon.out file, but gprof shows 0% for every function.

Has anyone got any idea why?

I think that is reasonable for that given example. Remember that time
profiling is via statistical sampling (ie every clock tick see where the
program is at). Your example code spends (statistically speaking) most
(all!) of the time in usleep(), and not actually running user code (and
most of what is left is in libc, and we have no libc_p). Note that the
function call counts are correct (that is done by direct monitoring) - 1
call to main and 1 to your do_something().

If I take your example and add in some user code that actually does
CPU-intensive things itself (some nested for loops, math, etc) then I
start to see some times billed to the code itself:

Each sample counts as 0.001 seconds.
% cumulative self self total
time seconds seconds calls ns/call ns/call name
100.00 0.00 0.00 1000 1000.00 1000.00 really_do_something
0.00 0.00 0.00 1 0.00 1000000.00 do_something
0.00 0.00 0.00 1 0.00 1000000.00 main

But this does show your compile line and invocation does have profiling
enabled. So, on a real piece of code, you should get a better time
approximation … just remember it is statistical sampling.

Yes,

Thanks John - I get this also.

I don’t understand why I got a similar output for my proper code, but
perhaps I was doing something else wrong again.

Thanks alot for your help Barry and John.

Robert.

“John Garvey” <jgarvey@qnx.com> wrote in message
news:cdia6v$d5m$1@inn.qnx.com

Robert Muil wrote:
I cannot get gprof to give me reasonable output in QNX 6.2.1.
I compile my program with the appropriate cc flags, produce the
gmon.out file, but gprof shows 0% for every function.

Has anyone got any idea why?

I think that is reasonable for that given example. Remember that time
profiling is via statistical sampling (ie every clock tick see where the
program is at). Your example code spends (statistically speaking) most
(all!) of the time in usleep(), and not actually running user code (and
most of what is left is in libc, and we have no libc_p). Note that the
function call counts are correct (that is done by direct monitoring) - 1
call to main and 1 to your do_something().

If I take your example and add in some user code that actually does
CPU-intensive things itself (some nested for loops, math, etc) then I
start to see some times billed to the code itself:

Each sample counts as 0.001 seconds.
% cumulative self self total
time seconds seconds calls ns/call ns/call name
100.00 0.00 0.00 1000 1000.00 1000.00 really_do_something
0.00 0.00 0.00 1 0.00 1000000.00 do_something
0.00 0.00 0.00 1 0.00 1000000.00 main

But this does show your compile line and invocation does have profiling
enabled. So, on a real piece of code, you should get a better time
approximation … just remember it is statistical sampling.