Beispiel #1
0
void __TI_Unwind_Resume(_Unwind_Exception *uexcep, _Unwind_Context *context)
{
    #ifdef DEBUG_UNWINDER
    printf("UW: __TI_Unwind_Resume\n");
    #endif

    /*-----------------------------------------------------------------------*/
    /* Resuming after running a cleanup, restore PC from saved area in UE    */
    /*-----------------------------------------------------------------------*/
    __TI_targ_regbuf_set_pc(context, 
			    uexcep->unwinder_data.saved_callsite_addr);

    #ifdef DEBUG_UNWINDER
    printf("UW: restored PC: %"PRIx32"\n", 
           uexcep->unwinder_data.saved_callsite_addr);
    #endif

    /*-----------------------------------------------------------------------*/
    /* Call PR with phase set to Phase2 Resume (PR set up by Phase 2 Start)  */
    /*-----------------------------------------------------------------------*/
    #pragma diag_suppress 1107
    _Unwind_Reason_Code reason_code =
	((_PR_TYPE)(uexcep->unwinder_data.pr_addr))(_UP_Phase2_Resume, 
						    uexcep, 
						    context);
    #pragma diag_default 1107

    #ifdef DEBUG_UNWINDER
    printf("UW: PR returned to __TI_Unwind_Resume\n");
    #endif

    /*-----------------------------------------------------------------------*/
    /* If PR returns CONTINUE, call __TI_unwind_frame to unwind next frame   */
    /* If PR returns INSTALL, copy register buffer regs to machine regs      */
    /*-----------------------------------------------------------------------*/
    if (reason_code == _URC_CONTINUE_UNWIND) 
	__TI_unwind_frame(uexcep, context); /* Process next frame */
    else if (reason_code == _URC_INSTALL_CONTEXT)
	__TI_targ_regbuf_install(context);
    else
	abort();

}
Beispiel #2
0
_Unwind_Reason_Code __TI_Unwind_RaiseException2(_Unwind_Exception *uexcep, 
                                                _Unwind_Context   *ph1_context,
                                                _Unwind_Context   *ph2_context)
{
    #ifdef DEBUG_UNWINDER
    printf("UW: In __TI_Unwind_RaiseException2, UE @ %p, ph1_context @ %p, ph2_context @ %p\n", 
           uexcep, ph1_context, ph2_context);
    #endif

    /*-----------------------------------------------------------------------*/
    /* Search for a handler                                                  */
    /*-----------------------------------------------------------------------*/
    _Unwind_Reason_Code reason_code;
    while (1)
    {
	/*-------------------------------------------------------------------*/
	/* Look up Unwind Table using PC to find the EHT, set up PR to call  */
	/*-------------------------------------------------------------------*/
	if (find_et_setup_pr(uexcep, __TI_targ_regbuf_get_pc(ph1_context)) != 
		_URC_SUCCESS)
        {
            #ifdef DEBUG_UNWINDER
            printf("UW: find_et_setup_pr() != _URC_SUCCESS\n");
            #endif

	    return _URC_FATAL_PHASE1_ERROR;
        }

	/*-------------------------------------------------------------------*/
	/* Call PR with phase set to Phase1                                  */
	/*-------------------------------------------------------------------*/
        #pragma diag_suppress 1107
	reason_code = ((_PR_TYPE)(uexcep->unwinder_data.pr_addr))(_UP_Phase1, 
								  uexcep, 
								  ph1_context);
        #pragma diag_default 1107

        #ifdef DEBUG_UNWINDER
        printf("UW: PR returned to __TI_Unwind_RaiseException\n");
        #endif

	if (reason_code != _URC_CONTINUE_UNWIND)  break;
    }

    #ifdef DEBUG_UNWINDER
    printf("UW: Unwind phase 1 finished\n");
    #endif

    /*-----------------------------------------------------------------------*/
    /* At this point, we should have found a handler for the exception       */
    /*-----------------------------------------------------------------------*/
    if (reason_code != _URC_HANDLER_FOUND) return _URC_FATAL_PHASE1_ERROR;

    /*-----------------------------------------------------------------------*/
    /* Start phase 2 unwinding                                               */
    /*-----------------------------------------------------------------------*/
    __TI_unwind_frame(uexcep, ph2_context);

    /*-----------------------------------------------------------------------*/
    /* Should not get here, if we do, indicate failure                       */
    /*-----------------------------------------------------------------------*/
    return _URC_FATAL_PHASE2_ERROR;
}
_Unwind_Reason_Code __TI_Unwind_RaiseException(_Unwind_Exception *uexcep, 
					       _Unwind_Context   *context)
{
    #ifdef DEBUG_UNWINDER
    printf("UW: In __TI_Unwind_RaiseException, UE @ %p, context @ %p\n", 
           uexcep, context);
    #endif

    /*-----------------------------------------------------------------------*/
    /* Call target specific routine to make a copy of the register context   */
    /* for use by the Phase 1 unwinder.  This needs to be a copy because     */
    /* we're going to simulate unwinding by writing to it, and we don't want */
    /* to scribble on the original yet.  Phase 2 will use the original,      */
    /* since at that time we are committed to unwinding the frame.           */
    /*-----------------------------------------------------------------------*/
    _Unwind_Context *ph1_context = 
				__TI_targ_unwind_regbuf_setup(uexcep, context);

    if (!ph1_context)
    {
        #ifdef DEBUG_UNWINDER
        printf("UW: __TI_targ_unwind_regbuf_setup() == NULL\n");
        #endif

        return _URC_FAILURE;
    }

    /*-----------------------------------------------------------------------*/
    /* Search for a handler                                                  */
    /*-----------------------------------------------------------------------*/
    _Unwind_Reason_Code reason_code;
    while (1)
    {
	/*-------------------------------------------------------------------*/
	/* Look up Unwind Table using PC to find the EHT, set up PR to call  */
	/*-------------------------------------------------------------------*/
	if (find_et_setup_pr(uexcep, __TI_targ_regbuf_get_pc(ph1_context)) != 
		_URC_SUCCESS)
        {
            #ifdef DEBUG_UNWINDER
            printf("UW: find_et_setup_pr() != _URC_SUCCESS\n");
            #endif

	    return _URC_FATAL_PHASE1_ERROR;
        }

	/*-------------------------------------------------------------------*/
	/* Call PR with phase set to Phase1                                  */
	/*-------------------------------------------------------------------*/
        #pragma diag_suppress 1107
	reason_code = ((_PR_TYPE)(uexcep->unwinder_data.pr_addr))(_UP_Phase1, 
								  uexcep, 
								  ph1_context);
        #pragma diag_default 1107

        #ifdef DEBUG_UNWINDER
        printf("UW: PR returned to __TI_Unwind_RaiseException\n");
        #endif

	if (reason_code != _URC_CONTINUE_UNWIND)  break;
    }

    #ifdef DEBUG_UNWINDER
    printf("UW: Unwind phase 1 finished\n");
    #endif

    /*-----------------------------------------------------------------------*/
    /* Phase 1 Register Context no longer required, free it                  */
    /*-----------------------------------------------------------------------*/
    free(ph1_context);

    /*-----------------------------------------------------------------------*/
    /* At this point, we should have found a handler for the exception       */
    /*-----------------------------------------------------------------------*/
    if (reason_code != _URC_HANDLER_FOUND) return _URC_FATAL_PHASE1_ERROR;

    /*-----------------------------------------------------------------------*/
    /* Start phase 2 unwinding                                               */
    /*-----------------------------------------------------------------------*/
    __TI_unwind_frame(uexcep, context);

    /*-----------------------------------------------------------------------*/
    /* Should not get here, if we do, indicate failure                       */
    /*-----------------------------------------------------------------------*/
    return _URC_FATAL_PHASE2_ERROR;
}