简体   繁体   English

如何在Visual Studio 2010中查看C ++函数的已编译机器代码或字节代码?

[英]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". 您还可以在调试时(在断点处)查看程序集,并使用相应的源代码,右键单击源文件文本区域中的当前行,然后单击“转到反汇编”。

gotodisassembly

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来制作截图。 :-) :-)

For a C++ project, compile with /FA to get an assembly listing. 对于C ++项目,使用/FA编译以获取程序集列表。

For .NET assemblies, there's ildasm . 对于.NET程序集,有ildasm

对于.NET,您可以使用框架附带的ildasm工具来查看IL。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在Visual Studio 2010中的C ++ googletest项目中设置代码覆盖率 - How do I set up code coverage in C++ googletest project in Visual Studio 2010 Visual Studio 2010 C ++代码格式化程序 - Visual Studio 2010 C++ code formatter 如何在 Visual Studio 2017 中无错误地打开 Visual Studio 2019 c++ 代码? - How do i open Visual Studio 2019 c++ code in Visual Studio 2017 without errors? Visual Studio 2015 TCHAR中已编译的旧版C ++代码 - Compiled Legacy C++ Code in Visual Studio 2015 TCHAR issues 当代码中不存在代码行时如何解决Visual Studio 2010 C ++中的错误C2719 - How to solve error C2719 in visual studio 2010 c++ when no code line exist in code 如何使Visual Studio 2015 C ++项目与Visual Studio 2010兼容? - How do I make a Visual Studio 2015 C++ project compatible with Visual Studio 2010? 使用Visual Studio 2010对嵌入式C ++代码进行单元测试 - Unit Test Embedded C++ Code using Visual Studio 2010 Visual Studio 2010本机C ++代码覆盖率着色不起作用 - Visual Studio 2010 Native C++ Code Coverage Coloring Not Working Visual Studio C ++ Express 2010-可以与非托管代码一起使用吗? - Visual Studio C++ Express 2010 - does it work with unmanaged code? 是否有用于格式化C ++代码的Visual Studio 2010加载项? - Is there any Visual Studio 2010 add-in for formating C++ code?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM