diff --git a/Makefile b/Makefile index ab111fd..b4fab4c 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +run_debug: + ./build-unix-debug.sh && ./shf + run: ./build-unix.sh && ./shf diff --git a/build-unix-debug.sh b/build-unix-debug.sh new file mode 100755 index 0000000..642b991 --- /dev/null +++ b/build-unix-debug.sh @@ -0,0 +1,8 @@ +#!/bin/sh +mlton -const 'Exn.keepHistory true' -link-opt "$(pkg-config --cflags glfw3) $(pkg-config --static --libs glfw3)" \ + -export-header ffi/export.h \ + shf.mlb \ + ffi/glad.c \ + ffi/glfw-export.c \ + ffi/gles3-export.c \ + ffi/glfw-input.c diff --git a/shell/update-thread.sml b/shell/update-thread.sml index a42582f..f4d435b 100644 --- a/shell/update-thread.sml +++ b/shell/update-thread.sml @@ -17,7 +17,19 @@ struct fun loop (app: AppType.app_type, inputMailbox, drawMailbox) = let val inputMsg = Mailbox.recv inputMailbox - val app = AppUpdate.update (app, inputMsg) + val app = + AppUpdate.update (app, inputMsg) + handle e => + let + (* print stack trace for debugging purposes, + * and then raise another exception to exit the program *) + val stackTrace = MLton.Exn.history e + val stackTrace = String.concatWith "\n" stackTrace + val () = print (stackTrace ^ "\n") + in + raise Empty + end + val () = sendMsgs (#msgs app, drawMailbox) in loop (app, inputMailbox, drawMailbox)