From e5cc3dd84467e066a82534ab656be6564b20b342 Mon Sep 17 00:00:00 2001 From: Wouter van Oortmerssen Date: Wed, 4 Oct 2023 18:21:24 -0700 Subject: [PATCH] dumpview.lobster --- samples/tools/dumpview.lobster | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 samples/tools/dumpview.lobster diff --git a/samples/tools/dumpview.lobster b/samples/tools/dumpview.lobster new file mode 100644 index 000000000..e98c63257 --- /dev/null +++ b/samples/tools/dumpview.lobster @@ -0,0 +1,42 @@ +/* +This tool allows you to view the contents of memory dump files generated by Lobster's +--runtime-memory-dump mode. +This is very useful to be able to debug crashes that may happen on a client's machine. +Make sure they run with the above flag, then when it crashes, have them send you the +.flex file it writes, and load up that file with this program, that allows you to +browse the full program state from a stack trace! + +Example: +bin/lobster.exe --runtime-memory-dump my_buggy_program_that_asserts.lobster +bin/lobster.exe samples/tools/dumpview.lobster -- crash_stack_trace_memory_dump_2023-10-04-12-16-50.flex + +*/ + +import vec +import color +import gl +import imgui +import gl + +let args = command_line_arguments() +if args.length != 1: + fatal("dumpview: expecting exactly 1 argument, the dump file name.") + +let fb = read_file(args[0]) +if not fb: + fatal("dumpview: can\'t read file: " + args[0]) +assert fb + +fatal(gl.window("Crash dump viewer", 640, 1024)) + +im.init(false, im.config_docking_enable, 3.0) +assert im.add_font("data/fonts/Droid_Sans/DroidSans.ttf", 20.0) + +while gl.frame(): + gl.clear(color_grey) + im.frame(): + im.next_window_pos(float2_0, float2_0) + im.next_window_size(float(gl.window_size())) + im.window_dock("Crash dump viewer", im.window_no_collapse | im.window_no_titlebar | + im.window_no_resize | im.window_no_move): + im.show_flexbuffer(fb)