@@ -1165,6 +1165,8 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
1165
1165
{
1166
1166
size_t nthreads = jl_atomic_load_acquire (& jl_n_threads );
1167
1167
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 );
1168
1170
for (size_t i = 0 ; i < nthreads ; i ++ ) {
1169
1171
// skip GC threads since they don't have tasks
1170
1172
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
1180
1182
jl_task_t * t = ptls2 -> root_task ;
1181
1183
if (t != NULL )
1182
1184
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 ));
1185
1187
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 );
1187
1189
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 ,
1190
1192
jl_atomic_load_relaxed (& t -> tid ) + 1 );
1191
1193
if (t -> stkbuf != NULL ) {
1192
1194
jlbacktracet (t );
1193
1195
}
1194
1196
else {
1195
- jl_safe_printf (" no stack\n" );
1197
+ jl_safe_printf ("thread (%d) no stack\n" , ctid );
1196
1198
}
1197
1199
}
1198
- jl_safe_printf (" ---- End root task\n" );
1200
+ jl_safe_printf ("thread (%d) ---- End root task\n" , ctid );
1199
1201
}
1200
1202
1201
1203
for (size_t j = 0 ; j < n ; j ++ ) {
@@ -1205,20 +1207,20 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
1205
1207
int t_state = jl_atomic_load_relaxed (& t -> _state );
1206
1208
if (!show_done && t_state == JL_TASK_STATE_DONE )
1207
1209
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 );
1209
1211
// 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 ,
1212
1214
jl_atomic_load_relaxed (& t -> tid ) + 1 );
1213
1215
if (t -> stkbuf != NULL )
1214
1216
jlbacktracet (t );
1215
1217
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 );
1218
1220
}
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 );
1220
1222
}
1221
- jl_safe_printf ("==== Done\n" );
1223
+ jl_safe_printf ("thread (%d) ++++ Done\n" , ctid );
1222
1224
}
1223
1225
1224
1226
#ifdef __cplusplus
0 commit comments