gpt4 book ai didi

c - 使用回调函数报告堆栈回溯

转载 作者:太空宇宙 更新时间:2023-11-04 04:08:24 25 4
gpt4 key购买 nike

假设我有以下内容:

typedef struct {
char *name;
char binding;
int address;
} Fn_Symbol //definition of function symbol

static Fn_Symbol *fnSymbols; //array of function symbols in a file
statc int total; //number of symbol functions in the array and file

static void PrintBacktrace(int sigum, siginfo_t * siginfo, void *context)
{
printf("\nSignal received %d (%s)\n", signum, strsignal(signum));
const int eip_index = 14;
void *eip = (void *)((struct ucontext *)context)->uc_mcontext.gregs[eip_index];
printf("Error at [%p] %s (+0x%x), eip, fnName, offset from start); //?????
exit(0);
}

到目前为止我已经知道了,但是使用 fnSymbols 静态全局指针来识别发生错误的函数然后通过堆栈回溯以通过地址、名称和偏移量来识别每个调用函数的最佳方法是什么?

最佳答案

关于c - 使用回调函数报告堆栈回溯,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2933697/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com