Skip to content
RblSb edited this page Aug 14, 2023 · 2 revisions

Using a debugger

To debug the Haxe compiler, you can use either a system debugger (gdb/lldb), or ocamldebug. ocamldebug provides a better debugging experience. To use it, uncomment (modes byte) from src/dune and recompile.

Using printf

To print information about a type, you can add the following before most lines:

Printf.printf "%s\n" (s_type_kind t);

To print specific data structure, you can see other functions with s_ prefix, or check Printer.s_* functions

print_endline (s_expr_debug expr);
print_endline (Printer.s_type t);

There are lots of other stringifying functions in src/core/tPrinting.ml. If specific data structure is not there, you can try to convert it to json first:

let jctx = Genjson.create_context GMFull in
let json = (Genjson.generate_anon_status jctx anon.a_status) in
print_endline (Json.string_of_json json);

If you want to get stacktrace of current call without debugger, you can add die "" __LOC__; to crash compiler on specific line.