This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

changing profiling in Cygwin


The current code to do profiling has a few quirks that I'd like to fix, but 
there is a small timing issue with gcc and cygwin releases.

Here's how profiling works on a typical OS: you specify -pg, gcc links in
gcrt0.o as the first object file; gcrt0.o will normally invoke monstartup
at program startup, either via .init section if available or some other
means such as OS specific global constructor mechanism. It'll also provide 
a way to call mcleanup at termination. GCC doesn't need to do anything.

Cygwin profiling works in subtly different way -- gcrt0 doesn't use .init
since it's not available under win32 as such, and to call monstartup at
startup, GCC emits a call to monstartup when it compiles a function named
"main". This has some problems -- it only works when you do have main() 
that you yourself compiled; this loses for g77 for example where main() 
comes precompiled in a library; loses for windows applications that don't
have a user "main"; also you lose all the profiling from global 
constructors in C++.

I propose the following simple solution (and I have a working prototype
of course): undo GCC change to look for "main", and instead use 
constructor/destructor function attributes in GCC to kick off monstartup
at startup and mcleanup at termination.

This solution is clean, but it implies that Cygwin and GCC releases are
perfectly timed, which is unreasonable to expect. To fix this, we can
add a switch -mold-profile to be used with -pg to use Cygwin's current 
scheme and -pg alone will use the new scheme. Eventually, we'll deprecate 
-mold-profile and then remove it in due time.

Comments?

Regards,
Mumit


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]