views:

18

answers:

1

There are compiler options in MSVC to enable the automatic generation of instrumentation calls on entering and exiting functions. These hooks are called _penter() and _pexit(). The options to the compiler are:

/Gh Enable _penter Hook Function

/GH Enable _pexit Hook Function

Is there a pragma or some sort of function declaration that will turn off the instrumentation on a per function basis? I know that using __declspec(naked) functions will not be instrumented but this isn't always a very practical option. I'm using MSVC both on PC and on a non-X86 platform and the non-X86 platform is a pain to manually write epilog/prolog in assembler (not to mention it messes up the debugger stack tracing).

If this in only on a per file (compiler option) basis, I think I will have to split out the special functions into a separate file to turn the option off but it'd be much easier if I could just control it on a per file basis.

The fallback plan if this can't be done is to just move the functions to their own CPP translation unit and compile separately without the options.

+1  A: 

I don't see any way to do this. Given that you would have to locate and handle every affected function anyway, perhaps moving them into their own module(s) is not such a big deal.

Steve Townsend
I was hoping for a simple thing like __declspec(dontinstrument) or something like that.
Adisak
@Adisak - right - I don't think there is anything to do this, though.
Steve Townsend
Yeah... I didn't see another way to do it myself. But it can't hurt to ask.
Adisak