@@ -3624,6 +3624,31 @@ static int is_system32_path(const char *path)
36243624 return 1 ;
36253625}
36263626
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+
36273652static void setup_windows_environment (void )
36283653{
36293654 char * tmp = getenv ("TMPDIR" );
@@ -3638,6 +3663,7 @@ static void setup_windows_environment(void)
36383663 }
36393664 }
36403665
3666+ printStacktraceWithLines ();
36413667 if (tmp ) {
36423668 /*
36433669 * Convert all dir separators to forward slashes,
0 commit comments