Liam0205 / liam0205.github.io

Deployment of my weblog.
https://liam0205.github.io
35 stars 5 forks source link

GDB 入门教程:调试 ncurses 相关 bug 的完整范例 | 始终 #185

Open Liam0205 opened 5 years ago

Liam0205 commented 5 years ago

https://liam.page/2017/05/27/tutorial-to-GDB-taking-ncurses-as-an-example/

这是一篇由 Liam Huang 翻译的译文,原文是 Brendan Gregg 所作的 gdb Debugging Full Example (Tutorial): ncurses。转载请保留本段文字,尊重作者和译者的权益。The author of this work is Brendan Gregg and this work was firstly posted on gdb Debug

generalibm commented 5 years ago

第八章 中 “译注:原作者写的是 %rax,这应该是手误”

原作者应该没有出错,应该是查看rax寄存器内容,而非eax内容;

   0x00007f0a37aac401 <+289>:   mov    0x20cb68(%rip),%rax        # 0x7f0a37cb8f70
   0x00007f0a37aac408 <+296>:   mov    (%rax),%rsi
   0x00007f0a37aac40b <+299>:   xor    %eax,%eax
=> 0x00007f0a37aac40d <+301>:   mov    0x10(%rsi),%rdi

箭头出错这一行,是rsi寄存器存储了零值,而rsi的值来源于mov (%rax),%rsi,因此检查rax寄存器的值是有道理的