@@ -1407,6 +1407,8 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
1407
1407
{
1408
1408
size_t nthreads = jl_atomic_load_acquire (& jl_n_threads );
1409
1409
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 );
1410
1412
for (size_t i = 0 ; i < nthreads ; i ++ ) {
1411
1413
jl_ptls_t ptls2 = allstates [i ];
1412
1414
if (gc_is_collector_thread (i )) {
@@ -1422,17 +1424,22 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
1422
1424
jl_task_t * t = ptls2 -> root_task ;
1423
1425
if (t != NULL )
1424
1426
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 ));
1427
1429
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 );
1429
1431
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 ,
1432
1434
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
+ }
1434
1441
}
1435
- jl_safe_printf (" ---- End root task\n" );
1442
+ jl_safe_printf ("thread (%d) ---- End root task\n" , ctid );
1436
1443
}
1437
1444
1438
1445
for (size_t j = 0 ; j < n ; j ++ ) {
@@ -1442,17 +1449,20 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
1442
1449
int t_state = jl_atomic_load_relaxed (& t -> _state );
1443
1450
if (!show_done && t_state == JL_TASK_STATE_DONE )
1444
1451
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 );
1446
1453
// 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 ,
1449
1456
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 );
1452
1462
}
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 );
1454
1464
}
1455
- jl_safe_printf ("==== Done\n" );
1465
+ jl_safe_printf ("thread (%d) ++++ Done\n" , ctid );
1456
1466
}
1457
1467
1458
1468
#ifdef __cplusplus
0 commit comments