Skip to content
FutureBlitz

    Install

    Tools

    Debugging and stack traces

    Stack traces from panics and uncaught errors, debug info, and stepping through code in VS Code or any debugger.

    Stack traces

    A panic, or an error nothing catches, prints where it happened and the calls that led there, by FutureBlitz’s own names, files, and lines:

    Import std.core
    
    Function Pick(items: String[], at: Int): String
        Return items[at]
    End Function
    
    Function Choose(): String
        Return Pick(["red", "green", "blue"], 5)
    End Function
    
    Print(Choose())
    Output
    panic: index 5 is out of range for 3 elements at main.fb:4:12
        at Pick (main.fb:4)
        at Choose (main.fb:8)
        at top-level code (main.fb:11)

    Every executable fb builds, debug and release, has a table of where each call is, so a program on someone else’s machine prints the same trace with no debug files shipped. A program that panics exits with 101.

    Debug info

    A debug build, the default, has full debug info: DWARF on Linux and macOS, and CodeView on Windows, in a .pdb beside the executable. A debugger sees functions, lines, locals, and parameters, and the types of each: Structs, Classes, arrays, Strings, nullables, and Enums. A release build, --release, keeps line tables, so its traces and a debugger’s still name lines.

    In VS Code

    The FutureBlitz extension debugs with CodeLLDB, on every OS.

    1. Open a .fb file, or a package’s folder.
    2. Set breakpoints in the gutter.
    3. Press F5. The extension builds the program in debug, shows any errors in Problems, and runs it under the debugger.

    Strings, arrays, Maps, nullables, and Classes show as their values, through a script fb ships, lldb/futureblitz.py. A launch.json configuration says what to run:

    {
      "type": "futureblitz",
      "request": "launch",
      "name": "Debug",
      "program": "${workspaceFolder}",
      "args": ["--verbose"],
      "stopOnEntry": false
    }
    Key
    programA .fb file, or a package’s folder
    argsThe program’s command line
    cwd, envIts folder and its environment
    releaseBuilds it with --release
    stopOnEntryStops before its first line
    terminalWhere it runs: the integrated terminal, an external one, or the console

    CodeLLDB’s own keys, like preRunCommands, go in the same configuration.

    In another debugger

    A debug build is an ordinary native executable, so any debugger that reads its platform’s debug info works on it: lldb or gdb on Linux and macOS, and Visual Studio or WinDbg on Windows, with the .pdb. In lldb, command script import <FutureBlitz>/lldb/futureblitz.py shows FutureBlitz’s values as VS Code does.

    Report an issue with this page or with FutureBlitz on GitHub.