int hash = 0;
if (obj == NULL)
- return 0;
+ return NULL;
if (suspend_count) {
/*
static inline int
get_objid (MonoObject *obj)
{
- return get_objref (obj)->id;
+ if (!obj)
+ return 0;
+ else
+ return get_objref (obj)->id;
}
/*
DEBUG_PRINTF (1, "[%p] Interrupting %p...\n", (gpointer) (gsize) mono_native_thread_id_get (), (gpointer)tid);
- /* This is _not_ equivalent to ves_icall_System_Threading_Thread_Abort () */
+ /* This is _not_ equivalent to mono_thread_internal_abort () */
InterruptData interrupt_data = { 0 };
interrupt_data.tls = tls;
ecount ++;
- if (!thread)
- thread = mono_thread_current ();
+ if (event == EVENT_KIND_VM_DEATH) {
+ thread = NULL;
+ } else {
+ if (!thread)
+ thread = mono_thread_current ();
- if (event == EVENT_KIND_VM_START && arg != NULL)
- thread = (MonoThread *)arg;
+ if (event == EVENT_KIND_VM_START && arg != NULL)
+ thread = (MonoThread *)arg;
+ }
buffer_add_objid (&buf, (MonoObject*)thread); // thread
static void
runtime_shutdown (MonoProfiler *prof)
{
- process_profiler_event (EVENT_KIND_VM_DEATH, mono_thread_current ());
+ process_profiler_event (EVENT_KIND_VM_DEATH, NULL);
mono_debugger_agent_cleanup ();
}
code = mono_jit_find_compiled_method_with_jit_info (domain, method, &ji);
if (!code) {
+ MonoError oerror;
+
/* Might be AOTed code */
- code = mono_aot_get_method (domain, method);
+ code = mono_aot_get_method_checked (domain, method, &oerror);
g_assert (code);
+ mono_error_assert_ok (&oerror);
ji = mono_jit_info_table_find (domain, (char *)code);
g_assert (ji);
}
void
mono_debugger_agent_debug_log (int level, MonoString *category, MonoString *message)
{
+ MonoError error;
int suspend_policy;
GSList *events;
EventInfo ei;
mono_loader_unlock ();
ei.level = level;
- ei.category = category ? mono_string_to_utf8 (category) : NULL;
- ei.message = message ? mono_string_to_utf8 (message) : NULL;
+ ei.category = NULL;
+ if (category) {
+ ei.category = mono_string_to_utf8_checked (category, &error);
+ mono_error_cleanup (&error);
+ }
+ ei.message = NULL;
+ if (message) {
+ ei.message = mono_string_to_utf8_checked (message, &error);
+ mono_error_cleanup (&error);
+ }
process_event (EVENT_KIND_USER_LOG, &ei, 0, NULL, events, suspend_policy);
/*
* Take the loader lock to avoid race conditions with CMD_VM_ABORT_INVOKE:
*
- * It is possible that ves_icall_System_Threading_Thread_Abort () was called
+ * It is possible that mono_thread_internal_abort () was called
* after the mono_runtime_invoke_checked() already returned, but it doesn't matter
* because we reset the abort here.
*/
tls->abort_requested = TRUE;
- ves_icall_System_Threading_Thread_Abort (THREAD_TO_INTERNAL (thread), NULL);
+ mono_thread_internal_abort (THREAD_TO_INTERNAL (thread));
mono_loader_unlock ();
break;
}
static void
buffer_add_cattr_arg (Buffer *buf, MonoType *t, MonoDomain *domain, MonoObject *val)
{
- if (val && val->vtable->klass == mono_defaults.monotype_class) {
+ if (val && val->vtable->klass == mono_defaults.runtimetype_class) {
/* Special case these so the client doesn't have to handle Type objects */
buffer_add_byte (buf, VALUE_TYPE_ID_TYPE);
// FIXME: Generics
switch (mono_metadata_token_code (token)) {
case MONO_TOKEN_STRING: {
+ MonoError error;
MonoString *s;
char *s2;
- s = mono_ldstr (domain, method->klass->image, mono_metadata_token_index (token));
- g_assert (s);
+ s = mono_ldstr_checked (domain, method->klass->image, mono_metadata_token_index (token), &error);
+ mono_error_assert_ok (&error); /* FIXME don't swallow the error */
- s2 = mono_string_to_utf8 (s);
+ s2 = mono_string_to_utf8_checked (s, &error);
+ mono_error_assert_ok (&error);
buffer_add_byte (buf, TOKEN_TYPE_STRING);
buffer_add_string (buf, s2);
break;
}
default: {
+ MonoError error;
gpointer val;
MonoClass *handle_class;
break;
}
} else {
- MonoError error;
val = mono_ldtoken_checked (method->klass->image, token, &handle_class, NULL, &error);
if (!val)
g_error ("Could not load token due to %s", mono_error_get_message (&error));
} else if (handle_class == mono_defaults.string_class) {
char *s;
- s = mono_string_to_utf8 ((MonoString *)val);
+ s = mono_string_to_utf8_checked ((MonoString *)val, &error);
+ mono_error_assert_ok (&error);
buffer_add_byte (buf, TOKEN_TYPE_STRING);
buffer_add_string (buf, s);
g_free (s);
buffer_add_int (buf, mono_string_length (str) * 2);
buffer_add_data (buf, (guint8*)mono_string_chars (str), mono_string_length (str) * 2);
} else {
- s = mono_string_to_utf8 (str);
+ MonoError error;
+ s = mono_string_to_utf8_checked (str, &error);
+ mono_error_assert_ok (&error);
buffer_add_string (buf, s);
g_free (s);
}
ErrorCode err;
gboolean no_reply;
gboolean attach_failed = FALSE;
- gpointer attach_cookie, attach_dummy;
DEBUG_PRINTF (1, "[dbg] Agent thread started, pid=%p\n", (gpointer) (gsize) mono_native_thread_id_get ());
debugger_thread_id = mono_native_thread_id_get ();
- attach_cookie = mono_jit_thread_attach (mono_get_root_domain (), &attach_dummy);
- MonoInternalThread *thread = mono_thread_internal_current ();
- mono_thread_set_name_internal (thread, mono_string_new (mono_get_root_domain (), "Debugger agent"), TRUE, &error);
+ MonoThread *thread = mono_thread_attach (mono_get_root_domain ());
+ mono_thread_set_name_internal (thread->internal_thread, mono_string_new (mono_get_root_domain (), "Debugger agent"), TRUE, &error);
mono_error_assert_ok (&error);
- thread->flags |= MONO_THREAD_FLAG_DONT_MANAGE;
+ thread->internal_thread->state |= ThreadState_Background;
+ thread->internal_thread->flags |= MONO_THREAD_FLAG_DONT_MANAGE;
mono_set_is_debugger_attached (TRUE);
start_debugger_thread ();
}
- mono_jit_thread_detach (attach_cookie, &attach_dummy);
-
return 0;
}