aboutsummaryrefslogtreecommitdiff
path: root/std/debug.zig
blob: 1a289b645e52db5b6d54d6cafc3ac39ca0503abc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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);
    }
}