@@ -1403,6 +1403,8 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14031403{
14041404 size_t nthreads = jl_atomic_load_acquire (& jl_n_threads );
14051405 jl_ptls_t * allstates = jl_atomic_load_relaxed (& jl_all_tls_states );
1406+ int ctid = jl_threadid () + 1 ;
1407+ jl_safe_printf ("thread (%d) ++++ Task backtraces\n" , ctid );
14061408 for (size_t i = 0 ; i < nthreads ; i ++ ) {
14071409 jl_ptls_t ptls2 = allstates [i ];
14081410 if (gc_is_collector_thread (i )) {
@@ -1418,17 +1420,22 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14181420 jl_task_t * t = ptls2 -> root_task ;
14191421 if (t != NULL )
14201422 t_state = jl_atomic_load_relaxed (& t -> _state );
1421- jl_safe_printf ("==== Thread %d created %zu live tasks\n" ,
1422- ptls2 -> tid + 1 , n + (t_state != JL_TASK_STATE_DONE ));
1423+ jl_safe_printf ("thread (%d) ==== Thread %d created %zu live tasks\n" ,
1424+ ctid , ptls2 -> tid + 1 , n + (t_state != JL_TASK_STATE_DONE ));
14231425 if (show_done || t_state != JL_TASK_STATE_DONE ) {
1424- jl_safe_printf (" ---- Root task (%p)\n" , ptls2 -> root_task );
1426+ jl_safe_printf ("thread (%d) ---- Root task (%p)\n" , ctid , ptls2 -> root_task );
14251427 if (t != NULL ) {
1426- jl_safe_printf (" (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1427- t -> sticky , t -> ctx .started , t_state ,
1428+ jl_safe_printf ("thread (%d) (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1429+ ctid , t -> sticky , t -> ctx .started , t_state ,
14281430 jl_atomic_load_relaxed (& t -> tid ) + 1 );
1429- jlbacktracet (t );
1431+ if (t -> ctx .stkbuf != NULL ) {
1432+ jlbacktracet (t );
1433+ }
1434+ else {
1435+ jl_safe_printf ("thread (%d) no stack\n" , ctid );
1436+ }
14301437 }
1431- jl_safe_printf (" ---- End root task\n" );
1438+ jl_safe_printf ("thread (%d) ---- End root task\n" , ctid );
14321439 }
14331440
14341441 for (size_t j = 0 ; j < n ; j ++ ) {
@@ -1438,17 +1445,20 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14381445 int t_state = jl_atomic_load_relaxed (& t -> _state );
14391446 if (!show_done && t_state == JL_TASK_STATE_DONE )
14401447 continue ;
1441- jl_safe_printf (" ---- Task %zu (%p)\n" , j + 1 , t );
1448+ jl_safe_printf ("thread (%d) ---- Task %zu (%p)\n" , ctid , j + 1 , t );
14421449 // n.b. this information might not be consistent with the stack printing after it, since it could start running or change tid, etc.
1443- jl_safe_printf (" (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1444- t -> sticky , t -> ctx .started , t_state ,
1450+ jl_safe_printf ("thread (%d) (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1451+ ctid , t -> sticky , t -> ctx .started , t_state ,
14451452 jl_atomic_load_relaxed (& t -> tid ) + 1 );
1446- jlbacktracet (t );
1447- jl_safe_printf (" ---- End task %zu\n" , j + 1 );
1453+ if (t -> ctx .stkbuf != NULL )
1454+ jlbacktracet (t );
1455+ else
1456+ jl_safe_printf ("thread (%d) no stack\n" , ctid );
1457+ jl_safe_printf ("thread (%d) ---- End task %zu\n" , ctid , j + 1 );
14481458 }
1449- jl_safe_printf ("==== End thread %d\n" , ptls2 -> tid + 1 );
1459+ jl_safe_printf ("thread (%d) ==== End thread %d\n" , ctid , ptls2 -> tid + 1 );
14501460 }
1451- jl_safe_printf ("==== Done\n" );
1461+ jl_safe_printf ("thread (%d) ++++ Done\n" , ctid );
14521462}
14531463
14541464#ifdef __cplusplus
0 commit comments