Beispiel #1
0
void
mono_arm_throw_exception_by_token (guint32 type_token, mgreg_t pc, mgreg_t sp, mgreg_t *int_regs, gdouble *fp_regs)
{
	/* Clear thumb bit */
	pc &= ~1;

	mono_arm_throw_exception ((MonoObject*)mono_exception_from_token (mono_defaults.corlib, type_token), pc, sp, int_regs, fp_regs);
}
Beispiel #2
0
void
mono_arm_throw_exception_by_token (guint32 ex_token_index, mgreg_t pc, mgreg_t sp, mgreg_t *int_regs, gdouble *fp_regs)
{
	guint32 ex_token = MONO_TOKEN_TYPE_DEF | ex_token_index;
	/* Clear thumb bit */
	pc &= ~1;

	mono_arm_throw_exception ((MonoObject*)mono_exception_from_token (mono_defaults.corlib, ex_token), pc, sp, int_regs, fp_regs);
}
Beispiel #3
0
static void
mono_x86_throw_corlib_exception (mgreg_t *regs, guint32 ex_token_index, 
								 mgreg_t eip, gint32 pc_offset)
{
	guint32 ex_token = MONO_TOKEN_TYPE_DEF | ex_token_index;
	MonoException *ex;

	ex = mono_exception_from_token (mono_defaults.exception_class->image, ex_token);

	eip -= pc_offset;

	mono_x86_throw_exception (regs, (MonoObject*)ex, eip, FALSE);
}
Beispiel #4
0
void
mono_x86_throw_corlib_exception (mgreg_t *regs, guint32 ex_token_index, 
								 mgreg_t eip, gint32 pc_offset)
{
	guint32 ex_token = MONO_TOKEN_TYPE_DEF | ex_token_index;
	MonoException *ex;

	ex = mono_exception_from_token (m_class_get_image (mono_defaults.exception_class), ex_token);

	eip -= pc_offset;

	/* Negate the ip adjustment done in mono_x86_throw_exception () */
	eip += 1;

	mono_x86_throw_exception (regs, (MonoObject*)ex, eip, FALSE);
}
Beispiel #5
0
void
mono_amd64_throw_corlib_exception (guint64 dummy1, guint64 dummy2, guint64 dummy3, guint64 dummy4,
								   guint64 dummy5, guint64 dummy6,
								   MonoContext *mctx, guint32 ex_token_index, gint64 pc_offset)
{
	guint32 ex_token = MONO_TOKEN_TYPE_DEF | ex_token_index;
	MonoException *ex;

	ex = mono_exception_from_token (mono_defaults.exception_class->image, ex_token);

	mctx->gregs [AMD64_RIP] -= pc_offset;

	/* Negate the ip adjustment done in mono_amd64_throw_exception () */
	mctx->gregs [AMD64_RIP] += 1;

	mono_amd64_throw_exception (dummy1, dummy2, dummy3, dummy4, dummy5, dummy6, mctx, (MonoObject*)ex, FALSE);
}
Beispiel #6
0
void
mono_amd64_throw_corlib_exception (guint64 dummy1, guint64 dummy2, guint64 dummy3, guint64 dummy4,
								   guint64 dummy5, guint64 dummy6,
								   mgreg_t *regs, mgreg_t rip,
								   guint32 ex_token_index, gint64 pc_offset)
{
	guint32 ex_token = MONO_TOKEN_TYPE_DEF | ex_token_index;
	MonoException *ex;

	ex = mono_exception_from_token (mono_defaults.exception_class->image, ex_token);

	rip -= pc_offset;

	/* Negate the ip adjustment done in mono_amd64_throw_exception () */
	rip += 1;

	mono_amd64_throw_exception (dummy1, dummy2, dummy3, dummy4, dummy5, dummy6, regs, rip, (MonoObject*)ex, FALSE);
}
Beispiel #7
0
/*
 * mono_arm_throw_exception:
 *
 *   This function is called by the exception trampolines.
 * FP_REGS points to the 8 callee saved fp regs.
 */
void
mono_arm_throw_exception (gpointer arg, mgreg_t pc, mgreg_t *int_regs, gdouble *fp_regs, gboolean corlib, gboolean rethrow)
{
    MonoError error;
    MonoContext ctx;
    MonoObject *exc = NULL;
    guint32 ex_token_index, ex_token;

    if (!corlib)
        exc = arg;
    else {
        ex_token_index = (guint64)arg;
        ex_token = MONO_TOKEN_TYPE_DEF | ex_token_index;
        exc = (MonoObject*)mono_exception_from_token (mono_defaults.corlib, ex_token);
    }

    /* Adjust pc so it points into the call instruction */
    pc -= 4;

    /* Initialize a ctx based on the arguments */
    memset (&ctx, 0, sizeof (MonoContext));
    memcpy (&(ctx.regs [0]), int_regs, sizeof (mgreg_t) * 32);
    memcpy (&(ctx.fregs [ARMREG_D8]), fp_regs, sizeof (double) * 8);
    ctx.has_fregs = 1;
    ctx.pc = pc;

    if (mono_object_isinst_checked (exc, mono_defaults.exception_class, &error)) {
        MonoException *mono_ex = (MonoException*)exc;
        if (!rethrow) {
            mono_ex->stack_trace = NULL;
            mono_ex->trace_ips = NULL;
        }
    }
    mono_error_assert_ok (&error);

    mono_handle_exception (&ctx, exc);

    mono_restore_context (&ctx);
}
void
mono_arm_throw_exception_by_token (guint32 type_token, unsigned long eip, unsigned long esp, gulong *int_regs, gdouble *fp_regs)
{
	mono_arm_throw_exception ((MonoObject*)mono_exception_from_token (mono_defaults.corlib, type_token), eip, esp, int_regs, fp_regs);
}