[英]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:以下适用于调试和发布版本:
Set a breakpoint on the line(s) of interest.在感兴趣的行上设置断点。
Launch your program under the debugger (F5).在调试器 (F5) 下启动您的程序。
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.