Skip to content
maximecb edited this page Nov 18, 2014 · 3 revisions

Instruction Trace

You can log a trace of all executed IR instructions with the --trace_instrs command-line option. This slows down the program execution significantly, and so makes this approach unsuitable for long-running programs. It may be necessary to try and shorten your program to make it crash/fail faster.

GNU Debugger (GDB)

To do this, Higgs must first be compiled with debug information. You can compile a debug binary with the make debug command from the source directory. It is then possible to run the debug executable with gdb.

Print Statements

When all else fails, print() statements may be used to follow the execution flow. This does not always work, however, because the print() JavaScript function itself may disrupt the execution of your program by allocating data, for example, when converting integers to strings. There are also cases where introducing a function call into your program can change the way machine code is generated, making some bugs temporarily disappear (i.e.: heisenbugs).

Two low level IR instructions are available which can print without triggering the GC and without introducing function calls. These are $ir_print_str() and $ir_print_ptr(). The former can print JS strings, and the second one interprets values as pointers and prints them in hexadecimal notation. Note that $ir_print_str() can only print atomic strings and not ropes, that is, strings which are not the result of string concatenation.