diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2016-05-17 13:32:43 -0700 |
|---|---|---|
| committer | Andrew Kelley <superjoe30@gmail.com> | 2016-05-17 13:32:43 -0700 |
| commit | 7edef4f3fd8e260c69142741e750b3e6893434b8 (patch) | |
| tree | 5bde5c32cf492ab7ebef830a0a423a37777d4aaf /std/debug.zig | |
| parent | 2c710382a888e8f45b958bdf3e77213cc18c2733 (diff) | |
| download | zig-7edef4f3fd8e260c69142741e750b3e6893434b8.tar.gz zig-7edef4f3fd8e260c69142741e750b3e6893434b8.zip | |
add beginning of print stack trace function
introduce std.debug and move std.assert to std.debug.assert
add mem.copy
Diffstat (limited to 'std/debug.zig')
| -rw-r--r-- | std/debug.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/std/debug.zig b/std/debug.zig new file mode 100644 index 0000000000..1a289b645e --- /dev/null +++ b/std/debug.zig @@ -0,0 +1,16 @@ +const io = @import("io.zig"); + +pub fn assert(b: bool) { + if (!b) unreachable{} +} + +pub fn print_stack_trace() { + var maybe_fp: ?&const u8 = @frame_address(); + while (true) { + const fp = maybe_fp ?? break; + const return_address = *(&const usize)(usize(fp) + @sizeof(usize)); + %%io.stderr.print_u64(return_address); + %%io.stderr.printf("\n"); + maybe_fp = *(&const ?&const u8)(fp); + } +} |
