我想用 callb 替换以下函数 calla (参考:从 C 中的任何线程获取调用堆栈)
int calla()
{
printf("Inside calla\n");
printf("A1=%x\n",__builtin_return_address (0));
printf("A2=%x\n",__builtin_return_address (1) );
printf("A3=%x\n",__builtin_return_address (2) );
}
int callb()
{
int i,j;
j = stackdepth();
for (i=0 ; i<j ;i++)
printf("%x\n",__builtin_return_address (i));
}
如何找到堆栈深度?