Retrieve JIT output

后端 未结 5 2065
Happy的楠姐
Happy的楠姐 2020-12-03 15:00

I\'m interested in viewing the actual x86 assembly output by a C# program (not the CLR bytecode instructions). Is there a good way to do this?

5条回答
  •  余生分开走
    2020-12-03 15:31

    You should use WinDbg with SOS/SOSEX, ensure that method you want to see x86 code for is JITted in method tables and then see actual unassembly with u command. Thus you would see actual code.

    As others mentioned here, with ngen you could see code that is not exactly matches actual JIT compilation result. With Visual Studio it is also possible because JIT's compilation depends heavily on the fact if debugger is present or not.

    UPD: Some clarification. WinDbg is a debugger also, but it is native one.

    Here you can read about the technique in detail.

提交回复
热议问题