Locked SetILInstrumentedCodeMap generates wrong IL offset?

  • Monday, April 25, 2011 4:37 PM
     
     

    Hi.

     

    I use Profiling library to modify IL at runtime. In fact, I only add some IL stuff at the beginning of some methods.

    To be able to debug original code as before, I have to shift IL instructions of the amount of code I add at the beggining of the method (offset).

    I change IL code as soon as assemblies are loaded (AssemblyLoadFinished), but I have to wait method compilation to native to be done to retreive original offsets (JITCompilationFinished).

    Then, I remap every ilOffset (oldOffset of a COR_IL_MAP) to ilOffset + offset (newOffset of a COR_IL_MAP) calling SetILInstrumentedCodeMap, skipping prolog and epilog mapping.

     

    Problem is that I can see 3 lines in 'Disassembly' view within VS2010 when I debug non-instrumented code: '{', my first line of code and my second line of code (I only have two lines of code in the instrumented method of my testing project).

    When I debug the instrumented method (the same one), I have 18 ilOffset (+2 for prolog and epilog I do not care) that I shift with the same value: 84 bytes, I do not see any line for '{'. I see lines for my two code lines, but they are too far! What's wrong?

     

    Thanks for your help.

All Replies

  • Monday, May 23, 2011 2:56 PM
    Owner
     
     

    I am afraid this issue will take quite a bit of time to work on, and as such your question falls into the paid support category which requires a more in-depth level of support.  Please visit this link to see the various paid support options that are available to better meet your needs:  http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.


    --Trevor H.
    Send files to Hotmail.com: "MS_TREVORH"
  • Thursday, June 02, 2011 4:06 AM
     
     

    I may be able to help

    I use SetILInstrumentedCodeMap in JITCompilationStarted after I have updated the methodbody with a new instrumented method body (code coverage)

    you can find some sample code here

    https://github.com/sawilde/DDD2011_ProfilerDemo


     

  • Friday, June 24, 2011 4:41 AM
     
     

    Hi Ludovic

    Did you get an answer?

    I think under debug the first instruction is a NOP and this coincides with the first { - so i'd try and instrument the code such you map

    0 => 0

    1 =>  1 + offset