| author | |
| committer | |
| log | 051aadd7810de9b68f415ec00a3867f6f783b961 |
| tree | 01b324db1cfc39840e4368ed28911bfc73968c8f |
| parent | 72b5ceed66005f03933a4e5bbd0eda08378b0fd0 |
Sadly, trying to collect stack frames goes into an infinite loop on
mips. This sets the default number of stack frames to collect to 0 on
mips.2 files changed, 17 insertions(+), 3 deletions(-)
doc/langref.html.in+1-1| ... | @@ -9363,7 +9363,7 @@ pub fn main() !void { | ... | @@ -9363,7 +9363,7 @@ pub fn main() !void { |
| 9363 | Finally, if none of the above apply, you need a general purpose allocator. | 9363 | Finally, if none of the above apply, you need a general purpose allocator. |
| 9364 | Zig's general purpose allocator is available as a function that takes a {#link|comptime#} | 9364 | Zig's general purpose allocator is available as a function that takes a {#link|comptime#} |
| 9365 | {#link|struct#} of configuration options and returns a type. | 9365 | {#link|struct#} of configuration options and returns a type. |
| 9366 | Generally, you will set up one {#syntax#}std.heap.GeneralPurposeAllocator#{endsyntax#} in | 9366 | Generally, you will set up one {#syntax#}std.heap.GeneralPurposeAllocator{#endsyntax#} in |
| 9367 | your main function, and then pass it or sub-allocators around to various parts of your | 9367 | your main function, and then pass it or sub-allocators around to various parts of your |
| 9368 | application. | 9368 | application. |
| 9369 | </li> | 9369 | </li> |
lib/std/heap/general_purpose_allocator.zig+16-2| ... | @@ -102,8 +102,22 @@ const StackTrace = std.builtin.StackTrace; | ... | @@ -102,8 +102,22 @@ const StackTrace = std.builtin.StackTrace; |
| 102 | /// Integer type for pointing to slots in a small allocation | 102 | /// Integer type for pointing to slots in a small allocation |
| 103 | const SlotIndex = std.meta.Int(false, math.log2(page_size) + 1); | 103 | const SlotIndex = std.meta.Int(false, math.log2(page_size) + 1); |
| 104 | 104 | ||
| 105 | // WebAssembly doesn't support stack tracing yet. | 105 | const sys_can_stack_trace = switch (std.Target.current.cpu.arch) { |
| 106 | const default_stack_trace_frames: usize = if (std.Target.current.cpu.arch.isWasm()) 0 else 4; | 106 | // Observed to go into an infinite loop. |
| 107 | // TODO: Make this work. | ||
| 108 | .mips, | ||
| 109 | .mipsel, | ||
| 110 | => false, | ||
| 111 | |||
| 112 | // `@returnAddress()` in LLVM 10 gives | ||
| 113 | // "Non-Emscripten WebAssembly hasn't implemented __builtin_return_address". | ||
| 114 | .wasm32, | ||
| 115 | .wasm64, | ||
| 116 | => std.Target.current.os.tag == .emscripten, | ||
| 117 | |||
| 118 | else => true, | ||
| 119 | }; | ||
| 120 | const default_stack_trace_frames: usize = if (sys_can_stack_trace) 4 else 0; | ||
| 107 | 121 | ||
| 108 | pub const Config = struct { | 122 | pub const Config = struct { |
| 109 | /// Number of stack frames to capture. | 123 | /// Number of stack frames to capture. |