In which scenario it is useful to use Disassembly language while debugging

前端 未结 4 711
无人共我
无人共我 2021-01-14 21:28

I have following basic questions :

  • When we should involve disassembly in debugging

  • How to interpret disassembly, For example be

4条回答
  •  天命终不由人
    2021-01-14 21:34

    It's quite useful to estimate how efficient is the code emitted by the compiler.

    For example, if you use an std::vector::operator[] in a loop without disassembly it's quite hard to guess that each call to operator[] in fact requires two memory accesses but using an iterator for the same would require one memory access.

    In your example:

    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
    

    this is a typical sequence for calling a function - paramaters are pushed into stack and then the control is transferred to that function code (call instruction).

    Also using disassembly is quite useful when participating in arguments about "how it works after compilation" - like caf points in his answer to this question.

提交回复
热议问题