Skip to main content

Debugging

BBj provides a powerful console-based debugging environment that lets you break into a running program, step through code line by line, inspect and modify variables, and trace execution to a file. These tools work directly in the BBj interpreter -- no IDE plugin required.

At a Glance

TechniqueCommand/VerbPurpose
Break to consoleCtrl-C or Ctrl-BreakPause running program
Single step. + EnterExecute one line
Step over.. + EnterExecute one line, skip subroutine internals
Step N lines. nExecute next n lines
Print variable? var or PRINT varDisplay variable value
Change variablevar = newvalueModify variable at runtime
Search code\searchstringFind text in program
DUMPDUMP(chan)Write all variables to file
SETTRACESETTRACE(chan)Log each executed line to file
ENDTRACEENDTRACEStop tracing

BBj debugging is interactive. You are inside the running interpreter with full access to program state. You can evaluate expressions, call methods, and even change code flow -- the console is a live REPL in the context of your paused program.

For Java, Python, and C# Developers

TaskJavaPythonC#BBj
Print debugSystem.out.println(x)print(x)Console.WriteLine(x)print x
Set breakpointIDE breakpoint or assertbreakpoint()IDE breakpointCtrl-C or Ctrl-Break at runtime
Trace execution-verbose flag or debuggersys.settrace(fn)Debugger step-throughSETTRACE(chan) to log each line
Inspect variableDebugger watch windowpdb: p variableDebugger watch window? var in console
Dump all variablesHeap dumplocals()Debugger locals windowDUMP(chan) to file

BBj's debugger is built into the interpreter console -- no IDE plugin required. You break into a running program and interact with it as a live REPL. For the complete cross-language reference, see BBj for Java, Python, and C# Developers.

Complete Runnable Examples

This chapter's code snippets illustrate individual concepts. For complete, runnable programs you can open directly in the BBj IDE, see the sample files in samples/11-debugging/:

  • settrace_example.bbj -- SETTRACE/ENDTRACE to record line-by-line execution
  • dump_example.bbj -- DUMP verb to write all variables to a file
  • logging_example.bbj -- System.out.println and PRINT-based logging techniques

See Running Samples for setup instructions.