How to display instructions around the current instuction?

Christian Biesinger cbiesinger@google.com
Thu Jan 28 13:11:07 GMT 2021


On Thu, Jan 28, 2021 at 12:13 AM Peng Yu via Gdb <gdb@sourceware.org> wrote:
>
> Hi,
>
> The following command will disply instructions below the current
> instructions. Is there a way to display around the current instruction
> (e.g., 5 instructions above and 5 instructions below)?

I believe "disas" should work:

Breakpoint 1, main () at a.cpp:5

5     std::cout << "Miau\n";

(gdb) disas
Dump of assembler code for function main():
   0x0000555555555155 <+0>: push   %rbp
   0x0000555555555156 <+1>: mov    %rsp,%rbp
=> 0x0000555555555159 <+4>: lea    0xea5(%rip),%rsi        # 0x555555556005
   0x0000555555555160 <+11>: lea    0x2ed9(%rip),%rdi        #
0x555555558040 <_ZSt4cout@GLIBCXX_3.4>
   0x0000555555555167 <+18>: call   0x555555555040
<_ZStlsISt11char_traitsIcEERSt13basic_ostreamIcT_ES5_PKc@plt>
   0x000055555555516c <+23>: mov    $0x0,%eax
   0x0000555555555171 <+28>: pop    %rbp
   0x0000555555555172 <+29>: ret
End of assembler dump.


More information about the Gdb mailing list