简介: CSDN博客专家,专注Android/Linux系统,分享多mic语音方案、音视频、编解码等技术,与大家一起成长!
优质专栏:Audio工程师进阶系列【原创干货持续更新中……】🚀
人生格言: 人生从来没有捷径,只有行动才是治疗恐惧和懒惰的唯一良药.
1.前言
本篇目的:GDB之打印函数堆栈。
info frame指令:输出当前函数堆栈帧的地址,指令寄存器的值,局部变量地址及值等信息,
2.调试实例
#include <cstdio>
#include <string>
void test1(){
printf("xxx----------->%s(), line = %d\n",__FUNCTION__,__LINE__);
}
int main(void){
std::string buf1 = "Hello";
std::string buf2 = "World";
printf("buf1 is %s, buf2 is %s\n", buf1.c_str(), buf2.c_str());
return 0;
}
调试步骤:gdb使用info frame打印函数堆栈。
gdb) info frame
Stack level 0, frame at 0x7fffffffdc70:
rip = 0x555555555433 in main (test.cpp:9); saved rip = 0x7ffff7b50d90
source language c++.
Arglist at 0x7fffffffdc60, args:
Locals at 0x7fffffffdc60, Previous frame's sp is 0x7fffffffdc70
Saved registers:
rbx at 0x7fffffffdc58, rbp at 0x7fffffffdc60, rip at 0x7fffffffdc68