I'm trying to profile DOSEMU using -pg, but I have a problem: the mcount() implementation here depends on GS being set to the value that libc (or the kernel) initialized it to. (Presumably, mcount() needs access to thread local state.)
However, DOSEMU has some signal handlers that might be called from DPMI context, where GS is presumably going to have a different setting, and the Linux kernel does not (cannot?) restore GS to it's former value for signal handlers.
Soo... I sought an __attribute__ to disable the instrumentation of these signal handlers, but the only one I could find, __attribute__((no_instrument_function)), does not seem to cover this case -- it neither overrides -pg, nor is it documented to do so.
Failing that, I sought a command-line flag to cancel the effect of -pg for just this subdirectory (or the file), but I couldn't find one of those, either.
Please add an __attribute__ for this, and perhaps a negative form of -pg as well.
__attribute__((no_instrument_function)) should do the trick. Maybe you need to
cover more functions with it?
Oh, hmm ... looks like you're right: I was looking at the wrong function in objdump -- possibly because the functions somehow came out in a different order in the object file from the source file.
Perhaps the documentation should be updated to mention that "no_instrument_function" applies even for -pg? Right now, http://gcc.gnu.org/onlinedocs/gcc-4.4.0/gcc/Function-Attributes.html only says:
If -finstrument-functions is given, profiling function calls will be generated at entry and exit of most user-compiled functions. Functions with this attribute will not be so instrumented.
Yeah, the docs could be clarified.