Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Mac Programming / March 2008



Tip: Looking for answers? Try searching our database.

gprof bug on Mac OS X?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sungmin Cho - 19 Oct 2005 10:35 GMT
With Mac OS X, I gcc and gprof.
But the result is as follows.

%   cumulative   self              self     total
time   seconds   seconds    calls  ms/call  ms/call  name
 0.0       0.00     0.00        2     0.00     0.00  __Z5func1v [33]
 0.0       0.00     0.00        1     0.00     0.00  __Z5func2v [34]
 0.0       0.00     0.00        1     0.00     0.00  _main [35]

The time is always 0.0. With Linux/cygwin I can get some numbers other
than 0.0.
What's wrong with this?
Michael Ash - 19 Oct 2005 16:02 GMT
> With Mac OS X, I gcc and gprof.
> But the result is as follows.
[quoted text clipped - 8 lines]
> than 0.0.
> What's wrong with this?

I don't know the answer to your question, but I would like to suggest an
alternative. Apple's Shark profiler works well (or at least it should!)
and I personally find it to be greatly superior to any other profiler I've
used, although it is a sampling profiler rather than an instrumented
profiler (I hope that's the right term), so it's not exactly the same
thing.

Shark is part of the CHUD tools which are an optional install with the
developer tools, or which can be downloaded separately here:

http://developer.apple.com/tools/download/

Signature

Michael Ash
Rogue Amoeba Software

Greg - 27 Oct 2005 15:29 GMT
> > With Mac OS X, I gcc and gprof.
> > But the result is as follows.
[quoted text clipped - 20 lines]
>
> http://developer.apple.com/tools/download/

Then you probably haven't tried Saturn. :)

Saturn is Apple's adoption of gprof and offers much the same GUI
analyses as Shark does; but since the program being profiled collects
its own profiling data (in addition to the sampling), the results are
both a more detailed - and a more accurate - description of the
profiled application's execution.

Greg
Michael Ash - 27 Oct 2005 23:01 GMT
>> I don't know the answer to your question, but I would like to suggest an
>> alternative. Apple's Shark profiler works well (or at least it should!)
[quoted text clipped - 9 lines]
>
> Then you probably haven't tried Saturn. :)

You are remarkably perceptive! :)

> Saturn is Apple's adoption of gprof and offers much the same GUI
> analyses as Shark does; but since the program being profiled collects
> its own profiling data (in addition to the sampling), the results are
> both a more detailed - and a more accurate - description of the
> profiled application's execution.

I personally prefer sampling profilers, since it seems that the
instrumentation would skew the results less overall. I also don't think
that you can get a Shark-like view which displays the proportionate amount
of time spent on each line of code or assembly instruction if you're using
gprof data, although I would be happy to be wrong in this case. But
whatever you prefer, more options and more cool tools are always good to
have. Thanks for pointing it out.

Signature

Michael Ash
Rogue Amoeba Software

Greg - 27 Oct 2005 15:31 GMT
> With Mac OS X, I gcc and gprof.
> But the result is as follows.
[quoted text clipped - 8 lines]
> than 0.0.
> What's wrong with this?

You forgot to link in the appropriate runtime library. "gcrt1.o" (or
something along those lines), check the gprof man page for the
appropriate library.

Greg
something_appropriate - 07 Mar 2008 01:01 GMT
>With Mac OS X, I gcc and gprof.
>But the result is as follows.
[quoted text clipped - 6 lines]
>
>The time is always 0.0.

I realize that my reply is being posted several years after the original
question.  However, I have been having this same mac osx xcode gprof problem
all day long so I thought I would post what I found on as many forums as
possible (within the next 10 minutes anyway).

gprof only works on the Mac if you are NOT using an Intel mac.  If you are
using an Intel Mac, then STOP WASTING your time trying to fix the  gprof "all
zero seconds" problem.  Apple says that gprof does not work for the Intel Mac.

Saturn is what you want to use.  People may have told you to use Shark, but
shark does sampling, which is not what gprof does.  Saturn is much more
similar to Shark.

go to
developer.apple.com

search for Shark (this is part of Developer Performance Tools "CHUD Tools").

Find and download SaturnUserGuide.pdf (2007-10-31  Copyright 2007 Apple Inc.
All Rights Reserved).

You will have to use this flag:
-finstrument-functions

I am using that flag under "C flags" and under "linker flags" (in Target Info
"Build" tab)

ALSO: you have to GET RID OF the "-pg" flag that you were probably trying to
use when you still thought there was hope to get gprof working.
something_appropriate - 07 Mar 2008 17:29 GMT
arg !!

I typed Shark where I meant to type Saturn.  Wow, that almost completely
undermined my point....

Where I said:

>> go to
>> developer.apple.com
>>
>> search for Shark

I MEANT TO SAY:

>> go to
>> developer.apple.com
>>
>> search for SATURN

>>With Mac OS X, I gcc and gprof.
>>But the result is as follows.
[quoted text clipped - 31 lines]
>ALSO: you have to GET RID OF the "-pg" flag that you were probably trying to
>use when you still thought there was hope to get gprof working.
something_appropriate - 07 Mar 2008 17:36 GMT
OMG.

I just noticed another big, idiotic typo in my original post.  I was so
frazzled and exhausted yesterday after struggling with the mac version of
gprof I clearly could not type straight.

Where I wrote:

>> Saturn is much more similar to Shark.

I MEANT TO SAY:

>> Saturn is much more similar to gprof.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2010 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.