diff --git a/build.sh b/build.sh index 95756fb..06fc364 100755 --- a/build.sh +++ b/build.sh @@ -93,6 +93,7 @@ function build_zig { -DLV_USE_LOG=1 \ -DLV_LOG_LEVEL=LV_LOG_LEVEL_TRACE \ -DLV_LOG_TRACE_OBJ_CREATE=1 \ + -DLV_LOG_TRACE_TIMER=1 \ -DLV_MEM_SIZE=1000000 \ "-DLV_ASSERT_HANDLER={void lv_assert_handler(void); lv_assert_handler();}" \ -I . \ @@ -227,6 +228,7 @@ function compile_lvgl { -DLV_USE_LOG=1 \ -DLV_LOG_LEVEL=LV_LOG_LEVEL_TRACE \ -DLV_LOG_TRACE_OBJ_CREATE=1 \ + -DLV_LOG_TRACE_TIMER=1 \ -DLV_MEM_SIZE=1000000 \ "-DLV_ASSERT_HANDLER={void lv_assert_handler(void); lv_assert_handler();}" \ \ diff --git a/lvglwasm.wasm b/lvglwasm.wasm index c5a32b3..8a4c798 100755 Binary files a/lvglwasm.wasm and b/lvglwasm.wasm differ diff --git a/lvglwasm.zig b/lvglwasm.zig index ef8f993..7a2f77b 100644 --- a/lvglwasm.zig +++ b/lvglwasm.zig @@ -44,7 +44,9 @@ pub export fn lv_demo_widgets() void { c.lv_log_register_print_cb(custom_logger); // Init LVGL + debug("before lv_init", .{}); //// c.lv_init(); + debug("after lv_init", .{}); //// // Fetch pointers to Display Driver and Display Buffer const disp_drv = c.get_disp_drv(); @@ -177,9 +179,9 @@ export fn millis() u32 { /// Number of elapsed milliseconds var elapsed_ms: u32 = 0; -/// TODO: Print a Stack Trace on Assertion Failure and halt +/// On Assertion Failure, print a Stack Trace and halt export fn lv_assert_handler() void { - wasmlog.Console.log("*** lv_assert_handler: ASSERTION FAILED", .{}); + @panic("*** lv_assert_handler: ASSERTION FAILED"); } /// Custom Logger for LVGL that writes to JavaScript Console @@ -187,30 +189,6 @@ export fn custom_logger(buf: [*c]const u8) void { wasmlog.Console.log("{s}", .{buf}); } -/////////////////////////////////////////////////////////////////////////////// -// Panic Handler - -/// Called by Zig when it hits a Panic. We print the Panic Message, Stack Trace and halt. See -/// https://andrewkelley.me/post/zig-stack-traces-kernel-panic-bare-bones-os.html -/// https://github.com/ziglang/zig/blob/master/lib/std/builtin.zig#L763-L847 -pub fn panic(message: []const u8, _stack_trace: ?*std.builtin.StackTrace) noreturn { - // Print the Panic Message - _ = _stack_trace; - wasmlog.Console.log("\n!ZIG PANIC!\n{s}", .{message}); - - // TODO: Print the Stack Trace - wasmlog.Console.log("Stack Trace:", .{}); - var it = std.debug.StackIterator.init(@returnAddress(), null); - while (it.next()) |return_address| { - wasmlog.Console.log("{}", .{@intCast(i32, return_address)}); - } - - // Halt - while (true) { - wasmlog.Console.log("Halted", .{}); - } -} - /////////////////////////////////////////////////////////////////////////////// // Logging