2012-02-05 11:35:58 -05:00
|
|
|
/****************************************************************
|
|
|
|
* *
|
2012-10-29 18:54:31 -04:00
|
|
|
* Copyright 2001, 2012 Fidelity Information Services, Inc *
|
2012-02-05 11:35:58 -05:00
|
|
|
* *
|
|
|
|
* This source code contains the intellectual property *
|
|
|
|
* of its copyright holder(s), and is made available *
|
|
|
|
* under a license. If you do not know the terms of *
|
|
|
|
* the license, please stop and do not read further. *
|
|
|
|
* *
|
|
|
|
****************************************************************/
|
|
|
|
|
|
|
|
#include "mdef.h"
|
2012-10-29 18:54:31 -04:00
|
|
|
#include <rtnhdr.h>
|
2012-02-05 11:35:58 -05:00
|
|
|
#include "stack_frame.h"
|
|
|
|
#include "stringpool.h"
|
|
|
|
#include "objlabel.h"
|
|
|
|
#include "cache.h"
|
|
|
|
#include "cache_cleanup.h"
|
|
|
|
#include "trans_code_cleanup.h"
|
|
|
|
#include "dm_setup.h"
|
|
|
|
#include "error.h"
|
|
|
|
#include "error_trap.h"
|
|
|
|
#include "io.h"
|
|
|
|
#ifdef GTM_TRIGGER
|
|
|
|
# include "gtm_trigger_trc.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
GBLREF unsigned short proc_act_type;
|
|
|
|
GBLREF stack_frame *frame_pointer;
|
|
|
|
GBLREF spdesc stringpool;
|
|
|
|
GBLREF spdesc rts_stringpool;
|
|
|
|
GBLREF mval dollar_ztrap, dollar_etrap;
|
|
|
|
GBLREF mstr *err_act;
|
|
|
|
GBLREF io_desc *active_device;
|
2012-03-24 14:06:46 -04:00
|
|
|
GBLREF boolean_t ztrap_explicit_null;
|
2012-02-05 11:35:58 -05:00
|
|
|
|
|
|
|
error_def(ERR_STACKCRIT);
|
|
|
|
error_def(ERR_ERRWZTRAP);
|
|
|
|
error_def(ERR_ERRWETRAP);
|
|
|
|
error_def(ERR_ERRWIOEXC);
|
|
|
|
|
|
|
|
void trans_code_cleanup(void)
|
|
|
|
{
|
|
|
|
stack_frame *fp, *fpprev;
|
2012-03-24 14:06:46 -04:00
|
|
|
uint4 errmsg;
|
2012-02-05 11:35:58 -05:00
|
|
|
DCL_THREADGBL_ACCESS;
|
|
|
|
|
|
|
|
SETUP_THREADGBL_ACCESS;
|
|
|
|
assert(!(SFT_ZINTR & proc_act_type));
|
|
|
|
/* With no extra ztrap frame being pushed onto stack, we may miss error(s)
|
|
|
|
* during trans_code if we don't check proc_act_type in addition to
|
|
|
|
* frame_pointer->type below.
|
|
|
|
*/
|
|
|
|
if (SFT_ZTRAP == proc_act_type)
|
|
|
|
{
|
|
|
|
if (0 < dollar_ztrap.str.len)
|
2012-03-24 14:06:46 -04:00
|
|
|
errmsg = ERR_ERRWZTRAP;
|
2012-02-05 11:35:58 -05:00
|
|
|
else
|
2012-03-24 14:06:46 -04:00
|
|
|
errmsg = ERR_ERRWETRAP;
|
2012-02-05 11:35:58 -05:00
|
|
|
} else if (SFT_DEV_ACT == proc_act_type)
|
2012-03-24 14:06:46 -04:00
|
|
|
errmsg = ERR_ERRWIOEXC;
|
2012-02-05 11:35:58 -05:00
|
|
|
else
|
2012-03-24 14:06:46 -04:00
|
|
|
errmsg = 0;
|
2012-02-05 11:35:58 -05:00
|
|
|
proc_act_type = 0;
|
|
|
|
if (TREF(compile_time))
|
|
|
|
{
|
|
|
|
TREF(compile_time) = FALSE;
|
|
|
|
if (stringpool.base != rts_stringpool.base)
|
|
|
|
stringpool = rts_stringpool;
|
|
|
|
}
|
|
|
|
for (fp = frame_pointer; fp; fp = fpprev)
|
|
|
|
{
|
|
|
|
fpprev = fp->old_frame_pointer;
|
|
|
|
# ifdef GTM_TRIGGER
|
|
|
|
if (SFT_TRIGR & fpprev->type)
|
|
|
|
fpprev = *(stack_frame **)(fpprev + 1);
|
|
|
|
# endif
|
|
|
|
if (fp->type & SFT_DM)
|
|
|
|
break;
|
|
|
|
if (fp->type & SFT_COUNT)
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
if ((ERR_ERRWZTRAP == errmsg) || (ERR_ERRWETRAP == errmsg))
|
2012-02-05 11:35:58 -05:00
|
|
|
{ /* Whether ETRAP or ZTRAP we want to rethrow the error at one level down */
|
|
|
|
SET_ERROR_FRAME(fp); /* reset error_frame to point to the closest counted frame */
|
|
|
|
assert(fp->flags & SFF_ETRAP_ERR);
|
|
|
|
/* Turn off any device exception related flags now that we are going to handle errors using
|
|
|
|
* $ETRAP or $ZTRAP AT THE PARENT LEVEL only (no more device exceptions).
|
|
|
|
*/
|
|
|
|
dollar_ztrap.str.len = 0;
|
2012-03-24 14:06:46 -04:00
|
|
|
ztrap_explicit_null = FALSE;
|
|
|
|
fp->flags &= SFF_DEV_ACT_ERR_OFF;
|
|
|
|
fp->flags &= SFF_ZTRAP_ERR_OFF;
|
2012-02-05 11:35:58 -05:00
|
|
|
err_act = &dollar_etrap.str;
|
2012-03-24 14:06:46 -04:00
|
|
|
break;
|
|
|
|
} else if (ERR_ERRWIOEXC == errmsg)
|
2012-02-05 11:35:58 -05:00
|
|
|
{ /* Error while compiling device exception. Set SFF_ETRAP_ERR bit so control is transferred to
|
|
|
|
* error_return() which in turn will rethrow the error AT THE SAME LEVEL in order to try and
|
|
|
|
* use $ZTRAP or $ETRAP whichever is active. Also set the SFF_DEV_ACT_ERR bit to signify this
|
|
|
|
* is a device exception that is rethrown instead of a ztrap/etrap error. Also assert that
|
|
|
|
* the rethrow will not use IO exception again (thereby ensuring error processing will
|
|
|
|
* eventually terminate instead of indefinitely recursing).
|
|
|
|
*/
|
|
|
|
fp->flags |= (SFF_DEV_ACT_ERR | SFF_ETRAP_ERR);
|
|
|
|
assert(NULL == active_device); /* mdb_condition_handler should have reset it */
|
2012-03-24 14:06:46 -04:00
|
|
|
break;
|
|
|
|
} else if ((ERR_ERRWZBRK == errmsg) || (ERR_ERRWEXC == errmsg))
|
2012-02-05 11:35:58 -05:00
|
|
|
{ /* For typical exceptions in ZBREAK and ZSTEP, get back to direct mode */
|
|
|
|
dm_setup();
|
2012-03-24 14:06:46 -04:00
|
|
|
break;
|
2012-02-05 11:35:58 -05:00
|
|
|
} else
|
2012-03-24 14:06:46 -04:00
|
|
|
{ /* The only known way to be here is if the command is a command given in direct mode as
|
|
|
|
* mdb_condition_handler won't drive an error handler in that case which would be caught in
|
|
|
|
* one of the above conditions. Not breaking out of the loop here means the frame will just
|
|
|
|
* unwind and we'll break on the direct mode frame which will be redriven. If the parent frame
|
|
|
|
* is not a direct mode frame, we'll assert in debug or break in pro and just continue.
|
|
|
|
* to direct mode.
|
2012-02-05 11:35:58 -05:00
|
|
|
*/
|
2012-03-24 14:06:46 -04:00
|
|
|
assert(fp->flags && (SFF_INDCE));
|
|
|
|
if (!fp->old_frame_pointer || !(fp->old_frame_pointer->type & SFT_DM))
|
|
|
|
{
|
|
|
|
assert(FALSE);
|
|
|
|
break;
|
|
|
|
}
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (fp->type)
|
|
|
|
{
|
2012-03-24 14:06:46 -04:00
|
|
|
SET_ERR_CODE(fp, errmsg);
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|
|
|
|
/* If this frame is indicated for cache cleanup, do that cleanup
|
|
|
|
* now before we get rid of the pointers used by that cleanup.
|
|
|
|
*/
|
|
|
|
IF_INDR_FRAME_CLEANUP_CACHE_ENTRY_AND_UNMARK(fp);
|
|
|
|
fp->mpc = CODE_ADDRESS(pseudo_ret);
|
|
|
|
fp->ctxt = GTM_CONTEXT(pseudo_ret);
|
2012-10-29 18:54:31 -04:00
|
|
|
fp->flags &= SFF_IMPLTSTART_CALLD_OFF; /* Frame enterable now with mpc reset */
|
|
|
|
GTMTRIG_ONLY(DBGTRIGR((stderr, "trans_code_cleanup: turning off SFF_IMPLTSTART_CALLD in frame 0x"lvaddr"\n",
|
2012-02-05 11:35:58 -05:00
|
|
|
frame_pointer)));
|
|
|
|
}
|
|
|
|
TREF(transform) = TRUE;
|
2012-03-24 14:06:46 -04:00
|
|
|
if (0 != errmsg)
|
|
|
|
dec_err(VARLSTCNT(1) errmsg);
|
2012-02-05 11:35:58 -05:00
|
|
|
}
|