@@ -3624,6 +3624,31 @@ static int is_system32_path(const char *path)
3624
3624
return 1 ;
3625
3625
}
3626
3626
3627
+ #include "libbacktrace/backtrace.h"
3628
+ #include "libbacktrace/backtrace-supported.h"
3629
+
3630
+ static void bt_error_callback (void * data , const char * msg , int errnum )
3631
+ {
3632
+ error ("%s (%d)" , msg , errnum );
3633
+ }
3634
+
3635
+ static struct backtrace_state * bt_state ;
3636
+
3637
+ static int bt_full_callback (void * data , uintptr_t pc , const char * filename , int lineno , const char * function )
3638
+ {
3639
+ fprintf (stderr , "%s:%d %s %p\n" , filename , lineno , function , (void * )pc );
3640
+
3641
+ return 0 ;
3642
+ }
3643
+
3644
+ static void printStacktraceWithLines (void )
3645
+ {
3646
+ if (!bt_state )
3647
+ bt_state = backtrace_create_state (NULL , BACKTRACE_SUPPORTS_THREADS , bt_error_callback , NULL );
3648
+ backtrace_full (bt_state , 1 , bt_full_callback , bt_error_callback , NULL );
3649
+ }
3650
+
3651
+
3627
3652
static void setup_windows_environment (void )
3628
3653
{
3629
3654
char * tmp = getenv ("TMPDIR" );
@@ -3638,6 +3663,7 @@ static void setup_windows_environment(void)
3638
3663
}
3639
3664
}
3640
3665
3666
+ printStacktraceWithLines ();
3641
3667
if (tmp ) {
3642
3668
/*
3643
3669
* Convert all dir separators to forward slashes,
0 commit comments