如何获取函数调用链
来源:互联网 发布:皇图护盾进阶数据 编辑:程序博客网 时间:2024/06/08 04:45
直接上代码。仅针对x86或x86_64架构。
#include <stdio.h>
int get_call_links(unsigned long *records, int nr, unsigned long *usr_provide_bp)
{
unsigned long *bp;
int depth=0;
if (usr_provide_bp!=NULL)
{
bp=usr_provide_bp;
}
else
{
#if defined(__i386)
asm ("movl %%ebp, %0":"=qm"(bp));
#elif defined( __x86_64)
asm ("movq %%rbp, %0":"=qm"(bp));
#else
#error unsupported arch
#endif
}
while (depth<nr && (*bp)!=0)
{
records[depth]=*(bp+1);
bp=(void*)(*bp);
depth++;
}
return depth;
}
int f1()
{
unsigned long calls[100];
int depth;
depth=get_call_links(calls, 100, NULL);
printf("depth=%d\n", depth);
return 1;
}
int f2()
{
return f1();
}
int f3()
{
return f2();
}
int main(int argc, char *argv[])
{
f3();
return 0;
}
- 如何获取函数调用链
- 如何获取函数的调用者
- 如何调用ShowModelessHTMLDialog函数
- 如何调用DES_EnCode函数
- 如何调用C++函数?
- 函数如何被调用
- linux函数调用栈获取
- 如何调用MFC中的函数打开一个系统资源面板,获取文件
- Smarty中如何获取数组的长度 ,及smarty 调用php函数
- c++里的system()函数调用系统命令如何获取打印信息
- 【JavaScript】如何获取调用该函数的源对象(元素)
- 如何调用DLL中的函数
- C++如何调用JS函数
- 如何调用 DLL 中的函数
- jquery如何调用自定义函数
- JNI如何调用Java函数
- LoadRunner如何调用外部函数
- 如何调用DLL中的函数
- django学习系列之模板系统篇(二)
- android和iOS平台的崩溃捕获和收集
- java接口
- CString类常用方法---GetLength(),strlen(),IsEmpty(),Empty()
- (1)今天你求职了吗?
- 如何获取函数调用链
- SQL SERVER 2008 MINI安装
- filter配置
- SRAM和DRAM的区别
- android.os.NetworkOnMainThreadException异常
- IOS开发笔记(5)程序异常crash捕获与拦截
- Restarting nginx daemon: nginxnginx: [emerg] bind() to 0.0.0.0:80 failed (98:
- 入职IT公司三天了
- 安装第三方库出现 Python version 2.7 required, which was not found in the registry