@@ -614,22 +614,25 @@ JL_DLLEXPORT jl_value_t *jl_lookup_code_address(void *ip, int skipC)
614
614
return rs ;
615
615
}
616
616
617
- static void jl_safe_print_codeloc (const char * func_name , const char * file_name ,
617
+ static void jl_safe_print_codeloc (const char * pre_str ,
618
+ const char * func_name , const char * file_name ,
618
619
int line , int inlined ) JL_NOTSAFEPOINT
619
620
{
620
621
const char * inlined_str = inlined ? " [inlined]" : "" ;
621
622
if (line != -1 ) {
622
- jl_safe_printf ("%s at %s:%d%s\n" , func_name , file_name , line , inlined_str );
623
+ jl_safe_printf ("%s%s at %s:%d%s\n" ,
624
+ pre_str , func_name , file_name , line , inlined_str );
623
625
}
624
626
else {
625
- jl_safe_printf ("%s at %s (unknown line)%s\n" , func_name , file_name , inlined_str );
627
+ jl_safe_printf ("%s%s at %s (unknown line)%s\n" ,
628
+ pre_str , func_name , file_name , inlined_str );
626
629
}
627
630
}
628
631
629
632
// Print function, file and line containing native instruction pointer `ip` by
630
633
// looking up debug info. Prints multiple such frames when `ip` points to
631
634
// inlined code.
632
- void jl_print_native_codeloc (uintptr_t ip ) JL_NOTSAFEPOINT
635
+ void jl_print_native_codeloc (char * pre_str , uintptr_t ip ) JL_NOTSAFEPOINT
633
636
{
634
637
// This function is not allowed to reference any TLS variables since
635
638
// it can be called from an unmanaged thread on OSX.
@@ -641,10 +644,11 @@ void jl_print_native_codeloc(uintptr_t ip) JL_NOTSAFEPOINT
641
644
for (i = 0 ; i < n ; i ++ ) {
642
645
jl_frame_t frame = frames [i ];
643
646
if (!frame .func_name ) {
644
- jl_safe_printf ("unknown function (ip: %p)\n" , (void * )ip );
647
+ jl_safe_printf ("%sunknown function (ip: %p)\n" , pre_str , (void * )ip );
645
648
}
646
649
else {
647
- jl_safe_print_codeloc (frame .func_name , frame .file_name , frame .line , frame .inlined );
650
+ jl_safe_print_codeloc (pre_str , frame .func_name ,
651
+ frame .file_name , frame .line , frame .inlined );
648
652
free (frame .func_name );
649
653
free (frame .file_name );
650
654
}
@@ -653,10 +657,17 @@ void jl_print_native_codeloc(uintptr_t ip) JL_NOTSAFEPOINT
653
657
}
654
658
655
659
// Print code location for backtrace buffer entry at *bt_entry
656
- void jl_print_bt_entry_codeloc (jl_bt_element_t * bt_entry ) JL_NOTSAFEPOINT
660
+ void jl_print_bt_entry_codeloc (int sig , jl_bt_element_t * bt_entry ) JL_NOTSAFEPOINT
657
661
{
662
+ char sig_str [32 ], pre_str [64 ];
663
+ sig_str [0 ] = '\0' ;
664
+ if (sig != -1 ) {
665
+ snprintf (sig_str , 32 , "signal (%d) " , sig );
666
+ }
667
+ snprintf (pre_str , 64 , "%sthread (%d) " , sig_str , jl_threadid () + 1 );
668
+
658
669
if (jl_bt_is_native (bt_entry )) {
659
- jl_print_native_codeloc (bt_entry [0 ].uintptr );
670
+ jl_print_native_codeloc (pre_str , bt_entry [0 ].uintptr );
660
671
}
661
672
else if (jl_bt_entry_tag (bt_entry ) == JL_BT_INTERP_FRAME_TAG ) {
662
673
size_t ip = jl_bt_entry_header (bt_entry );
@@ -682,7 +693,7 @@ void jl_print_bt_entry_codeloc(jl_bt_element_t *bt_entry) JL_NOTSAFEPOINT
682
693
method = (jl_value_t * )((jl_method_t * )method )-> name ;
683
694
if (jl_is_symbol (method ))
684
695
func_name = jl_symbol_name ((jl_sym_t * )method );
685
- jl_safe_print_codeloc (func_name , jl_symbol_name (locinfo -> file ),
696
+ jl_safe_print_codeloc (pre_str , func_name , jl_symbol_name (locinfo -> file ),
686
697
locinfo -> line , locinfo -> inlined_at );
687
698
debuginfoloc = locinfo -> inlined_at ;
688
699
}
@@ -1108,7 +1119,9 @@ static void jl_rec_backtrace(jl_task_t *t) JL_NOTSAFEPOINT
1108
1119
1109
1120
JL_DLLEXPORT void jl_gdblookup (void * ip )
1110
1121
{
1111
- jl_print_native_codeloc ((uintptr_t )ip );
1122
+ char pre_str [64 ];
1123
+ snprintf (pre_str , 64 , "thread (%d) " , jl_threadid () + 1 );
1124
+ jl_print_native_codeloc (pre_str , (uintptr_t )ip );
1112
1125
}
1113
1126
1114
1127
// Print backtrace for current exception in catch block
@@ -1123,7 +1136,7 @@ JL_DLLEXPORT void jlbacktrace(void) JL_NOTSAFEPOINT
1123
1136
size_t i , bt_size = jl_excstack_bt_size (s , s -> top );
1124
1137
jl_bt_element_t * bt_data = jl_excstack_bt_data (s , s -> top );
1125
1138
for (i = 0 ; i < bt_size ; i += jl_bt_entry_size (bt_data + i )) {
1126
- jl_print_bt_entry_codeloc (bt_data + i );
1139
+ jl_print_bt_entry_codeloc (-1 , bt_data + i );
1127
1140
}
1128
1141
}
1129
1142
@@ -1136,7 +1149,7 @@ JL_DLLEXPORT void jlbacktracet(jl_task_t *t) JL_NOTSAFEPOINT
1136
1149
size_t i , bt_size = ptls -> bt_size ;
1137
1150
jl_bt_element_t * bt_data = ptls -> bt_data ;
1138
1151
for (i = 0 ; i < bt_size ; i += jl_bt_entry_size (bt_data + i )) {
1139
- jl_print_bt_entry_codeloc (bt_data + i );
1152
+ jl_print_bt_entry_codeloc (-1 , bt_data + i );
1140
1153
}
1141
1154
}
1142
1155
0 commit comments