diff options
author | Jay Krell <jaykrell@microsoft.com> | 2019-08-30 06:45:59 +0300 |
---|---|---|
committer | Larry Ewing <lewing@microsoft.com> | 2019-09-04 18:31:22 +0300 |
commit | 14afe79a0ab064ea769025ded95ae961e8df8247 (patch) | |
tree | da97917c874e5e027b2a9beae65b116f17bdf6eb | |
parent | 30625b25df4e3d83f6abb30cea2bd57ff0c49539 (diff) |
[Coop] GetStackTraces.
-rw-r--r-- | mono/metadata/icall-def.h | 2 | ||||
-rw-r--r-- | mono/metadata/threads-types.h | 3 | ||||
-rw-r--r-- | mono/metadata/threads.c | 41 |
3 files changed, 23 insertions, 23 deletions
diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 39bac4179f2..94704a79154 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -1039,7 +1039,7 @@ HANDLES(THREAD_60, "GetCurrentThread", ves_icall_System_Threading_Thread_GetCurr HANDLES(THREAD_7, "GetDomainID", ves_icall_System_Threading_Thread_GetDomainID, gint32, 0, ()) HANDLES(THREAD_8, "GetName_internal(System.Threading.InternalThread)", ves_icall_System_Threading_Thread_GetName_internal, MonoString, 1, (MonoInternalThread)) HANDLES(THREAD_57, "GetPriorityNative", ves_icall_System_Threading_Thread_GetPriority, int, 1, (MonoThreadObject)) -ICALL(THREAD_59, "GetStackTraces", ves_icall_System_Threading_Thread_GetStackTraces) +HANDLES(THREAD_59, "GetStackTraces", ves_icall_System_Threading_Thread_GetStackTraces, void, 2, (MonoArrayOut, MonoArrayOut)) HANDLES(THREAD_11, "GetState(System.Threading.InternalThread)", ves_icall_System_Threading_Thread_GetState, guint32, 1, (MonoInternalThread)) HANDLES(THREAD_53, "InterruptInternal", ves_icall_System_Threading_Thread_Interrupt_internal, void, 1, (MonoThreadObject)) HANDLES(THREAD_12, "JoinInternal", ves_icall_System_Threading_Thread_Join_internal, MonoBoolean, 2, (MonoThreadObject, int)) diff --git a/mono/metadata/threads-types.h b/mono/metadata/threads-types.h index 09188fc455c..f692e5b6a8b 100644 --- a/mono/metadata/threads-types.h +++ b/mono/metadata/threads-types.h @@ -410,9 +410,6 @@ void mono_threads_add_joinable_thread (gpointer tid); void mono_threads_join_threads (void); void mono_thread_join (gpointer tid); -ICALL_EXPORT -void ves_icall_System_Threading_Thread_GetStackTraces (MonoArray **out_threads, MonoArray **out_stack_traces); - MONO_API gpointer mono_threads_attach_coop (MonoDomain *domain, gpointer *dummy); diff --git a/mono/metadata/threads.c b/mono/metadata/threads.c index 188c45e04a8..79dae03773c 100644 --- a/mono/metadata/threads.c +++ b/mono/metadata/threads.c @@ -4094,20 +4094,25 @@ mono_threads_perform_thread_dump (void) } /* Obtain the thread dump of all threads */ -static gboolean -mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_frames, MonoError *error) +void +ves_icall_System_Threading_Thread_GetStackTraces (MonoArrayHandleOut out_threads_handle, MonoArrayHandleOut out_stack_frames_handle, MonoError *error) { + MonoStackFrameHandle stack_frame_handle = MONO_HANDLE_NEW (MonoStackFrame, NULL); + MonoReflectionMethodHandle reflection_method_handle = MONO_HANDLE_NEW (MonoReflectionMethod, NULL); + MonoStringHandle filename_handle = MONO_HANDLE_NEW (MonoString, NULL); + MonoArrayHandle thread_frames_handle = MONO_HANDLE_NEW (MonoArray, NULL); ThreadDumpUserData ud; guint32 thread_array [128]; MonoDomain *domain = mono_domain_get (); MonoDebugSourceLocation *location; int tindex, nthreads; - - error_init (error); - *out_threads = NULL; - *out_stack_frames = NULL; + MonoArray* out_threads = NULL; + MonoArray* out_stack_frames = NULL; + + MONO_HANDLE_ASSIGN_RAW (out_threads_handle, NULL); + MONO_HANDLE_ASSIGN_RAW (out_stack_frames_handle, NULL); /* Make a copy of the threads hash to avoid doing work inside threads_lock () */ nthreads = collect_threads (thread_array, 128); @@ -4116,12 +4121,15 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra ud.frames = g_new0 (MonoStackFrameInfo, 256); ud.max_frames = 256; - *out_threads = mono_array_new_checked (domain, mono_defaults.thread_class, nthreads, error); + out_threads = mono_array_new_checked (domain, mono_defaults.thread_class, nthreads, error); goto_if_nok (error, leave); - *out_stack_frames = mono_array_new_checked (domain, mono_defaults.array_class, nthreads, error); + MONO_HANDLE_ASSIGN_RAW (out_threads_handle, out_threads); + out_stack_frames = mono_array_new_checked (domain, mono_defaults.array_class, nthreads, error); goto_if_nok (error, leave); + MONO_HANDLE_ASSIGN_RAW (out_stack_frames_handle, out_stack_frames); for (tindex = 0; tindex < nthreads; ++tindex) { + guint32 handle = thread_array [tindex]; MonoInternalThread *thread = (MonoInternalThread *) mono_gchandle_get_target_internal (handle); @@ -4138,16 +4146,18 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra mono_thread_info_safe_suspend_and_run (thread_get_tid (thread), FALSE, get_thread_dump, &ud); } - mono_array_setref_fast (*out_threads, tindex, mono_thread_current_for_thread (thread)); + mono_array_setref_fast (out_threads, tindex, mono_thread_current_for_thread (thread)); thread_frames = mono_array_new_checked (domain, mono_defaults.stack_frame_class, ud.nframes, error); + MONO_HANDLE_ASSIGN_RAW (thread_frames_handle, thread_frames); goto_if_nok (error, leave); - mono_array_setref_fast (*out_stack_frames, tindex, thread_frames); + mono_array_setref_fast (out_stack_frames, tindex, thread_frames); for (i = 0; i < ud.nframes; ++i) { MonoStackFrameInfo *frame = &ud.frames [i]; MonoMethod *method = NULL; MonoStackFrame *sf = (MonoStackFrame *)mono_object_new_checked (domain, mono_defaults.stack_frame_class, error); + MONO_HANDLE_ASSIGN_RAW (stack_frame_handle, sf); goto_if_nok (error, leave); sf->native_offset = frame->native_offset; @@ -4159,6 +4169,7 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra sf->method_address = (gsize) frame->ji->code_start; MonoReflectionMethod *rm = mono_method_get_object_checked (domain, method, NULL, error); + MONO_HANDLE_ASSIGN_RAW (reflection_method_handle, rm); goto_if_nok (error, leave); MONO_OBJECT_SETREF_INTERNAL (sf, method, rm); @@ -4168,6 +4179,7 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra if (location->source_file) { MonoString *filename = mono_string_new_checked (domain, location->source_file, error); + MONO_HANDLE_ASSIGN_RAW (filename_handle, filename); goto_if_nok (error, leave); MONO_OBJECT_SETREF_INTERNAL (sf, filename, filename); sf->line = location->row; @@ -4186,7 +4198,6 @@ mono_threads_get_thread_dump (MonoArray **out_threads, MonoArray **out_stack_fra leave: g_free (ud.frames); - return is_ok (error); } /** @@ -5952,14 +5963,6 @@ mono_thread_internal_unhandled_exception (MonoObject* exc) } } -void -ves_icall_System_Threading_Thread_GetStackTraces (MonoArray **out_threads, MonoArray **out_stack_traces) -{ - ERROR_DECL (error); - mono_threads_get_thread_dump (out_threads, out_stack_traces, error); - mono_error_set_pending_exception (error); -} - /* * mono_threads_attach_coop_internal: called by native->managed wrappers * |