Why GDB jumps unpredictably between lines and prints variables as “”?

后端 未结 8 1161
伪装坚强ぢ
伪装坚强ぢ 2020-12-02 05:10

Can anyone explain this behavior of gdb?

900         memset(&new_ckpt_info,\'\\0\',sizeof(CKPT_INFO));
(gdb)
**903         prev_offset   = cp_node->of         


        
8条回答
  •  旧时难觅i
    2020-12-02 05:44

    To debug optimized code, learn assembly/machine language.

    Use the GDB TUI mode. My copy of GDB enables it when I type the minus and Enter. Then type C-x 2 (that is hold down Control and press X, release both and then press 2). That will put it into split source and disassembly display. Then use stepi and nexti to move one machine instruction at a time. Use C-x o to switch between the TUI windows.

    Download a PDF about your CPU's machine language and the function calling conventions. You will quickly learn to recognize what is being done with function arguments and return values.

    You can display the value of a register by using a GDB command like p $eax

提交回复
热议问题