简体   繁体   English

如何在发布模式下查看 Visual Studio 中的代码?

[英]How do I view code in Visual Studio in Release Mode?

When I change from debug to release mode in Visual Studio and the code is being optimized after debugging in Release Mode, can I see what the optimized code looks like?当我在 Visual Studio 中从 debug 模式切换到 release 模式并且代码在 Release 模式下调试后正在优化时,我能看到优化后的代码是什么样子吗? Or it is already a binary code that is optimized so Visual Studio itself doesn't optimize the code by rewriting it in C++, so there is no any C++ code that is my code but already rewritten for optimalization.或者它已经是经过优化的二进制代码,因此 Visual Studio 本身不会通过重写 C++ 中的代码来优化代码,因此没有任何 C++ 代码是我的代码但已经重写以进行优化。

The following works for both Debug and Release builds:以下适用于调试和发布版本:

  1. Set a breakpoint on the line(s) of interest.在感兴趣的行上设置断点。

  2. Launch your program under the debugger (F5).在调试器 (F5) 下启动您的程序。

  3. When your program breaks, right-click and select 'Go To Disassembly'.当您的程序中断时,右键单击并选择 select 'Go To Disassembly'。

But just to say, the code generated by the compiler in Release mode is not always easy to follow so be prepared for some surprises.但要说的是,编译器在 Release 模式下生成的代码并不总是容易理解,所以要做好一些意外的准备。


[Edit] As per @paddy's comment above, make sure that you compile your project with debugging information included, otherwise none of this will work properly: [编辑] 根据上面@paddy 的评论,确保您编译项目时包含调试信息,否则这些都无法正常工作:

Project properties -> C/C++ -> General -> Debug Information Format = Program Database (/Zi)

暂无
暂无

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

相关问题 Visual Studio:如何正确使用发布模式 - Visual studio: How to use release mode properly 如何在Visual Studio 2010中查看C ++函数的已编译机器代码或字节代码? - How do I view the compiled machine code or byte code for a C++ function in Visual Studio 2010? 运行时如何在 Visual Studio C++ 中确定调试或发布模式 - Runtime how to determine Debug or release mode in visual studio c++ Visual Studio 发布模式会阻止在调试模式下执行的代码执行。 使用 WinHTTP 和多线程 - Visual Studio release mode blocks code execution that is executed in debug mode. Using WinHTTP and Multi-Threading Visual Studio 2013 OMP发布模式 - Visual Studio 2013 OMP release mode Visual Studio Boost不包括在发布模式下 - Visual Studio Boost Not Including in Release Mode Visual Studio 发布模式 exe 文件是否独立? - Is the visual studio release mode exe file standalone or not? 我的Visual Studio 2012程序可在Debug(调试)中运行,而没有调试(ctrl + F5),但没有发布。 我该如何解决? - My Visual Studio 2012 program works in Debug, release without debug (ctrl + F5) but not release. How do I fix? 在 CMake 中,如何解决 Visual Studio 2010 尝试添加的调试和发布目录? - In CMake, how do I work around the Debug and Release directories Visual Studio 2010 tries to add? 如何让 OpenGL 在 Windows 上使用 Visual Studio Code? - How do I get OpenGL to work with Visual Studio Code on Windows?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM