示例#1
0
static void exception_throw(chk_expn_frame *frame,const char *exception,siginfo_t* info) {
	int32_t sig = 0;
	char    buff[256];
	if(!frame) {
		//非rethrow,打印日志
        if(exception == segfault)
    	    snprintf(buff,256," [exception:%s <invaild access addr:%p>]\n",
                             segfault,info->si_addr);
        else
    	    snprintf(buff,256," [exception:%s]\n",exception);		
		_log_stack(LOG_ERROR,3,buff);
		frame = chk_exp_top();
	}
	if(frame) {
		frame->exception = exception;
		frame->is_process = 0;
		if(exception == segfault) sig = SIGSEGV;
		else if(exception == sigbug) sig = SIGBUS;
		else if(exception == sigfpe) sig = SIGFPE;  
		siglongjmp(frame->jumpbuffer,sig);
	}else {
		//没有try,直接终止进程
		exit(0);
	}		
}
示例#2
0
static void exception_throw(chk_expn_frame *frame,const char *exception,siginfo_t* info) {
	int32_t sig = 0;
	chk_expn_thd *expthd = chk_exp_get_thread_expn();
	if(!frame) {
		expthd->sz = backtrace(expthd->bt, LOG_STACK_SIZE);
		expthd->exception = exception;
		expthd->addr = info->si_addr;
		frame = chk_exp_top();
	}
	if(frame) {
		frame->is_process = 0;
		if(exception == segfault) sig = SIGSEGV;
		else if(exception == sigbug) sig = SIGBUS;
		else if(exception == sigfpe) sig = SIGFPE;  
		siglongjmp(frame->jumpbuffer,sig);
	}else {
		chk_exp_log_exption_stack();
		//没有try,直接终止进程
		exit(0);
	}		
}