[英]How do I view the compiled machine code or byte code for a C++ function in Visual Studio 2010?
What is the best (quickest) way to view the code that the compiler generated from my files? 查看编译器从我的文件生成的代码的最佳(最快)方法是什么? I'm using mostly C++ but a solution that works for .NET languages would be very welcome as well.
我主要使用的是C ++,但是也适用于.NET语言的解决方案。
Within Visual Studio, go to the property pages for your project, then go to C/C++ → Output Files → Assembler Output
. 在Visual Studio中,转到项目的属性页,然后转到
C/C++ → Output Files → Assembler Output
。 It should look something like this: 它应该看起来像这样:
Note the corresponding compiler switches, all variants of /FA
. 注意相应的编译器开关,
/FA
所有变体。
/FA
: Assembly-Only Listing /FA
:仅限大会列表 /FAcs
: Assembly, Machine Code and Source /FAcs
:装配,机器代码和来源 /FAc
: Assembly With Machine Code /FAc
:装配机器代码 /FAs
: Assembly With Source Code /FAs
:使用源代码进行汇编 Underneath the "Assembler Output" option there's an "ASM List Location" option. 在“汇编程序输出”选项下面有一个“ASM列表位置”选项。 This is equivalent to the
/Fa
switch (note capitalization!), and it sets the file path of the output listing. 这相当于
/Fa
开关(注意大小写!),它设置输出列表的文件路径。
You can also look at the assembly while debugging (at a breakpoint), complete with the corresponding source code, by right-clicking the current line in the source file text area and clicking "Go To Disassembly". 您还可以在调试时(在断点处)查看程序集,并使用相应的源代码,右键单击源文件文本区域中的当前行,然后单击“转到反汇编”。
It'll jump to the assembly at the line you right-clicked on in a separate tab. 它将跳转到您在单独选项卡中右键单击的行上的程序集。 The listing will resemble this:
列表将类似于:
Yes I know, the screenshots are not from Visual Studio 2010 but the steps and the general appearance are the same. 是的我知道,截图不是来自Visual Studio 2010,但步骤和一般外观是相同的。 I just don't have immediate access to VS2010 to make screenshots with.
我只是没有立即访问VS2010来制作截图。 :-)
:-)
对于.NET,您可以使用框架附带的ildasm
工具来查看IL。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.