@@ -88,7 +88,7 @@ pub fn getSelfDebugInfo() !*SelfInfo {
88
88
if (self_debug_info ) | * info | {
89
89
return info ;
90
90
} else {
91
- self_debug_info = try SelfInfo .openSelf (getDebugInfoAllocator ());
91
+ self_debug_info = try SelfInfo .open (getDebugInfoAllocator ());
92
92
return & self_debug_info .? ;
93
93
}
94
94
}
@@ -573,17 +573,19 @@ pub const StackIterator = struct {
573
573
pub fn initWithContext (first_address : ? usize , debug_info : * SelfInfo , context : * posix.ucontext_t ) ! StackIterator {
574
574
// The implementation of DWARF unwinding on aarch64-macos is not complete. However, Apple mandates that
575
575
// the frame pointer register is always used, so on this platform we can safely use the FP-based unwinder.
576
- if (builtin .target .isDarwin () and native_arch == .aarch64 ) {
576
+ if (builtin .target .isDarwin () and native_arch == .aarch64 )
577
577
return init (first_address , context .mcontext .ss .fp );
578
- } else {
578
+
579
+ if (SelfInfo .supports_unwinding ) {
579
580
var iterator = init (first_address , null );
580
581
iterator .unwind_state = .{
581
582
.debug_info = debug_info ,
582
583
.dwarf_context = try SelfInfo .UnwindContext .init (debug_info .allocator , context ),
583
584
};
584
-
585
585
return iterator ;
586
586
}
587
+
588
+ return init (first_address , null );
587
589
}
588
590
589
591
pub fn deinit (it : * StackIterator ) void {
@@ -725,11 +727,13 @@ pub fn writeCurrentStackTrace(
725
727
tty_config : io.tty.Config ,
726
728
start_addr : ? usize ,
727
729
) ! void {
728
- var context : ThreadContext = undefined ;
729
- const has_context = getContext (& context );
730
730
if (native_os == .windows ) {
731
+ var context : ThreadContext = undefined ;
732
+ assert (getContext (& context ));
731
733
return writeStackTraceWindows (out_stream , debug_info , tty_config , & context , start_addr );
732
734
}
735
+ var context : ThreadContext = undefined ;
736
+ const has_context = getContext (& context );
733
737
734
738
var it = (if (has_context ) blk : {
735
739
break :blk StackIterator .initWithContext (start_addr , debug_info , & context ) catch null ;
@@ -1340,7 +1344,7 @@ test "manage resources correctly" {
1340
1344
}
1341
1345
1342
1346
const writer = std .io .null_writer ;
1343
- var di = try SelfInfo .openSelf (testing .allocator );
1347
+ var di = try SelfInfo .open (testing .allocator );
1344
1348
defer di .deinit ();
1345
1349
try printSourceAtAddress (& di , writer , showMyTrace (), io .tty .detectConfig (std .io .getStdErr ()));
1346
1350
}
@@ -1581,5 +1585,9 @@ pub inline fn inValgrind() bool {
1581
1585
}
1582
1586
1583
1587
test {
1588
+ _ = & Dwarf ;
1589
+ _ = & MemoryAccessor ;
1590
+ _ = & Pdb ;
1591
+ _ = & SelfInfo ;
1584
1592
_ = & dumpHex ;
1585
1593
}
0 commit comments