Thread View: comp.unix.programmer
7 messages
7 total messages
Started by jeniffer
Wed, 05 Apr 2006 09:51
Gprof not giving correct output as per man page option
Author: jeniffer
Date: Wed, 05 Apr 2006 09:51
Date: Wed, 05 Apr 2006 09:51
81 lines
3749 bytes
3749 bytes
cat b.c
------------------------
cat b.c
#include<stdio.h>
void F()
{
printf("ji");
}
void Fnotcalled()
{
printf("not calld");
}
int main()
{
F();
return 0;
}
--------------------------
$ gcc -pg b.c -o b
$ ./b
$ gprof -z -c -b b.o >file
cat file --->>
-----------------------------------------------------------------------------------------------------------
Flat profile:
Each sample counts as 0.01 seconds.
no time accumulated
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 1 0.00 0.00 main
0.00 0.00 0.00 F
0.00 0.00 0.00 Fnotcalled
^L
Call graph
granularity: each sample hit covers 4 byte(s) no time propagated
index % time self children called name
0.00 0.00 1/1 <hicore> (2)
[1] 0.0 0.00 0.00 1 main [1]
-----------------------------------------------
<spontaneous>
[3] 0.0 0.00 0.00 F [3]
-----------------------------------------------
<spontaneous>
[4] 0.0 0.00 0.00 Fnotcalled [4]
-----------------------------------------------
^L
Index by function name
(2) <hicore> [4] Fnotcalled
[3] F [1] main
~
-----------------------------------------------------------------------------------------------------------
but according to man page of gprof :
"-z"
"--display-unused-functions"
If you give the -z option, "gprof" will mention all
functions in
the flat profile, even those that were never called, and
that had
no time spent in them. This is useful in conjunction with
the -c
option for discovering which routines were never called.
"-b"
"--brief"
If the -b option is given, "gprof" doesnΓ’t print the
verbose blurbs
that try to explain the meaning of all of the fields in the
tables.
This is useful if you intend to print out the output, or
are tired
of seeing the blurbs.
Re: Gprof not giving correct output as per man page option
Author: rmansfield
Date: Wed, 05 Apr 2006 11:33
Date: Wed, 05 Apr 2006 11:33
8 lines
1575 bytes
1575 bytes
Sorry, what option do you claim is not working correctly? -b doesn't dump the verbose output so it clearly works. -z displays Fnotcalled which is never called so it clearly works. Regards, Ryan Mansfield
Re: Gprof not giving correct output as per man page option
Author: jeniffer
Date: Wed, 05 Apr 2006 11:40
Date: Wed, 05 Apr 2006 11:40
16 lines
1936 bytes
1936 bytes
rmansfield@gmail.com wrote: > Sorry, what option do you claim is not working correctly? > > -b doesn't dump the verbose output so it clearly works. > -z displays Fnotcalled which is never called so it clearly works. > > Regards, > > Ryan Mansfield I thought that I'll get only uncalled function names and not uncalled function names with called ones :( Its a disappointment since I wanted only function names that are not called or only function names that are called.
Re: Gprof not giving correct output as per man page option
Author: rmansfield
Date: Wed, 05 Apr 2006 12:38
Date: Wed, 05 Apr 2006 12:38
14 lines
1797 bytes
1797 bytes
Well -z does say "gprof will mention all functions in the flat profile, even those that were never called"... Easy solution: gprof -b b >file1 gprof -z -b b >file2 diff -u file1 file2 It would be almost trivial to modify gprof to have it print only the unused functions.. Regards Ryan Mansfield
Re: Gprof not giving correct output as per man page option
Author: Robert Bonomi
Date: Wed, 05 Apr 2006 13:39
Date: Wed, 05 Apr 2006 13:39
29 lines
2134 bytes
2134 bytes
In article <1144237223.367750.244560@g10g2000cwb.googlegroups.com>, jeniffer <zenith.of.perfection@gmail.com> wrote: > >rmansfield@gmail.com wrote: >> Sorry, what option do you claim is not working correctly? >> >> -b doesn't dump the verbose output so it clearly works. >> -z displays Fnotcalled which is never called so it clearly works. >> >> Regards, >> >> Ryan Mansfield > > >I thought that I'll get only uncalled function names and not uncalled >function names with called ones :( *WHY* would your think that? The documentation of the -z option, which you even _quoted- in your original post said that '-z' "causes ALL functions to be listed, even those that are not called" >Its a disappointment since I wanted only function names that are not >called or only function names that are called. obviously, the list of 'only are called' is easy to get. And, now you know that 'called plus un-called' is easy to get. Guess what you get if you apply 'diff' to those two lists. <grin>
Re: Gprof not giving correct output as per man page option
Author: Paul D. Smith
Date: Wed, 05 Apr 2006 13:50
Date: Wed, 05 Apr 2006 13:50
15 lines
2063 bytes
2063 bytes
%% bonomi@host122.r-bonomi.com (Robert Bonomi) writes: rb> obviously, the list of 'only are called' is easy to get. rb> And, now you know that 'called plus un-called' is easy to get. rb> Guess what you get if you apply 'diff' to those two lists. <grin> Apropos of not much, but "comm" is probably better suited to this task than diff. -- ------------------------------------------------------------------------------- Paul D. Smith <psmith@gnu.org> Find some GNU make tips at: http://www.gnu.org http://make.paulandlesley.org "Please remain calm...I may be mad, but I am a professional." --Mad Scientist
Re: Gprof not giving correct output as per man page option
Author: jeniffer
Date: Thu, 06 Apr 2006 06:30
Date: Thu, 06 Apr 2006 06:30
88 lines
3528 bytes
3528 bytes
rmansfield@gmail.com wrote:
> Well -z does say "gprof will mention all functions in the flat
> profile, even those that were never called"...
>
> Easy solution:
> gprof -b b >file1
> gprof -z -b b >file2
> diff -u file1 file2
>
> It would be almost trivial to modify gprof to have it print only the
> unused functions..
>
> Regards
>
> Ryan Mansfield
I did what you asked but its not giving the exact func names ..the
second command gprof -z -b b >file2 ,i think is creating problem ....I
also tried gprof for the follownig c program :
#include<stdio.h>
static void static_func()
{
printf(" inside static function ");
}
void f_called()
{
printf(" in f_called ");
}
void f_not_called()
{
printf(" in f_not_called ");
}
void Func_calling_static()
{
printf("\n in Func_calling static");
static_func();
}
/*void extern_func()
{
printf("\nhello");
}
*/
int main()
{
static_func();
// extern_func();
f_called();
Func_calling_static();
return 0;
}
~
gprof a1 |more
Flat profile:
Each sample counts as 0.01 seconds.
no time accumulated
% cumulative self self total
time seconds seconds calls Ts/call Ts/call name
0.00 0.00 0.00 1 0.00 0.00 static_func
........
Call graph (explanation follows)
granularity: each sample hit covers 4 byte(s) no time propagated
index % time self children called name
0.00 0.00 1/1 Func_calling_static
[4]
[1] 0.0 0.00 0.00 1 static_func [1]
-----------------------------------------------
Index by function name
[1] static_func
.........
Why f_called is not listed in the call graph ?
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads