示例#1
0
//
// Called by personality handler during phase 2 to get instruction pointer
// ipBefore is a boolean that says if IP is already adjusted to be the call
// site address.  Normally IP is the return address.
//
EXPORT uintptr_t _Unwind_GetIPInfo(struct _Unwind_Context* context, int* ipBefore)
{
	_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t)context;
	*ipBefore = 0;
	DEBUG_PRINT_API("_Unwind_GetIPInfo(context=%p, %p) => 0x%lX\n", context, ipBefore, ufc->resumeLocation+1);
	return ufc->resumeLocation+1; 
}
示例#2
0
//
// Called by personality handler during phase 2 to get register values
//
EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context* context, int index)
{
	unw_cursor_t* cursor = (unw_cursor_t*)context;
	unw_word_t result;
	unw_get_reg(cursor, index, &result);
	DEBUG_PRINT_API("_Unwind_GetGR(context=%p, reg=%d) => 0x%llX\n", context, index, (uint64_t)result);
	return result;
}
示例#3
0
//
// Called by personality handler during phase 2 to get instruction pointer
//
EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context* context)
{
	unw_cursor_t* cursor = (unw_cursor_t*)context;
	unw_word_t result;
	unw_get_reg(cursor, UNW_REG_IP, &result);
	DEBUG_PRINT_API("_Unwind_GetIP(context=%p) => 0x%llX\n", context, (uint64_t)result);
	return result;
}
示例#4
0
//
// Called by personality handler during phase 2 to find the start of the function
//
EXPORT uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context* context)
{
	unw_cursor_t* cursor = (unw_cursor_t*)context;
	unw_proc_info_t frameInfo;
	uintptr_t result = 0;
	if ( unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS ) 
		result = frameInfo.start_ip;
	DEBUG_PRINT_API("_Unwind_GetRegionStart(context=%p) => 0x%lX\n", context, result);
	return result;
}
示例#5
0
//
// Called by personality handler to get Call Frame Area for current frame
//
EXPORT uintptr_t _Unwind_GetCFA(struct _Unwind_Context* context)
{
	DEBUG_PRINT_API("_Unwind_GetCFA(context=%p)\n", context);
	if ( context != NULL ) {
		_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t)context;
		// setjmp/longjmp based exceptions don't have a true CFA
		// the SP in the jmpbuf is the closest approximation
		return (uintptr_t)ufc->jbuf[2];
	}
	return 0;
}
示例#6
0
//
// When _Unwind_RaiseException() is in phase2, it hands control
// to the personality function at each frame.  The personality
// may force a jump to a landing pad in that function, the landing
// pad code may then call _Unwind_Resume() to continue with the
// unwinding.  Note: the call to _Unwind_Resume() is from compiler
// geneated user code.  All other _Unwind_* routines are called 
// by the C++ runtime __cxa_* routines. 
//
// Re-throwing an exception is implemented by having the code call
// __cxa_rethrow() which in turn calls _Unwind_Resume_or_Rethrow()
//
EXPORT void _Unwind_SjLj_Resume(struct _Unwind_Exception* exception_object)
{
	DEBUG_PRINT_API("_Unwind_SjLj_Resume(ex_obj=%p)\n", exception_object);
	
	if ( exception_object->private_1 != 0 ) 
		unwind_phase2_forced(exception_object, (_Unwind_Stop_Fn)exception_object->private_1, (void*)exception_object->private_2);  
	else
		unwind_phase2(exception_object);  
	
	// clients assume _Unwind_Resume() does not return, so all we can do is abort.
	ABORT("_Unwind_SjLj_Resume() can't return");
}
示例#7
0
//
//  Called by __cxa_rethrow()
//
EXPORT _Unwind_Reason_Code _Unwind_SjLj_Resume_or_Rethrow(struct _Unwind_Exception* exception_object)
{
	DEBUG_PRINT_API("__Unwind_SjLj_Resume_or_Rethrow(ex_obj=%p), private_1=%ld\n", exception_object, exception_object->private_1);
	// if this is non-forced and a stopping place was found, then this is a re-throw
	// call _Unwind_RaiseException() as if this was a new exception
	if ( exception_object->private_1 == 0 )
		_Unwind_SjLj_RaiseException(exception_object); 
	
	// call through to _Unwind_Resume() which distiguishes between forced and regular exceptions
	_Unwind_SjLj_Resume(exception_object); 
	ABORT("__Unwind_SjLj_Resume_or_Rethrow() called _Unwind_SjLj_Resume() which unexpectedly returned");
}
示例#8
0
//
// Not used by C++.  
// Unwinds stack, calling "stop" function at each frame
// Could be used to implement longjmp().
//
EXPORT _Unwind_Reason_Code _Unwind_ForcedUnwind(struct _Unwind_Exception* exception_object, _Unwind_Stop_Fn stop, void* stop_parameter)
{
	DEBUG_PRINT_API("_Unwind_ForcedUnwind(ex_obj=%p, stop=%p)\n", exception_object, stop);
	unw_context_t uc;
	unw_getcontext(&uc);

	// mark that this is a forced unwind, so _Unwind_Resume() can do the right thing
	exception_object->private_1	= (uintptr_t)stop;
	exception_object->private_2	= (uintptr_t)stop_parameter;
	
	// doit
	return unwind_phase2_forced(&uc, exception_object, stop, stop_parameter);  
}
示例#9
0
//
// Called by personality handler during phase 2 to get LSDA for current frame
//
EXPORT uintptr_t _Unwind_GetLanguageSpecificData(struct _Unwind_Context* context)
{
	unw_cursor_t* cursor = (unw_cursor_t*)context;
	unw_proc_info_t frameInfo;
	uintptr_t result = 0;
	if ( unw_get_proc_info(cursor, &frameInfo) == UNW_ESUCCESS ) 
		result = frameInfo.lsda;
	DEBUG_PRINT_API("_Unwind_GetLanguageSpecificData(context=%p) => 0x%lX\n", context, result);
	if ( result != 0 ) {
		if ( *((uint8_t*)result) != 0xFF ) 
			DEBUG_MESSAGE("lsda at 0x%lX does not start with 0xFF\n", result);
	}
	return result;
}
示例#10
0
//
// Called by __cxa_throw.  Only returns if there is a fatal error
//
EXPORT _Unwind_Reason_Code _Unwind_SjLj_RaiseException(struct _Unwind_Exception* exception_object)
{
	DEBUG_PRINT_API("_Unwind_SjLj_RaiseException(ex_obj=%p)\n", exception_object);

	// mark that this is a non-forced unwind, so _Unwind_Resume() can do the right thing
	exception_object->private_1	= 0;
	exception_object->private_2	= 0;

	// phase 1: the search phase
	_Unwind_Reason_Code phase1 = unwind_phase1(exception_object);
	if ( phase1 != _URC_NO_REASON )
		return phase1;
	
	// phase 2: the clean up phase
	return unwind_phase2(exception_object);  
}
示例#11
0
//
// Called by personality handler during phase 2 to alter register values
//
EXPORT void _Unwind_SetGR(struct _Unwind_Context* context, int index, uintptr_t new_value)
{
	DEBUG_PRINT_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%0llX)\n", context, index, (uint64_t)new_value);
	unw_cursor_t* cursor = (unw_cursor_t*)context;
	unw_set_reg(cursor, index, new_value);
}
示例#12
0
//
// Called by personality handler during phase 2 to alter instruction pointer
//
EXPORT void _Unwind_SetIP(struct _Unwind_Context* context, uintptr_t new_value)
{
	DEBUG_PRINT_API("_Unwind_SetIP(context=%p, value=0x%0lX)\n", context, new_value);
	_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t)context;
	ufc->resumeLocation = new_value-1;
}
示例#13
0
//
// Called by personality handler during phase 2 to get instruction pointer
//
EXPORT uintptr_t _Unwind_GetIP(struct _Unwind_Context* context)
{
	_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t)context;
	DEBUG_PRINT_API("_Unwind_GetIP(context=%p) => 0x%lX\n", context, ufc->resumeLocation+1);
	return ufc->resumeLocation+1;
}
示例#14
0
//
// Called by personality handler during phase 2 to alter register values
//
EXPORT void _Unwind_SetGR(struct _Unwind_Context* context, int index, uintptr_t new_value)
{
	DEBUG_PRINT_API("_Unwind_SetGR(context=%p, reg=%d, value=0x%0lX)\n", context, index, new_value);
	_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t)context;
	ufc->resumeParameters[index] = new_value;
}
示例#15
0
//
// Called by personality handler during phase 2 to get register values
//
EXPORT uintptr_t _Unwind_GetGR(struct _Unwind_Context* context, int index)
{
	DEBUG_PRINT_API("_Unwind_GetGR(context=%p, reg=%d)\n", context, index);
	_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t)context;
	return ufc->resumeParameters[index];
}
示例#16
0
//
// Called by personality handler during phase 2 to get LSDA for current frame
//
EXPORT uintptr_t _Unwind_GetLanguageSpecificData(struct _Unwind_Context* context)
{
	_Unwind_FunctionContext_t ufc = (_Unwind_FunctionContext_t)context;
	DEBUG_PRINT_API("_Unwind_GetLanguageSpecificData(context=%p) => 0x%0lX\n", context, ufc->lsda);
	return ufc->lsda;
}
示例#17
0
//
// Called by personality handler during phase 2 to alter instruction pointer
//
EXPORT void _Unwind_SetIP(struct _Unwind_Context* context, uintptr_t new_value)
{
	DEBUG_PRINT_API("_Unwind_SetIP(context=%p, value=0x%0llX)\n", context, (uint64_t)new_value);
	unw_cursor_t* cursor = (unw_cursor_t*)context;
	unw_set_reg(cursor, UNW_REG_IP, new_value);
}
示例#18
0
//
// Called by personality handler during phase 2 to find the start of the function
//
EXPORT uintptr_t _Unwind_GetRegionStart(struct _Unwind_Context* context)
{
	// Not supported or needed for sjlj based unwinding
	DEBUG_PRINT_API("_Unwind_GetRegionStart(context=%p)\n", context);
	return 0;
}
示例#19
0
//
// Called by personality handler during phase 2 if a foreign exception is caught 
//
EXPORT void _Unwind_DeleteException(struct _Unwind_Exception* exception_object)
{
	DEBUG_PRINT_API("_Unwind_DeleteException(ex_obj=%p)\n", exception_object);
	if ( exception_object->exception_cleanup != NULL )
		(*exception_object->exception_cleanup)(_URC_FOREIGN_EXCEPTION_CAUGHT, exception_object);
}
示例#20
0
//
// Called by personality handler during phase 2 to get base address for text relative encodings
//
EXPORT uintptr_t _Unwind_GetTextRelBase(struct _Unwind_Context* context)
{
	// Not supported or needed for sjlj based unwinding
	DEBUG_PRINT_API("_Unwind_GetTextRelBase(context=%p)\n", context);
	ABORT("_Unwind_GetTextRelBase() not implemented");
}