if (cc == CC_Return_Stack) reserve_size += return_size;
if (context.options->stack_trace_enabled) {
+ emit_stack_address(mod, &code, mod->stack_trace_idx, NULL);
+ WIL(NULL, WI_I32_CONST, call->token->pos.line);
+ emit_store_instruction(mod, &code, &basic_types[Basic_Kind_U32], 8);
+
u64 stack_trace_pass_global = bh_imap_get(&mod->index_map, (u64) &builtin_stack_trace);
emit_stack_address(mod, &code, mod->stack_trace_idx, NULL);
WIL(NULL, WI_GLOBAL_SET, stack_trace_pass_global);
#if Enable_Stack_Trace {
trace := runtime.info.get_stack_trace();
for trace {
- log(.Error, "Core", core.tprintf("in {} ({}:{})", it.func_name, it.file, it.line));
+ log(.Error, "Core", core.tprintf("in {} ({}:{})", it.info.func_name, it.info.file, it.current.line));
}
}
}
trace := runtime.info.get_stack_trace();
defer if trace do delete(&trace);
for trace {
- log(.Info, "Core", tprintf("in {} ({}:{})", it.func_name, it.file, it.line));
+ log(.Info, "Core", tprintf("in {} ({}:{})", it.info.func_name, it.info.file, it.current_line));
}
return res;
// Every platform should define this, even if is it just '() {}'.
#export "_start" platform.__start
+#local
+__output_uint :: (n: u64) {
+ buf: [128] u8;
+ i := 127;
+ while n > 0 && i >= 0 {
+ buf[i] = ~~('0' + n % 10);
+ i -= 1;
+ n /= 10;
+ }
+
+ __output_string(buf[i .. 128]);
+}
// The default assert handler. This assumes that __output_string
// and __exit are defined in the 'runtime' package.
trace := info.get_stack_trace();
for trace[1..trace.length] {
__output_string(" in ");
- __output_string(it.func_name);
+ __output_string(it.info.func_name);
__output_string(" (");
- __output_string(it.file);
+ __output_string(it.info.file);
+ __output_string(":");
+ __output_uint(~~it.current_line);
__output_string(")\n");
}
raw_free(alloc.heap_allocator, __tls_base);
core.thread.__exited(id);
}
-}
\ No newline at end of file
+}
Stack_Trace :: struct {
prev: &Stack_Trace;
data: &Stack_Node;
+ current_line: u32;
+}
+
+Stack_Frame :: struct {
+ info: &Stack_Node;
+ current_line: u32;
}
#if runtime.Stack_Trace_Enabled {
-get_stack_trace :: () -> [..] &Stack_Node {
- trace := make([..] &Stack_Node, 8, alloc.temp_allocator);
+get_stack_trace :: () -> [..] Stack_Frame {
+ trace := make([..] Stack_Frame, 8, alloc.temp_allocator);
walker := __stack_trace.prev;
while walker {
- trace << walker.data;
+ trace << .{ walker.data, walker.current_line };
walker = walker.prev;
}
} else {
-get_stack_trace :: () -> [] &Stack_Node {
+get_stack_trace :: () -> [] Stack_Frame {
return .[];
}