@@ -87,12 +87,14 @@ struct CallstackElement
8787 uint line ;
8888}
8989
90- fn bool print_backtrace (String message , int backtraces_to_ignore ) @if (env ::DARWIN || env :: LINUX )
90+ fn bool print_backtrace (String message , int backtraces_to_ignore ) @if (env ::NATIVE_STACKTRACE )
9191{
9292 @pool ()
9393 {
9494 BacktraceList ! backtrace = backtrace ::backtrace_load (mem ::temp ());
95+ io ::eprintn (" A" );
9596 if (catch backtrace ) return false ;
97+ io ::eprintfn (" B %d %d" , backtraces_to_ignore , backtrace .len ());
9698 if (backtrace .len () <= backtraces_to_ignore ) return false ;
9799 io ::eprint (" \n ERROR: '" );
98100 io ::eprint (message );
@@ -115,7 +117,7 @@ fn bool print_backtrace(String message, int backtraces_to_ignore) @if(env::DARWI
115117 return true ;
116118 };
117119}
118- fn void default_panic (String message , String file , String function , uint line ) @if (env ::DARWIN )
120+ fn void default_panic (String message , String file , String function , uint line ) @if (env ::NATIVE_STACKTRACE )
119121{
120122 $if $defined (io ::stderr ):
121123 if (! print_backtrace (message , 2 ))
@@ -127,7 +129,7 @@ fn void default_panic(String message, String file, String function, uint line) @
127129 $$trap ();
128130
129131}
130- fn void default_panic (String message , String file , String function , uint line ) @if (! env ::DARWIN )
132+ fn void default_panic (String message , String file , String function , uint line ) @if (! env ::NATIVE_STACKTRACE )
131133{
132134 CallstackElement * stack = $$stacktrace ();
133135 $if $defined (io ::stderr ):
@@ -367,35 +369,17 @@ macro uint void*.hash(void* ptr) => ((ulong)(uptr)ptr).hash();
367369module std ::core ::builtin @if ((env ::LINUX || env ::DARWIN ) && env ::COMPILER_SAFE_MODE && env ::DEBUG_SYMBOLS );
368370import libc ;
369371
370- fn void sig_panic (String message ) @if ( env :: DARWIN )
372+ fn void sig_panic (String message )
371373{
372374 default_panic (message , " ???" , " ???" , 0 );
373375}
374376
375- fn void sig_panic (String message ) @if (! env ::DARWIN )
376- {
377- $if $defined (io ::stderr ) && $defined (File .printf ):
378- CallstackElement * stack = $$stacktrace ();
379- if (stack ) stack = stack .prev ;
380- if (stack ) stack = stack .prev ;
381- (void )io ::stderr ().print (" \n SYSTEM ERROR: '" );
382- (void )io ::stderr ().print (message );
383- (void )io ::stderr ().printn (" '" );
384- while (stack )
385- {
386- (void )io ::stderr ().printfn (" in %s %s (%s:%s)" , stack .location .name , stack .function , stack .file , stack .line );
387- if (stack == stack .prev ) break ;
388- stack = stack .prev ;
389- }
390- $endif
391- }
392-
393377SignalFunction old_bus_error ;
394378SignalFunction old_segmentation_fault ;
395379
396380fn void sig_bus_error (CInt i )
397381{
398- $if ! env ::DARWIN :
382+ $if ! env ::NATIVE_STACKTRACE :
399383 sig_panic (" Illegal memory access." );
400384 $else
401385 $if $defined (io ::stderr ):
@@ -410,7 +394,7 @@ fn void sig_bus_error(CInt i)
410394
411395fn void sig_segmentation_fault (CInt i )
412396{
413- $if ! env ::DARWIN :
397+ $if ! env ::NATIVE_STACKTRACE :
414398 sig_panic (" Out of bounds memory access." );
415399 $else
416400 $if $defined (io ::stderr ):
0 commit comments