设为首页 加入收藏

TOP

善用backtrace解决大问题(三)
2014-11-23 22:30:38 来源: 作者: 【 】 浏览:3
Tags:善用 backtrace 解决 问题
_mask);
action.sa_flags = SA_RESTART;

sigaction(rec_signal,&action,NULL);

/* Print out the backtrace. */
backtr_size = backtrace(backtr,20);

/* The backtrace points to sigaction in libc, not to where the signal was actually raised.
This overwrites the sigaction with where the signal was sent, so we can resolve the sender. */
#if __WORDSIZE == 64
backtr[1] = (void*)u_context->uc_mcontext.gregs[REG_RIP];
#else
backtr[1] = (void*)u_context->uc_mcontext.gregs[REG_EIP];
#endif //__WORDSIZE

backtrace_symbols_fd(backtr,backtr_size,fileno(file));

fprintf(file,"Backtrace is above.\nFatal signal %d received.\n",rec_signal);
#if __WORDSIZE == 64
fprintf(file,"Signal received at address %p from 0x%08x.\n",signal_info->si_addr,
u_context->uc_mcontext.gregs[REG_RIP]);
#else
fprintf(file,"Signal received at address %p from 0x%08x.\n",signal_info->si_addr,
u_context->uc_mcontext.gregs[REG_EIP]);
#endif //__WORDSIZE


#if CPAL_LM_DEBUG
/* Print all NE_Infos */
for(; i < MAX_NO_OF_CONNS; i++)
{
ne_info = g_ne_hash_tab[i];
while(ne_info != NULL)
{
ne_info = ne_info->next_ne;
}
}
#endif

fflush(file);
fclose(file);
sleep (50); /* Sleep for 50 seconds */
g_handler_running = *_FALSE;
raise(rec_signal);
}

首页 上一页 1 2 3 下一页 尾页 3/3/3
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇 我的专属QQ功能篇(二) 下一篇[Fixed Eclipse CDT]可正常运行,..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: