/*g_print ("bitmap 0x%x for %s.%s (size: %d)\n", bitmap [0], klass->name_space, klass->name, class_size);*/
statics_gc_descr = mono_gc_make_descr_from_bitmap (bitmap, max_set + 1);
vt->vtable [klass->vtable_size] = mono_gc_alloc_fixed (class_size, statics_gc_descr, MONO_ROOT_SOURCE_STATIC, "managed static variables");
- mono_domain_add_class_static_data (domain, klass, vt->vtable [klass->vtable_size], NULL);
if (bitmap != default_bitmap)
g_free (bitmap);
} else {
* a warning to the console
*/
void
-mono_unhandled_exception (MonoObject *exc)
+mono_unhandled_exception (MonoObject *exc_raw)
+{
+ MonoError error;
+ HANDLE_FUNCTION_ENTER ();
+ MONO_HANDLE_DCL (MonoObject, exc);
+ error_init (&error);
+ mono_unhandled_exception_checked (exc, &error);
+ mono_error_assert_ok (&error);
+ HANDLE_FUNCTION_RETURN ();
+}
+
+/**
+ * mono_unhandled_exception:
+ * @exc: exception thrown
+ *
+ * This is a VM internal routine.
+ *
+ * We call this function when we detect an unhandled exception
+ * in the default domain.
+ *
+ * It invokes the * UnhandledException event in AppDomain or prints
+ * a warning to the console
+ */
+void
+mono_unhandled_exception_checked (MonoObjectHandle exc, MonoError *error)
{
MONO_REQ_GC_UNSAFE_MODE;
- MonoError error;
+ error_init (error);
MonoClassField *field;
MonoDomain *current_domain, *root_domain;
- MonoObject *current_appdomain_delegate = NULL, *root_appdomain_delegate = NULL;
+ MonoObjectHandle current_appdomain_delegate = MONO_HANDLE_NEW (MonoObject, NULL);
- if (mono_class_has_parent (exc->vtable->klass, mono_defaults.threadabortexception_class))
+ MonoClass *klass = mono_handle_class (exc);
+ if (mono_class_has_parent (klass, mono_defaults.threadabortexception_class))
return;
field = mono_class_get_field_from_name (mono_defaults.appdomain_class, "UnhandledException");
current_domain = mono_domain_get ();
root_domain = mono_get_root_domain ();
- root_appdomain_delegate = mono_field_get_value_object_checked (root_domain, field, (MonoObject*) root_domain->domain, &error);
- mono_error_assert_ok (&error);
+ MonoObjectHandle root_appdomain_delegate = MONO_HANDLE_NEW (MonoObject, mono_field_get_value_object_checked (root_domain, field, (MonoObject*) root_domain->domain, error)); /* FIXME use handles for mono_field_get_value_object_checked */
+ return_if_nok (error);
if (current_domain != root_domain) {
- current_appdomain_delegate = mono_field_get_value_object_checked (current_domain, field, (MonoObject*) current_domain->domain, &error);
- mono_error_assert_ok (&error);
+ MONO_HANDLE_ASSIGN (current_appdomain_delegate, MONO_HANDLE_NEW (MonoObject, mono_field_get_value_object_checked (current_domain, field, (MonoObject*) current_domain->domain, error))); /* FIXME use handles for mono_field_get_value_object_checked */
+ return_if_nok (error);
}
- if (!current_appdomain_delegate && !root_appdomain_delegate) {
- mono_print_unhandled_exception (exc);
+ if (MONO_HANDLE_IS_NULL (current_appdomain_delegate) && MONO_HANDLE_IS_NULL (root_appdomain_delegate)) {
+ mono_print_unhandled_exception (MONO_HANDLE_RAW (exc)); /* FIXME use handles for mono_print_unhandled_exception */
} else {
/* unhandled exception callbacks must not be aborted */
mono_threads_begin_abort_protected_block ();
- if (root_appdomain_delegate)
- call_unhandled_exception_delegate (root_domain, root_appdomain_delegate, exc);
- if (current_appdomain_delegate)
- call_unhandled_exception_delegate (current_domain, current_appdomain_delegate, exc);
+ if (!MONO_HANDLE_IS_NULL (root_appdomain_delegate))
+ call_unhandled_exception_delegate (root_domain, MONO_HANDLE_RAW (root_appdomain_delegate), MONO_HANDLE_RAW (exc)); /* FIXME use handles in call_unhandled_exception_delegate */
+ if (!MONO_HANDLE_IS_NULL (current_appdomain_delegate))
+ call_unhandled_exception_delegate (current_domain, MONO_HANDLE_RAW (current_appdomain_delegate), MONO_HANDLE_RAW (exc));
mono_threads_end_abort_protected_block ();
}