authorgravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2022-06-25 21:27:56-07:00
committergravatar for squeek502@hotmail.comRyan Liptak <squeek502@hotmail.com> 2022-06-25 21:27:56-07:00
log22720981ea50b1cee38d8309e0cd32df401b8156
treec2fd4b33cdaff492f4e938d2ffa0bf0fd2bcc7e2
parent19d7f4dd8221fcd36b7fb71067bf676bb294ca1c

Move sys_can_stack_trace from GPA to std.debug so that it can be re-used as needed


3 files changed, 25 insertions(+), 22 deletions(-)

lib/std/debug.zig+21
......@@ -26,6 +26,27 @@ pub const runtime_safety = switch (builtin.mode) {
2626 .ReleaseFast, .ReleaseSmall => false,
2727};
2828
29pub const sys_can_stack_trace = switch (builtin.cpu.arch) {
30 // Observed to go into an infinite loop.
31 // TODO: Make this work.
32 .mips,
33 .mipsel,
34 => false,
35
36 // `@returnAddress()` in LLVM 10 gives
37 // "Non-Emscripten WebAssembly hasn't implemented __builtin_return_address".
38 .wasm32,
39 .wasm64,
40 => builtin.os.tag == .emscripten,
41
42 // `@returnAddress()` is unsupported in LLVM 13.
43 .bpfel,
44 .bpfeb,
45 => false,
46
47 else => true,
48};
49
2950pub const LineInfo = struct {
3051 line: u64,
3152 column: u64,
lib/std/heap/general_purpose_allocator.zig+1-21
......@@ -105,28 +105,8 @@ const StackTrace = std.builtin.StackTrace;
105105/// Integer type for pointing to slots in a small allocation
106106const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1);
107107
108const sys_can_stack_trace = switch (builtin.cpu.arch) {
109 // Observed to go into an infinite loop.
110 // TODO: Make this work.
111 .mips,
112 .mipsel,
113 => false,
114
115 // `@returnAddress()` in LLVM 10 gives
116 // "Non-Emscripten WebAssembly hasn't implemented __builtin_return_address".
117 .wasm32,
118 .wasm64,
119 => builtin.os.tag == .emscripten,
120
121 // `@returnAddress()` is unsupported in LLVM 13.
122 .bpfel,
123 .bpfeb,
124 => false,
125
126 else => true,
127};
128108const default_test_stack_trace_frames: usize = if (builtin.is_test) 8 else 4;
129const default_sys_stack_trace_frames: usize = if (sys_can_stack_trace) default_test_stack_trace_frames else 0;
109const default_sys_stack_trace_frames: usize = if (std.debug.sys_can_stack_trace) default_test_stack_trace_frames else 0;
130110const default_stack_trace_frames: usize = switch (builtin.mode) {
131111 .Debug => default_sys_stack_trace_frames,
132112 else => 0,
lib/std/testing/failing_allocator.zig+3-1
......@@ -19,9 +19,11 @@ pub const FailingAllocator = struct {
1919 freed_bytes: usize,
2020 allocations: usize,
2121 deallocations: usize,
22 stack_addresses: [16]usize,
22 stack_addresses: [num_stack_frames]usize,
2323 has_induced_failure: bool,
2424
25 const num_stack_frames = if (std.debug.sys_can_stack_trace) 16 else 0;
26
2527 /// `fail_index` is the number of successful allocations you can
2628 /// expect from this allocator. The next allocation will fail.
2729 /// For example, if this is called with `fail_index` equal to 2,