简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长!
优质专栏:Audio工程师进阶系列【原创干货持续更新中……】
人生格言: 人生从来没有捷径,只有行动才是治疗恐惧和懒惰的唯一良药.
本篇目的:GDB之源码与汇编映射对应,查阅方便。
1 #include <cstdio>
2
3 void test(){
4 printf("1111111111111111\n");
5 }
6
7 int main(void) {
8 test();
9 return 0;
10 }
(gdb) disa
disable disassemble
(gdb) disassemble /m test
Dump of assembler code for function _Z4testv:
3 void test(){
0x0000000000001149 <+0>: endbr64
0x000000000000114d <+4>: push %rbp
0x000000000000114e <+5>: mov %rsp,%rbp
4 printf("1111111111111111\n");
0x0000000000001151 <+8>: lea 0xeac(%rip),%rax # 0x2004
0x0000000000001158 <+15>: mov %rax,%rdi
0x000000000000115b <+18>: call 0x1050
5 }
0x0000000000001160 <+23>: nop
0x0000000000001161 <+24>: pop %rbp
0x0000000000001162 <+25>: ret
End of assembler dump.
(gdb)
(gdb) i line 4
Line 4 of "test.cpp" starts at address 0x1151 <_Z4testv+8> and ends at 0x1160 <_Z4testv+23>
以上是 printf(“1111111111111111\n”);代码寻址语句:它的寻址范围: 0x1151 —> 0x1160。
disassemble Start,End
命令(gdb) disassemble 0x1151,0x1160
Dump of assembler code from 0x1151 to 0x1160:
0x0000000000001151 <_Z4testv+8>: lea 0xeac(%rip),%rax # 0x2004
0x0000000000001158 <_Z4testv+15>: mov %rax,%rdi
0x000000000000115b <_Z4testv+18>: call 0x1050
End of assembler dump.
(gdb)