Skip to content

Commit 54943bb

Browse files
kpamnanyRAI CI (GitHub Action Automation)
authored andcommitted
RAI: Prepend "thread (%d) " to output from jl_print_task_backtraces()
1 parent 3b7a5e1 commit 54943bb

File tree

1 file changed

+24
-14
lines changed

1 file changed

+24
-14
lines changed

src/stackwalk.c

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1407,6 +1407,8 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14071407
{
14081408
size_t nthreads = jl_atomic_load_acquire(&jl_n_threads);
14091409
jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_all_tls_states);
1410+
int ctid = jl_threadid() + 1;
1411+
jl_safe_printf("thread (%d) ++++ Task backtraces\n", ctid);
14101412
for (size_t i = 0; i < nthreads; i++) {
14111413
jl_ptls_t ptls2 = allstates[i];
14121414
if (gc_is_collector_thread(i)) {
@@ -1422,17 +1424,22 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14221424
jl_task_t *t = ptls2->root_task;
14231425
if (t != NULL)
14241426
t_state = jl_atomic_load_relaxed(&t->_state);
1425-
jl_safe_printf("==== Thread %d created %zu live tasks\n",
1426-
ptls2->tid + 1, n + (t_state != JL_TASK_STATE_DONE));
1427+
jl_safe_printf("thread (%d) ==== Thread %d created %zu live tasks\n",
1428+
ctid, ptls2->tid + 1, n + (t_state != JL_TASK_STATE_DONE));
14271429
if (show_done || t_state != JL_TASK_STATE_DONE) {
1428-
jl_safe_printf(" ---- Root task (%p)\n", ptls2->root_task);
1430+
jl_safe_printf("thread (%d) ---- Root task (%p)\n", ctid, ptls2->root_task);
14291431
if (t != NULL) {
1430-
jl_safe_printf(" (sticky: %d, started: %d, state: %d, tid: %d)\n",
1431-
t->sticky, t->ctx.started, t_state,
1432+
jl_safe_printf("thread (%d) (sticky: %d, started: %d, state: %d, tid: %d)\n",
1433+
ctid, t->sticky, t->ctx.started, t_state,
14321434
jl_atomic_load_relaxed(&t->tid) + 1);
1433-
jlbacktracet(t);
1435+
if (t->ctx.stkbuf != NULL) {
1436+
jlbacktracet(t);
1437+
}
1438+
else {
1439+
jl_safe_printf("thread (%d) no stack\n", ctid);
1440+
}
14341441
}
1435-
jl_safe_printf(" ---- End root task\n");
1442+
jl_safe_printf("thread (%d) ---- End root task\n", ctid);
14361443
}
14371444

14381445
for (size_t j = 0; j < n; j++) {
@@ -1442,17 +1449,20 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14421449
int t_state = jl_atomic_load_relaxed(&t->_state);
14431450
if (!show_done && t_state == JL_TASK_STATE_DONE)
14441451
continue;
1445-
jl_safe_printf(" ---- Task %zu (%p)\n", j + 1, t);
1452+
jl_safe_printf("thread (%d) ---- Task %zu (%p)\n", ctid, j + 1, t);
14461453
// n.b. this information might not be consistent with the stack printing after it, since it could start running or change tid, etc.
1447-
jl_safe_printf(" (sticky: %d, started: %d, state: %d, tid: %d)\n",
1448-
t->sticky, t->ctx.started, t_state,
1454+
jl_safe_printf("thread (%d) (sticky: %d, started: %d, state: %d, tid: %d)\n",
1455+
ctid, t->sticky, t->ctx.started, t_state,
14491456
jl_atomic_load_relaxed(&t->tid) + 1);
1450-
jlbacktracet(t);
1451-
jl_safe_printf(" ---- End task %zu\n", j + 1);
1457+
if (t->ctx.stkbuf != NULL)
1458+
jlbacktracet(t);
1459+
else
1460+
jl_safe_printf("thread (%d) no stack\n", ctid);
1461+
jl_safe_printf("thread (%d) ---- End task %zu\n", ctid, j + 1);
14521462
}
1453-
jl_safe_printf("==== End thread %d\n", ptls2->tid + 1);
1463+
jl_safe_printf("thread (%d) ==== End thread %d\n", ctid, ptls2->tid + 1);
14541464
}
1455-
jl_safe_printf("==== Done\n");
1465+
jl_safe_printf("thread (%d) ++++ Done\n", ctid);
14561466
}
14571467

14581468
#ifdef __cplusplus

0 commit comments

Comments
 (0)