Skip to content

Commit

Permalink
add more info to SIGUSR1 printing
Browse files Browse the repository at this point in the history
This is similar to what the kernel prints for us when sent SIGINFO, and
can be sometimes useful for getting the pid of a process, and other
status details.
  • Loading branch information
vtjnash authored and LilithHafner committed Mar 8, 2022
1 parent 7a81fe9 commit 7699e7b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/signal-handling.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ void jl_show_sigill(void *_ctx)
// what to do on a critical error on a thread
void jl_critical_error(int sig, bt_context_t *context, jl_task_t *ct)
{

jl_bt_element_t *bt_data = ct ? ct->ptls->bt_data : NULL;
size_t *bt_size = ct ? &ct->ptls->bt_size : NULL;
size_t i, n = ct ? *bt_size : 0;
Expand Down
17 changes: 13 additions & 4 deletions src/signals-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -790,19 +790,19 @@ static void *signal_listener(void *arg)
}
jl_set_safe_restore(old_buf);

jl_ptls_t ptls = jl_all_tls_states[i];
jl_ptls_t ptls2 = jl_all_tls_states[i];

// store threadid but add 1 as 0 is preserved to indicate end of block
bt_data_prof[bt_size_cur++].uintptr = ptls->tid + 1;
bt_data_prof[bt_size_cur++].uintptr = ptls2->tid + 1;

// store task id
bt_data_prof[bt_size_cur++].jlvalue = (jl_value_t*)jl_atomic_load_relaxed(&ptls->current_task);
bt_data_prof[bt_size_cur++].jlvalue = (jl_value_t*)jl_atomic_load_relaxed(&ptls2->current_task);

// store cpu cycle clock
bt_data_prof[bt_size_cur++].uintptr = cycleclock();

// store whether thread is sleeping but add 1 as 0 is preserved to indicate end of block
bt_data_prof[bt_size_cur++].uintptr = jl_atomic_load_relaxed(&ptls->sleep_check_state) + 1;
bt_data_prof[bt_size_cur++].uintptr = jl_atomic_load_relaxed(&ptls2->sleep_check_state) + 1;

// Mark the end of this block with two 0's
bt_data_prof[bt_size_cur++].uintptr = 0;
Expand Down Expand Up @@ -834,6 +834,15 @@ static void *signal_listener(void *arg)
jl_exit_thread0(128 + sig, bt_data, bt_size);
}
else {
#ifndef SIGINFO // SIGINFO already prints this automatically
int nrunning = 0;
for (int idx = jl_n_threads; idx-- > 0; ) {
jl_ptls_t ptls2 = jl_all_tls_states[idx];
nrunning += !jl_atomic_load_relaxed(&ptls2->sleep_check_state);
}
jl_safe_printf("\ncmd: %s %d running %d of %d\n", jl_options.julia_bin ? jl_options.julia_bin : "julia", jl_getpid(), nrunning, jl_n_threads);
#endif

jl_safe_printf("\nsignal (%d): %s\n", sig, strsignal(sig));
size_t i;
for (i = 0; i < bt_size; i += jl_bt_entry_size(bt_data + i)) {
Expand Down

0 comments on commit 7699e7b

Please sign in to comment.