如何查看优化的jitted .NET代码的反汇编? [英] How can I view the disassembly of optimised jitted .NET code?

查看:73
本文介绍了如何查看优化的jitted .NET代码的反汇编?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于某种原因,有时查看功能的优化编译器输出会很有用或有趣。



对于非托管C / C ++代码,我最喜欢的方法是在Release模式下编译,在感兴趣的函数中添加断点,运行并在遇到断点时在Visual Studio中查看反汇编。



我最近在C#项目中尝试了此操作,发现该技术无效。即使在发布模式下,我看到的反汇编显然也没有得到优化。我发现并禁用(在Visual Studio 2010中)调试...选项和设置...调试...常规...在模块加载时禁止JIT优化选项,大概使我更接近想要的东西现在,当我尝试运行它时,它会警告我,然后我无法使其停止在断点上,以便可以看到反汇编。



因此,如果我想查看针对某个功能的CLR(4.0)抖动的经过分解和优化的输出,最好的解决方法是什么?需要明确的是,我希望看到x86(最好是x86_64)的反汇编,而不仅仅是IL的反汇编(您可以在Reflector中看到)。

方案

当然,经过半天的时间寻找答案后,我在提出要求5分钟后便找到了答案。



<我接近了;我在问题中唯一缺少的步骤是,还必须在选项中取消选中启用我的代码。



完整的指南可在此处找到:< a href = http://blogs.msdn.com/b/vancem/archive/2006/02/20/535807.aspx rel = noreferrer> http://blogs.msdn.com/b/vancem/存档/2006/02/20/535807.aspx


For one reason or another, I sometimes find it useful or just interesting to look at the optimised compiler output for a function.

For unmanaged C/C++ code, my favourite way to do this has been to compile in Release mode, stick a breakpoint in the function of interest, run, and view the disassembly in Visual Studio when it hits the breakpoint.

I recently tried this with a C# project and discovered that that technique doesn't work. Even in Release mode, the disassembly I see is obviously not optimised. I found and disabled (in Visual Studio 2010) the "Debug ... Options and Settings ... Debugging ... General ... Suppress JIT optimization on module load" option, which presumeably gets me closer to what I want, only now it warns me when I try to run it, and I then can't get it to stop on a breakpoint so that I can see the disassembly.

So, if I want to see the disassembled, optimised output of the CLR (4.0) jitter for a function, what's the best way to go about that? To be clear, I'd like to see the x86 (or preferably x86_64) disassembly, not just the IL disassembly (which you can see in Reflector).

解决方案

Of course, after half a day of searching for the answer on this one, I find the answer myself 5 minutes after I ask on SO.

I was close; the only missing step from what I had in the question was that "Enable Just My Code" must also be unchecked in the options.

The full guide is available here: http://blogs.msdn.com/b/vancem/archive/2006/02/20/535807.aspx

这篇关于如何查看优化的jitted .NET代码的反汇编?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆