编程语言
首页 > 编程语言> > c – 在哪种情况下,在调试时使用反汇编语言很有用

c – 在哪种情况下,在调试时使用反汇编语言很有用

作者:互联网

我有以下基本问题:

  • When we should involve disassembly in debugging

  • How to interpret disassembly, For example below what does each segment stands for

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 

语言:C

平台:Windows

解决方法:

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

例如,如果在循环中使用std :: vector :: operator []而不进行反汇编,则很难猜测每次调用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

这是调用函数的典型序列 – 参数被推入堆栈,然后控制转移到该函数代码(调用指令).

当参与有关“编译后如何工作”的论据时,使用反汇编也非常有用 – 例如his answer to this question中的caf点.

标签:c,debugging,disassembly
来源: https://codeday.me/bug/20191008/1872052.html