获取ac#程序编译后的asm
可能的重复:
检索 JIT 输出
这是否可以做到,如果可以的话如何做(我需要在其 JIT 后我想,但我不知道该怎么做)?
Possible Duplicate:
Retrieve JIT output
Is this possible to do, and if so how (I would need to be after its JITed i think, but I have no idea how to go about doing this)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 Visual Studio 调试器查看即时编译的程序集(调试 -> Windows -> 反汇编)。
如果您在已附加调试器的情况下启动程序(在 Visual Studio 中按 F5),那么您将看到抖动检测到这种情况时生成的程序集的非优化版本。
如果您需要优化的非调试版本的 jitted 程序集,那么您需要在发布模式下编译程序并在不附加调试器的情况下启动它(在 Visual Studio 中Ctrl+F5)。一旦您知道所需的代码部分已经被抖动,则将调试器附加到正在运行的进程。然后您可以中断并查看抖动的装配体。
You can view the jitted assembly with the Visual Studio Debugger (Debug -> Windows -> Disassembly).
If you start the program with the debugger already attached (F5 in Visual Studio) then you'll see the non-optimised version of the assembly that's generated when the jitter detects such a situation.
If you need the optimised, non-debug version of the jitted assembly then you'll need to compile your program in Release mode and start it without the debugger attached (Ctrl+F5 in Visual Studio). Then attach the debugger to the running process once you know that the required section of code has already been jitted. Then you can break and view the jitted assembly.
.NET 使用即时编译器。直到最后一刻,即方法开始执行之前,才会生成机器代码。这使得“捕获 ASM”变得相当困难。
如果您只是对它的外观感兴趣,那么在调试时右键单击源代码窗口并选择“转到反汇编”。在调试发布版本并使用“工具+选项”、“调试器”、“常规”重新启用 JIT 编译器优化器之前,您不会看到“真实”机器代码。
另一种选择是运行 ngen.exe,即 .NET 的“预编译器”。 foo.dll 程序集将在 c:\windows\Assembly 或 c:\windows\microsoft.net\Assembly 目录中生成 foo.ni.dll 程序集。此 .ni.dll 映像文件包含抖动的机器代码。
.NET uses a just-in-time compiler. The machine code isn't generated until the last possible moment, just before a method starts executing. That makes it pretty difficult to 'capture the ASM'.
If you are just interested in what it looks like then right-click the source code window while debugging and select "Goto Disassembly". You are not looking at the 'real' machine code until you debug the Release build and re-enable the JIT compiler optimizer with Tools + Options, Debugger, General.
Another option is to run ngen.exe, the 'pre-compiler' for .NET. A foo.dll assembly will produce a foo.ni.dll assembly in the c:\windows\assembly or c:\windows\microsoft.net\assembly directory. This .ni.dll image file contains the jitted machine code.