| author | |
| committer | |
| log | 22720981ea50b1cee38d8309e0cd32df401b8156 |
| tree | c2fd4b33cdaff492f4e938d2ffa0bf0fd2bcc7e2 |
| parent | 19d7f4dd8221fcd36b7fb71067bf676bb294ca1c |
3 files changed, 25 insertions(+), 22 deletions(-)
lib/std/debug.zig+21| ... | @@ -26,6 +26,27 @@ pub const runtime_safety = switch (builtin.mode) { | ... | @@ -26,6 +26,27 @@ pub const runtime_safety = switch (builtin.mode) { |
| 26 | .ReleaseFast, .ReleaseSmall => false, | 26 | .ReleaseFast, .ReleaseSmall => false, |
| 27 | }; | 27 | }; |
| 28 | 28 | ||
| 29 | pub 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 | |||
| 29 | pub const LineInfo = struct { | 50 | pub const LineInfo = struct { |
| 30 | line: u64, | 51 | line: u64, |
| 31 | column: u64, | 52 | column: u64, |
lib/std/heap/general_purpose_allocator.zig+1-21| ... | @@ -105,28 +105,8 @@ const StackTrace = std.builtin.StackTrace; | ... | @@ -105,28 +105,8 @@ const StackTrace = std.builtin.StackTrace; |
| 105 | /// Integer type for pointing to slots in a small allocation | 105 | /// Integer type for pointing to slots in a small allocation |
| 106 | const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1); | 106 | const SlotIndex = std.meta.Int(.unsigned, math.log2(page_size) + 1); |
| 107 | 107 | ||
| 108 | const 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 | }; | ||
| 128 | const default_test_stack_trace_frames: usize = if (builtin.is_test) 8 else 4; | 108 | const default_test_stack_trace_frames: usize = if (builtin.is_test) 8 else 4; |
| 129 | const default_sys_stack_trace_frames: usize = if (sys_can_stack_trace) default_test_stack_trace_frames else 0; | 109 | const default_sys_stack_trace_frames: usize = if (std.debug.sys_can_stack_trace) default_test_stack_trace_frames else 0; |
| 130 | const default_stack_trace_frames: usize = switch (builtin.mode) { | 110 | const default_stack_trace_frames: usize = switch (builtin.mode) { |
| 131 | .Debug => default_sys_stack_trace_frames, | 111 | .Debug => default_sys_stack_trace_frames, |
| 132 | else => 0, | 112 | else => 0, |
lib/std/testing/failing_allocator.zig+3-1| ... | @@ -19,9 +19,11 @@ pub const FailingAllocator = struct { | ... | @@ -19,9 +19,11 @@ pub const FailingAllocator = struct { |
| 19 | freed_bytes: usize, | 19 | freed_bytes: usize, |
| 20 | allocations: usize, | 20 | allocations: usize, |
| 21 | deallocations: usize, | 21 | deallocations: usize, |
| 22 | stack_addresses: [16]usize, | 22 | stack_addresses: [num_stack_frames]usize, |
| 23 | has_induced_failure: bool, | 23 | has_induced_failure: bool, |
| 24 | 24 | ||
| 25 | const num_stack_frames = if (std.debug.sys_can_stack_trace) 16 else 0; | ||
| 26 | |||
| 25 | /// `fail_index` is the number of successful allocations you can | 27 | /// `fail_index` is the number of successful allocations you can |
| 26 | /// expect from this allocator. The next allocation will fail. | 28 | /// expect from this allocator. The next allocation will fail. |
| 27 | /// For example, if this is called with `fail_index` equal to 2, | 29 | /// For example, if this is called with `fail_index` equal to 2, |