starti
从第一条指令开始执行并停止.
nexti
执行完当前指令; 当前指令可能是call
一个函数, 但是仍然下一条指令才停止;
stepi
下一条指令, 如果跳转也跟着跳转;
查看寄存器值
info registers
查看通用寄存器info registers {register_name ...}
指定寄存器的值info registers all
所有寄存器, 不仅仅通用寄存器; 还有向量寄存器等;文章来源:https://www.toymoban.com/news/detail-645756.html
修改寄存器
p $rip = val
文章来源地址https://www.toymoban.com/news/detail-645756.html
查看汇编
disassemble $rip
disassemble main
# 推荐
x /1024ig $rip
案例
代码
int main() {
int a = 0;
a ++ ;
return a;
}
编译
gcc test.cpp -o a.out
案例
ch@ch-ubuntu:~/ch/cppfile/test$ gdb ./a.out -q
Reading symbols from ./a.out...
(No debugging symbols found in ./a.out)
(gdb) starti
Starting program: /home/ch/ch/cppfile/test/a.out
Program stopped.
0x00007ffff7fe4880 in _start () from /lib64/ld-linux-x86-64.so.2
(gdb) b main
Breakpoint 1 at 0x555555555131
(gdb) c
Continuing.
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Breakpoint 1, 0x0000555555555131 in main ()
(gdb) disassemble $rip
Dump of assembler code for function main:
0x0000555555555129 <+0>: endbr64
0x000055555555512d <+4>: push %rbp
0x000055555555512e <+5>: mov %rsp,%rbp
=> 0x0000555555555131 <+8>: movl $0x0,-0x4(%rbp)
0x0000555555555138 <+15>: addl $0x1,-0x4(%rbp)
0x000055555555513c <+19>: mov -0x4(%rbp),%eax
0x000055555555513f <+22>: pop %rbp
0x0000555555555140 <+23>: ret
End of assembler dump.
(gdb) nexti
0x0000555555555138 in main ()
(gdb) disassemble $rip
Dump of assembler code for function main:
0x0000555555555129 <+0>: endbr64
0x000055555555512d <+4>: push %rbp
0x000055555555512e <+5>: mov %rsp,%rbp
0x0000555555555131 <+8>: movl $0x0,-0x4(%rbp)
=> 0x0000555555555138 <+15>: addl $0x1,-0x4(%rbp)
0x000055555555513c <+19>: mov -0x4(%rbp),%eax
0x000055555555513f <+22>: pop %rbp
0x0000555555555140 <+23>: ret
End of assembler dump.
(gdb) x /5ig $rip
=> 0x555555555138 <main+15>: addl $0x1,-0x4(%rbp)
0x55555555513c <main+19>: mov -0x4(%rbp),%eax
0x55555555513f <main+22>: pop %rbp
0x555555555140 <main+23>: ret
0x555555555141: add %al,(%rax)
(gdb) ni
0x000055555555513c in main ()
(gdb) ni
0x000055555555513f in main ()
(gdb) p $eax
$1 = 1
(gdb)
到了这里,关于gdb 调试汇编的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!