What's the best way to view accurate disassembly in VC++ 2010 while in Win32 Release mode?

不打扰是莪最后的温柔 提交于 2019-12-01 11:58:58

问题


I am writing assembly-level optimized code, and I need to make sure that the C++ compiler is working with it correctly in Release-Mode.

I used to be able to get Release-Mode programs to break on breakpoints in VS 2002 (and display the raw disassembly as I stepped through it), but I can't remember how I got that to work. Does VS 2010 have any options that might allow this to happen?


回答1:


Compile with /Zi and link with /DEBUG and you'll be able to set breakpoints.

Under a project's Properties dialog:

  • /Zi can be enabled in C++ --> General --> Debug Information Format

  • /DEBUG can be enabled in Linker --> Debugging --> Generate Debug Info




回答2:


If you want to use the debugger to view the disassembly, you can place a __debugbreak() intrinsic call right before the code which you want to view.




回答3:


If you're writing straight assembly, you can just use INT 3. When you place a breakpoint using the debugger, it actually changes the code to that (0xCC in binary) so the debugger will get called when it's executed.

You can also call one of the functions that do that for you like zr suggested. The Windows one is DbgBreakPoint(). If you disassemble it, you could easily see it's nothing but INT 3.




回答4:


These used to be methods of causing breakponts:

_asm
{
  int 3
}

or

_asm
{
  _emit 0xcc
}

or was it

_emit 0xcc

I'm not sure of the syntax (it's been a while) but hopefully something can be made of it.



来源:https://stackoverflow.com/questions/5059614/whats-the-best-way-to-view-accurate-disassembly-in-vc-2010-while-in-win32-rel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!