在GDB中显示当前的汇编指令 [英] Show current assembly instruction in GDB
问题描述
我正在GDB中进行一些程序集级别的调试。有没有办法让GDB以与显示当前源代码行相同的方式显示当前汇编指令?每个命令之后的默认输出如下所示:
0x0001433f 990 Foo :: bar(p);
这给了我当前指令的地址,但我必须继续回顾反汇编
以查看我目前正在执行的指令。
你可以在GDB中切换到程序集布局:
(gdb)layout asm
请参阅 here 获取更多信息。
┌────────────────────────────────────────────────────────────────────────────────── ────────────────────────────────────────────────── ───────────┐
│0x7ffff740d756< __ libc_start_main + 214> mov 0x39670b(%rip),%rax#│
│0x7ffff740d75d< __ libc_start_main + 221> mov 0x8(%rsp),%rsi│
│0x7ffff740d762< __ libc_start_main + 226> mov 0x14(%rsp),%edi│
│0x7ffff740d766< __ libc_start_main + 230> mov(%rax),%rdx│
│0x7ffff740d769< __ libc_start_main + 233> callq * 0x18(%rsp)│
>│0x7ffff740d76d< __ libc_start_main + 237> mov%eax,%edi│
│0x7ffff740d76f< __ libc_start_main + 239> callq 0x7ffff7427970< exit> │
│0x7ffff740d774< __ libc_start_main + 244> xor%edx,%edx│
│0x7ffff740d776< __ libc_start_main + 246> jmpq 0x7ffff740d6b9< __libc_start│
│0x7ffff740d77b< __ libc_start_main + 251> mov 0x39ca2e(%rip),%rax#│
│0x7ffff740d782< __ libc_start_main + 258> ror $ 0x11,%rax│
│0x7ffff740d786< __ libc_start_main + 262> xor%fs:0x30,%rax│
│0x7ffff740d78f< __ libc_start_main + 271> callq *%rax│
└─────────────────────────────────────────── ───────────────────────────────
多重进程3718 In:__libc_start_main行: ?? PC中的0x7ffff740d76d
#3 0x00007ffff7466eb5 in /lib/x86_64-linux-gnu/libc.so.6
#4中的_IO_do_write()中的_IO_file_overflow()中的0x00007ffff74671ff从/ lib / x86_64- linux-gnu / libc.so.6
#5 0x0000000000408756 in ?? ()
#6 0x0000000000403980在?? ()
#7 0x00007ffff740d76d in __libc_start_main()
from /lib/x86_64-linux-gnu/libc.so.6
(gdb)
I'm doing some assembly-level debugging in GDB. Is there a way to get GDB to show me the current assembly instruction in the same way that it shows the current source line? The default output after every command looks like this:
0x0001433f 990 Foo::bar(p);
This gives me the address of the current instruction, but I have to keep referring back to the output of disassemble
in order to see which instruction I'm currently executing.
You can switch to assembly layout in GDB:
(gdb) layout asm
See here for more information. The current assembly instruction will be shown in assembler window.
┌───────────────────────────────────────────────────────────────────────────┐
│0x7ffff740d756 <__libc_start_main+214> mov 0x39670b(%rip),%rax #│
│0x7ffff740d75d <__libc_start_main+221> mov 0x8(%rsp),%rsi │
│0x7ffff740d762 <__libc_start_main+226> mov 0x14(%rsp),%edi │
│0x7ffff740d766 <__libc_start_main+230> mov (%rax),%rdx │
│0x7ffff740d769 <__libc_start_main+233> callq *0x18(%rsp) │
>│0x7ffff740d76d <__libc_start_main+237> mov %eax,%edi │
│0x7ffff740d76f <__libc_start_main+239> callq 0x7ffff7427970 <exit> │
│0x7ffff740d774 <__libc_start_main+244> xor %edx,%edx │
│0x7ffff740d776 <__libc_start_main+246> jmpq 0x7ffff740d6b9 <__libc_start│
│0x7ffff740d77b <__libc_start_main+251> mov 0x39ca2e(%rip),%rax #│
│0x7ffff740d782 <__libc_start_main+258> ror $0x11,%rax │
│0x7ffff740d786 <__libc_start_main+262> xor %fs:0x30,%rax │
│0x7ffff740d78f <__libc_start_main+271> callq *%rax │
└───────────────────────────────────────────────────────────────────────────┘
multi-thre process 3718 In: __libc_start_main Line: ?? PC: 0x7ffff740d76d
#3 0x00007ffff7466eb5 in _IO_do_write () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff74671ff in _IO_file_overflow ()
from /lib/x86_64-linux-gnu/libc.so.6
#5 0x0000000000408756 in ?? ()
#6 0x0000000000403980 in ?? ()
#7 0x00007ffff740d76d in __libc_start_main ()
from /lib/x86_64-linux-gnu/libc.so.6
(gdb)
这篇关于在GDB中显示当前的汇编指令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!