I want to climb on the compiled application to see the optimizations produced by the jit compiler.

What programs to use to get a listing of the native code after passing jit and mapping them on the il-code instruction? Ideally, another would be mapping on a C # code.

    1 answer 1

    Start or join your application with the Visual Studio debugger, set the point in a place of interest, and when it works, select the menu item "Debug / Windows / Disassembly".

    The options for showing IL are not there. You can only tick the "Show source code" checkbox and then the mapping of machine and source code will be shown (in C #, VB.NET, or in another language in which you are programming).

    • one
      The phrase "in debug mode" is a little confusing - as far as I know, the code in debug and release will be very different. Although breakpoint can also be put in a release. PS: Sorry, there is no studio at hand, I will definitely try in the evening. - Qwertiy ♦
    • 2
      Then run the application without a debugger, and attach a debugger to it! In the “under debugger” mode and the truth, many optimizations are disabled. - VladD
    • @Qwertiy, yes, I wrote a little ambiguously initially - with normal, not debug builds, this naturally also works. Reformulated. - Sergey Rufanov
    • @VladD, and if a separate application is launched by the studio in debug mode, how to specify a project for it with source codes? - Qwertiy ♦
    • one
      JIT at the time of compiling IL into machine code checks for the presence of a debugger, and disables optimization (even if the code is compiled in Release!). The most reliable method is to call the System.Diagnostics.Debugger.Launch(); call System.Diagnostics.Debugger.Launch(); right in the code you want to see. And attach debugger after system dialog appears. Normal breakpoints do not always work (Unable to resolve breakpoint at ...) because when fully optimized, methods / properties often inline / flow are rebuilt and the line in cs may not find an exact match in the machine code. - PashaPash ♦