Version: 1.1.0

Debugging

Mojo programs debug with prints, assertions, and the LLDB-based mojo debug flow.

Essentials

  • print of intermediate values is still the fastest first step.
  • comptime assert catches mistakes before a binary exists.
  • mojo debug file.mojo launches the debugger.
  • The VS Code extension can drive the same debugger.
  • Optimize after the values are right. Inlined kernels are harder to step through.

Example

$ mojo debug hello.mojo

Keep in mind

When a GPU kernel misbehaves, first run the same math on the CPU. Most index bugs show up there.