在调试时使用反汇编语言在什么情况下有用

Sat*_*bir 4 c++ debugging disassembly

我有以下基本问题:

  • 何时我们应该在调试中涉及反汇编

  • 如何解释反汇编,例如下面每个段代表什么

00637CE3 8B 55 08             mov         edx,dword ptr [arItem]
00637CE6 52                   push        edx
00637CE7 6A 00                push        0
00637CE9 8B 45 EC             mov         eax,dword ptr [result]
00637CEC 50                   push        eax
00637CED E8 3E E3 FF FF       call        getRequiredFields (00636030)
00637CF2 83 C4 0C             add 
Run Code Online (Sandbox Code Playgroud)

语言:C++

平台:Windows

sha*_*oth 6

估计编译器发出的代码的效率非常有用。

例如,如果您在std::vector::operator[]不进行反汇编的情况下在循环中使用 an ,则很难猜测每次调用operator[]实际上都需要两次内存访问,但使用迭代器进行相同的操作将需要一次内存访问。

在你的例子中:

mov         edx,dword ptr [arItem] // value stored at address "arItem" is loaded onto the register
push        edx // that register is pushes into stack
push        0 // zero is pushed into stack
mov         eax,dword ptr [result] // value stored at "result" address us loaded onto the register
push        eax // that register is pushed into stack
call        getRequiredFields (00636030) // getRequiredFields function is called
Run Code Online (Sandbox Code Playgroud)

这是调用函数的典型顺序 - 参数被推入堆栈,然后控制权被转移到该函数代码(call指令)。

在参与有关“编译后如何工作”的争论时,使用反汇编也非常有用 - 就像回答这个问题时所指出的那样。