static void SIG_HANDLER_SIGNATURE (sigquit_signal_handler) { gboolean res; GET_CONTEXT; /* We use this signal to start the attach agent too */ res = mono_attach_start (); if (res) return; if (mono_thread_info_new_interrupt_enabled ()) { mono_threads_request_thread_dump (); } else { printf ("Full thread dump:\n"); mono_threads_request_thread_dump (); /* * print_thread_dump () skips the current thread, since sending a signal * to it would invoke the signal handler below the sigquit signal handler, * and signal handlers don't create an lmf, so the stack walk could not * be performed. */ mono_print_thread_dump (ctx); } mono_chain_signal (SIG_HANDLER_PARAMS); }
SIG_HANDLER_FUNC (static, sigprof_signal_handler) { if (mono_chain_signal (SIG_HANDLER_PARAMS)) return; NOT_IMPLEMENTED; }
static void SIG_HANDLER_SIGNATURE (sigprof_signal_handler) { if (mono_chain_signal (SIG_HANDLER_PARAMS)) return; NOT_IMPLEMENTED; }
SIG_HANDLER_FUNC (static, sigusr2_signal_handler) { gboolean enabled = mono_trace_is_enabled (); mono_trace_enable (!enabled); mono_chain_signal (SIG_HANDLER_PARAMS); }
static void SIG_HANDLER_SIGNATURE (sigusr2_signal_handler) { gboolean enabled = mono_trace_is_enabled (); mono_trace_enable (!enabled); mono_chain_signal (SIG_HANDLER_PARAMS); }
SIG_HANDLER_FUNC (static, sigabrt_signal_handler) { MonoJitInfo *ji = NULL; GET_CONTEXT; if (mono_thread_internal_current ()) ji = mono_jit_info_table_find (mono_domain_get (), mono_arch_ip_from_context(ctx)); if (!ji) { if (mono_chain_signal (SIG_HANDLER_PARAMS)) return; mono_handle_native_sigsegv (SIGABRT, ctx); } }
MONO_SIG_HANDLER_FUNC (static, sigquit_signal_handler) { gboolean res; /* We use this signal to start the attach agent too */ res = mono_attach_start (); if (res) return; mono_threads_request_thread_dump (); mono_chain_signal (MONO_SIG_HANDLER_PARAMS); }
MONO_SIG_HANDLER_FUNC (static, sigabrt_signal_handler) { MonoJitInfo *ji = NULL; MONO_SIG_HANDLER_INFO_TYPE *info = MONO_SIG_HANDLER_GET_INFO (); MONO_SIG_HANDLER_GET_CONTEXT; if (mono_thread_internal_current ()) ji = mono_jit_info_table_find_internal (mono_domain_get (), mono_arch_ip_from_context (ctx), TRUE, TRUE); if (!ji) { if (mono_chain_signal (MONO_SIG_HANDLER_PARAMS)) return; mono_handle_native_crash ("SIGABRT", ctx, info); } }
MONO_SIG_HANDLER_FUNC (static, sigterm_signal_handler) { MONO_SIG_HANDLER_GET_CONTEXT; // Note: this function only returns for a single thread // When it's invoked on other threads once the dump begins, // those threads perform their dumps and then sleep until we // die. The dump ends with the exit(1) below MonoContext mctx; gchar *output = NULL; mono_sigctx_to_monoctx (ctx, &mctx); if (!mono_threads_summarize (&mctx, &output, NULL)) g_assert_not_reached (); // Only the dumping-supervisor thread exits mono_thread_summarize MOSTLY_ASYNC_SAFE_PRINTF("Unhandled exception dump: \n######\n%s\n######\n", output); mono_chain_signal (MONO_SIG_HANDLER_PARAMS); exit (1); }
MONO_SIG_HANDLER_FUNC (static, profiler_signal_handler) { int old_errno = errno; MONO_SIG_HANDLER_GET_CONTEXT; /* See the comment in mono_runtime_shutdown_stat_profiler (). */ if (mono_native_thread_id_get () == sampling_thread) { mono_atomic_inc_i32 (&profiler_interrupt_signals_received); return; } mono_atomic_inc_i32 (&profiler_signals_received); // Did a non-attached or detaching thread get the signal? if (mono_thread_info_get_small_id () == -1 || !mono_domain_get () || !mono_tls_get_jit_tls ()) { errno = old_errno; return; } // See the comment in sampling_thread_func (). mono_atomic_store_i32 (&mono_thread_info_current ()->profiler_signal_ack, 1); mono_atomic_inc_i32 (&profiler_signals_accepted); int hp_save_index = mono_hazard_pointer_save_for_signal_handler (); mono_thread_info_set_is_async_context (TRUE); MONO_PROFILER_RAISE (sample_hit, (mono_arch_ip_from_context (ctx), ctx)); mono_thread_info_set_is_async_context (FALSE); mono_hazard_pointer_restore_for_signal_handler (hp_save_index); errno = old_errno; mono_chain_signal (MONO_SIG_HANDLER_PARAMS); }
static void SIG_HANDLER_SIGNATURE (sigprof_signal_handler) { int call_chain_depth = mono_profiler_stat_get_call_chain_depth (); MonoProfilerCallChainStrategy call_chain_strategy = mono_profiler_stat_get_call_chain_strategy (); GET_CONTEXT; if (call_chain_depth == 0) { mono_profiler_stat_hit (mono_arch_ip_from_context (ctx), ctx); } else { MonoJitTlsData *jit_tls = mono_native_tls_get_value (mono_jit_tls_id); int current_frame_index = 1; MonoContext mono_context; guchar *ips [call_chain_depth + 1]; mono_arch_sigctx_to_monoctx (ctx, &mono_context); ips [0] = MONO_CONTEXT_GET_IP (&mono_context); if (jit_tls != NULL) { if (call_chain_strategy == MONO_PROFILER_CALL_CHAIN_NATIVE) { #if FULL_STAT_PROFILER_BACKTRACE guchar *current_frame; guchar *stack_bottom; guchar *stack_top; stack_bottom = jit_tls->end_of_stack; stack_top = MONO_CONTEXT_GET_SP (&mono_context); current_frame = MONO_CONTEXT_GET_BP (&mono_context); while ((current_frame_index <= call_chain_depth) && (stack_bottom IS_BEFORE_ON_STACK (guchar*) current_frame) && ((guchar*) current_frame IS_BEFORE_ON_STACK stack_top)) { ips [current_frame_index] = CURRENT_FRAME_GET_RETURN_ADDRESS (current_frame); current_frame_index ++; stack_top = current_frame; current_frame = CURRENT_FRAME_GET_BASE_POINTER (current_frame); } #else call_chain_strategy = MONO_PROFILER_CALL_CHAIN_GLIBC; #endif } if (call_chain_strategy == MONO_PROFILER_CALL_CHAIN_GLIBC) { #if GLIBC_PROFILER_BACKTRACE current_frame_index = backtrace ((void**) & ips [1], call_chain_depth); #else call_chain_strategy = MONO_PROFILER_CALL_CHAIN_MANAGED; #endif } if (call_chain_strategy == MONO_PROFILER_CALL_CHAIN_MANAGED) { MonoDomain *domain = mono_domain_get (); if (domain != NULL) { MonoLMF *lmf = NULL; MonoJitInfo *ji; MonoJitInfo res; MonoContext new_mono_context; int native_offset; ji = mono_find_jit_info (domain, jit_tls, &res, NULL, &mono_context, &new_mono_context, NULL, &lmf, &native_offset, NULL); while ((ji != NULL) && (current_frame_index <= call_chain_depth)) { ips [current_frame_index] = MONO_CONTEXT_GET_IP (&new_mono_context); current_frame_index ++; mono_context = new_mono_context; ji = mono_find_jit_info (domain, jit_tls, &res, NULL, &mono_context, &new_mono_context, NULL, &lmf, &native_offset, NULL); } } } } mono_profiler_stat_call_chain (current_frame_index, & ips [0], ctx); } mono_chain_signal (SIG_HANDLER_PARAMS); }