On Sun, Dec 02, 2001, Oleg Goldshmidt wrote about "Re: Problems when linking against 
the profiled libc":
> "Nadav Har'El" <[EMAIL PROTECTED]> writes:
> > By the way, when profiling, you should also use "-g". 
> Not true. You should use your normal compilation options. In
> particular, you might be interested in profiling optimized code
> without extra debugging information.

I stand by my original statement (which anyway was just a comment, in
addition to the solution of the original problem).

I explained why -g is needed for the last part of the gprof output, which
for each function tells you which file it comes from. This part is wrong
if you don't compile with -g (try it!), and this part is very useful when
you profile a program or library with many identically-named static functions
(e.g., openssl - one of the most obfuscated libraries I've seen).

We're talking about Linux, by the way, so we're talking about gcc, and in
gcc you can combine -g with -O if you want - the optimization is done
as usual regardless if you use "-g" or not. "-g" only adds a bit more
source file/line information to the object file, and doesn't change in any
way the code generation, running times, or anything except the size of the
executable (which is irrelevant in any non-trivial run).

So to summarize, if you're profiling with linux+gcc, I see no reason why
not to add a -g to the compilation line, leaving whatever -O option you
had there. Almost everything will work without this -g, though, so if
you feel nervous about it, leave it out...

> You need -g if you want to do line-by-line profiling (rather than
> function-by-function), because -g is what is tracking source code
> lines. Check gprof's info pages.

and source *files*. I never said this -g is of absolute importance - gprof
will work without it - but it's nice to have correct (rather than *wrong*)
source file information in the gprof output.

Nadav Har'El                        |      Sunday, Dec  2 2001, 17 Kislev 5762
[EMAIL PROTECTED]             |-----------------------------------------
Phone: +972-53-245868, ICQ 13349191 |This '|' is not a pipe.
http://nadav.harel.org.il           |

To unsubscribe, send mail to [EMAIL PROTECTED] with
the word "unsubscribe" in the message body, e.g., run the command
echo unsubscribe | mail [EMAIL PROTECTED]

Reply via email to