Skip to content

Commit 71d3477

Browse files
kpamnanyRAI CI (GitHub Action Automation)
authored and
RAI CI (GitHub Action Automation)
committed
RAI: Prepend "thread (%d) " to output from jl_print_task_backtraces()
1 parent ebd24e5 commit 71d3477

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/stackwalk.c

+16-14
Original file line numberDiff line numberDiff line change
@@ -1165,6 +1165,8 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
11651165
{
11661166
size_t nthreads = jl_atomic_load_acquire(&jl_n_threads);
11671167
jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_all_tls_states);
1168+
int ctid = jl_threadid() + 1;
1169+
jl_safe_printf("thread (%d) ++++ Task backtraces\n", ctid);
11681170
for (size_t i = 0; i < nthreads; i++) {
11691171
// skip GC threads since they don't have tasks
11701172
if (gc_first_tid <= i && i < gc_first_tid + jl_n_gcthreads) {
@@ -1180,22 +1182,22 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
11801182
jl_task_t *t = ptls2->root_task;
11811183
if (t != NULL)
11821184
t_state = jl_atomic_load_relaxed(&t->_state);
1183-
jl_safe_printf("==== Thread %d created %zu live tasks\n",
1184-
ptls2->tid + 1, n + (t_state != JL_TASK_STATE_DONE));
1185+
jl_safe_printf("thread (%d) ==== Thread %d created %zu live tasks\n",
1186+
ctid, ptls2->tid + 1, n + (t_state != JL_TASK_STATE_DONE));
11851187
if (show_done || t_state != JL_TASK_STATE_DONE) {
1186-
jl_safe_printf(" ---- Root task (%p)\n", ptls2->root_task);
1188+
jl_safe_printf("thread (%d) ---- Root task (%p)\n", ctid, ptls2->root_task);
11871189
if (t != NULL) {
1188-
jl_safe_printf(" (sticky: %d, started: %d, state: %d, tid: %d)\n",
1189-
t->sticky, t->started, t_state,
1190+
jl_safe_printf("thread (%d) (sticky: %d, started: %d, state: %d, tid: %d)\n",
1191+
ctid, t->sticky, t->started, t_state,
11901192
jl_atomic_load_relaxed(&t->tid) + 1);
11911193
if (t->stkbuf != NULL) {
11921194
jlbacktracet(t);
11931195
}
11941196
else {
1195-
jl_safe_printf(" no stack\n");
1197+
jl_safe_printf("thread (%d) no stack\n", ctid);
11961198
}
11971199
}
1198-
jl_safe_printf(" ---- End root task\n");
1200+
jl_safe_printf("thread (%d) ---- End root task\n", ctid);
11991201
}
12001202

12011203
for (size_t j = 0; j < n; j++) {
@@ -1205,20 +1207,20 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
12051207
int t_state = jl_atomic_load_relaxed(&t->_state);
12061208
if (!show_done && t_state == JL_TASK_STATE_DONE)
12071209
continue;
1208-
jl_safe_printf(" ---- Task %zu (%p)\n", j + 1, t);
1210+
jl_safe_printf("thread (%d) ---- Task %zu (%p)\n", ctid, j + 1, t);
12091211
// n.b. this information might not be consistent with the stack printing after it, since it could start running or change tid, etc.
1210-
jl_safe_printf(" (sticky: %d, started: %d, state: %d, tid: %d)\n",
1211-
t->sticky, t->started, t_state,
1212+
jl_safe_printf("thread (%d) (sticky: %d, started: %d, state: %d, tid: %d)\n",
1213+
ctid, t->sticky, t->started, t_state,
12121214
jl_atomic_load_relaxed(&t->tid) + 1);
12131215
if (t->stkbuf != NULL)
12141216
jlbacktracet(t);
12151217
else
1216-
jl_safe_printf(" no stack\n");
1217-
jl_safe_printf(" ---- End task %zu\n", j + 1);
1218+
jl_safe_printf("thread (%d) no stack\n", ctid);
1219+
jl_safe_printf("thread (%d) ---- End task %zu\n", ctid, j + 1);
12181220
}
1219-
jl_safe_printf("==== End thread %d\n", ptls2->tid + 1);
1221+
jl_safe_printf("thread (%d) ==== End thread %d\n", ctid, ptls2->tid + 1);
12201222
}
1221-
jl_safe_printf("==== Done\n");
1223+
jl_safe_printf("thread (%d) ++++ Done\n", ctid);
12221224
}
12231225

12241226
#ifdef __cplusplus

0 commit comments

Comments
 (0)