Re: How to display instructions around the current instuction?

Christian Biesinger via Gdb <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <CAPTJ0XE=e4Oner21Do0wkHp3Yq9dtp7F+TsYrKs_wpqPnDn6Dg@mail.gmail.com>
On Thu, Jan 28, 2021 at 12:13 AM Peng Yu via Gdb <[email protected]> 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.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.