@@ -1415,6 +1415,8 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14151415{
14161416 size_t nthreads = jl_atomic_load_acquire (& jl_n_threads );
14171417 jl_ptls_t * allstates = jl_atomic_load_relaxed (& jl_all_tls_states );
1418+ int ctid = jl_threadid () + 1 ;
1419+ jl_safe_printf ("thread (%d) ++++ Task backtraces\n" , ctid );
14181420 for (size_t i = 0 ; i < nthreads ; i ++ ) {
14191421 jl_ptls_t ptls2 = allstates [i ];
14201422 if (gc_is_collector_thread (i )) {
@@ -1430,17 +1432,22 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14301432 jl_task_t * t = ptls2 -> root_task ;
14311433 if (t != NULL )
14321434 t_state = jl_atomic_load_relaxed (& t -> _state );
1433- jl_safe_printf ("==== Thread %d created %zu live tasks\n" ,
1434- ptls2 -> tid + 1 , n + (t_state != JL_TASK_STATE_DONE ));
1435+ jl_safe_printf ("thread (%d) ==== Thread %d created %zu live tasks\n" ,
1436+ ctid , ptls2 -> tid + 1 , n + (t_state != JL_TASK_STATE_DONE ));
14351437 if (show_done || t_state != JL_TASK_STATE_DONE ) {
1436- jl_safe_printf (" ---- Root task (%p)\n" , ptls2 -> root_task );
1438+ jl_safe_printf ("thread (%d) ---- Root task (%p)\n" , ctid , ptls2 -> root_task );
14371439 if (t != NULL ) {
1438- jl_safe_printf (" (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1439- t -> sticky , t -> ctx .started , t_state ,
1440+ jl_safe_printf ("thread (%d) (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1441+ ctid , t -> sticky , t -> ctx .started , t_state ,
14401442 jl_atomic_load_relaxed (& t -> tid ) + 1 );
1441- jlbacktracet (t );
1443+ if (t -> ctx .stkbuf != NULL ) {
1444+ jlbacktracet (t );
1445+ }
1446+ else {
1447+ jl_safe_printf ("thread (%d) no stack\n" , ctid );
1448+ }
14421449 }
1443- jl_safe_printf (" ---- End root task\n" );
1450+ jl_safe_printf ("thread (%d) ---- End root task\n" , ctid );
14441451 }
14451452
14461453 for (size_t j = 0 ; j < n ; j ++ ) {
@@ -1450,17 +1457,20 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT
14501457 int t_state = jl_atomic_load_relaxed (& t -> _state );
14511458 if (!show_done && t_state == JL_TASK_STATE_DONE )
14521459 continue ;
1453- jl_safe_printf (" ---- Task %zu (%p)\n" , j + 1 , t );
1460+ jl_safe_printf ("thread (%d) ---- Task %zu (%p)\n" , ctid , j + 1 , t );
14541461 // n.b. this information might not be consistent with the stack printing after it, since it could start running or change tid, etc.
1455- jl_safe_printf (" (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1456- t -> sticky , t -> ctx .started , t_state ,
1462+ jl_safe_printf ("thread (%d) (sticky: %d, started: %d, state: %d, tid: %d)\n" ,
1463+ ctid , t -> sticky , t -> ctx .started , t_state ,
14571464 jl_atomic_load_relaxed (& t -> tid ) + 1 );
1458- jlbacktracet (t );
1459- jl_safe_printf (" ---- End task %zu\n" , j + 1 );
1465+ if (t -> ctx .stkbuf != NULL )
1466+ jlbacktracet (t );
1467+ else
1468+ jl_safe_printf ("thread (%d) no stack\n" , ctid );
1469+ jl_safe_printf ("thread (%d) ---- End task %zu\n" , ctid , j + 1 );
14601470 }
1461- jl_safe_printf ("==== End thread %d\n" , ptls2 -> tid + 1 );
1471+ jl_safe_printf ("thread (%d) ==== End thread %d\n" , ctid , ptls2 -> tid + 1 );
14621472 }
1463- jl_safe_printf ("==== Done\n" );
1473+ jl_safe_printf ("thread (%d) ++++ Done\n" , ctid );
14641474}
14651475
14661476#ifdef __cplusplus
0 commit comments