gdb
info line sourceCodeLine
(gdb) info line funcName
(gdb) info line 9
Line 9 of "main.cpp" starts at address 0x400670 <main+40> and ends at 0x400677 <main+47>.
(gdb) disas 0x400670 0x400677
Dump of assembler code from 0x400670 to 0x400677:
0x0000000000400670 <main+40>: movzbl -0xf(%rbp),%eax
0x0000000000400674 <main+44>: mov %al,-0x1(%rbp)
End of assembler dump.
结合用 x/i 可以查看指令
(gdb) info line main
Line 4 of "main.cpp" starts at address 0x400648 <main> and ends at 0x40064c <main+4>.
(gdb) x/5i
0x400648 <main>: push %rbp
0x400649 <main+1>: mov %rsp,%rbp
0x40064c <main+4>: movb $0x1,-0x9(%rbp)
0x400650 <main+8>: mov 0x1a1(%rip),%rax # 0x4007f8 <__dso_handle+8>
0x400657 <main+15>: mov %rax,-0x20(%rbp)
info line sourceCodeLine
(gdb) info line funcName
(gdb) info line 9
Line 9 of "main.cpp" starts at address 0x400670 <main+40> and ends at 0x400677 <main+47>.
(gdb) disas 0x400670 0x400677
Dump of assembler code from 0x400670 to 0x400677:
0x0000000000400670 <main+40>: movzbl -0xf(%rbp),%eax
0x0000000000400674 <main+44>: mov %al,-0x1(%rbp)
End of assembler dump.
结合用 x/i 可以查看指令
(gdb) info line main
Line 4 of "main.cpp" starts at address 0x400648 <main> and ends at 0x40064c <main+4>.
(gdb) x/5i
0x400648 <main>: push %rbp
0x400649 <main+1>: mov %rsp,%rbp
0x40064c <main+4>: movb $0x1,-0x9(%rbp)
0x400650 <main+8>: mov 0x1a1(%rip),%rax # 0x4007f8 <__dso_handle+8>
0x400657 <main+15>: mov %rax,-0x20(%rbp)