From 6170f130e18956f90655e43df4bb9aebecf74b58 Mon Sep 17 00:00:00 2001 From: Laytan Laats Date: Sun, 26 Jul 2026 17:28:29 +0200 Subject: [PATCH] use fmt so it runs on wasm --- core/debug/trace/trace.odin | 38 +++++++++++-------------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/core/debug/trace/trace.odin b/core/debug/trace/trace.odin index 9257d93bf..a93dead67 100644 --- a/core/debug/trace/trace.odin +++ b/core/debug/trace/trace.odin @@ -3,8 +3,7 @@ package debug_trace import "base:runtime" -import "core:io" -import "core:os" +import "core:fmt" import "core:sync" // Size of a constant backtrace, as used by the tracking allocator for example. @@ -135,9 +134,9 @@ assertion_failure_proc :: proc(prefix, message: string, loc: runtime.Source_Code lines, err := resolve(capture(skip=1), context.temp_allocator, context.temp_allocator) if err != nil { - os.write_string(os.stderr, "could not get backtrace for assertion failure\n") + fmt.eprintfln("could not get backtrace for assertion failure: %v", err) } else { - os.write_string(os.stderr, "[back trace]\n") + fmt.eprintfln("[back trace]") print(lines) locations_destroy(lines, context.temp_allocator) } @@ -147,47 +146,32 @@ assertion_failure_proc :: proc(prefix, message: string, loc: runtime.Source_Code } /* -Print/writes locations. +Print locations to stderr. Inputs: - locations: the result of a `resolve` call. - padding: padding to print before each line, defaults to a tab. -- w: the writer to print to, defaults to stderr. */ -print :: proc(locations: []Location, padding := "\t", w: Maybe(io.Writer) = nil) { - w := w.? or_else os.to_writer(os.stderr) - +print :: proc(locations: []Location, padding := "\t") { for location, i in locations { - io.write_string(w, padding) - io.write_byte(w, '#') - io.write_int(w, i) - io.write_string(w, " ") - io.write_string(w, location.procedure) - io.write_string(w, " at ") - io.write_string(w, location.file_path) - + fmt.eprintf("%s#%v %v at %v", padding, i, location.procedure, location.file_path) if location.line > 0 { when ODIN_ERROR_POS_STYLE == .Default { - io.write_byte(w, '(') - io.write_int(w, int(location.line)) + fmt.eprintf("(%v", location.line) if location.column > 0 { - io.write_byte(w, ':') - io.write_int(w, int(location.column)) + fmt.eprintf(":%v)", location.column) } - io.write_byte(w, ')') } else when ODIN_ERROR_POS_STYLE == .Unix { - io.write_byte(w, ':') - io.write_int(w, int(location.line)) + fmt.eprintf(":%v", location.line) if location.column > 0 { - io.write_byte(w, ':') - io.write_int(w, int(location.column)) + fmt.eprintf(":%v", location.column) } } else { #panic("unhandled ODIN_ERROR_POS_STYLE") } } - io.write_byte(w, '\n') + fmt.eprintln() } }