假设我有以下内容:
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/