xxxxx是linux下編譯生成的可執行程序
objdump -j .text -Sl xxxxx > obj.txt
記錄堆棧信息函數
void SignalHandler(void)
{
void* array[10] = {0};
int size = 0;
char **strframe = NULL;
int i = 0, j = 0;
size = backtrace(array, 10);
strframe = (char **)backtrace_symbols(array, size);
printf("print call frame now:\n");
for(i = 0; i < size; i++)
{
printf("frame %d -- %s\n", i, strframe[i]);
}
if(strframe)
{
free(strframe);
strframe = NULL;
}
}
注冊信號回調函數
signal(SIGSEGV, SignalHandler);