Debugging Guide

fble-0.5 (2025-07-13,fble-0.4-212-ga8f8ad0f)

Fble has some limited support for debugging. This document explains tips and tricks for making the most of the currently available debug support.

For printf like debugging

Use the /Core/Debug%.Trace functions for the strings to print.

For example:

Unit@ _ = /Core/Debug%.Trace(Strs[Str|'x is: ', /Core/Int/Show%.Show(x)]);
...

To more easily enable or disable tracing, and avoid the costs of computing the trace message when disabled, you can use a style like this:

% Trace = /Core/Debug%.Enable(True);  # Change to False to disable tracing.

Unit@ _ = {
  Unit@ _ <- Trace.TraceLn;
  String@ debugDump = ExpensiveDebugFunction(x);
  Strs[Str|'x is: ', debugDump];
};

You should see Trace values printed to stderr as the program executes.

Compile your code

There is dwarf debug support for compiled fble code generated using the aarch64 target. Dwarf based debug is not currently available for compiled fble generated using the c target nor for interpreted fble code. Compile your code using the aarch64 target to access that debug support.

You should now be able to debug your fble code with gdb.

To print an Int@ variable value in gdb
print FbleIntValueAccess(foo)
To print a String@ variable value in gdb
print FbleStringValueAccess(foo)
To access a struct field
print FbleStructValueField(foo, tag)
To set a breakpoint that will trigger on runtime error
break fprintf
To avoid stepping into runtime implementation code
skip -gfi *.c

Note: This currently will not work because it's too much of a pain to maintain the code needed to support it.