LibreOffice Basic IDE Debugging Tools

This article provides a concise overview of the debugging tools built into the LibreOffice Basic Integrated Development Environment (IDE). It outlines essential features such as breakpoints, step-by-step code execution, variable inspection, the Watch window, and the Call Stack, enabling developers to efficiently locate and resolve errors in their macro scripts.

Breakpoints

Breakpoints pause code execution right before a designated line runs, allowing you to inspect the program’s state. * Setting Breakpoints: Click in the left-hand margin next to the line number or place the cursor on a line and press F9 (or select the breakpoint icon on the Macro toolbar). * Behavior: When the macro runs, execution automatically halts at the breakpoint, highlighting the line in yellow.

Stepping Execution

The IDE offers multiple stepping commands to navigate code line by line: * Single Step / Step Into (F8): Executes the current line of code. If the line contains a call to another Sub or Function, execution steps inside that procedure. * Procedure Step / Step Over (Shift + F8): Executes the current line without entering called procedures, treating the entire procedure call as a single step. * Step Out (Ctrl + Shift + F8): Executes the remainder of the current procedure and pauses immediately after returning to the calling procedure.

Watch Window

The Watch window monitors specific variables, objects, and expressions as the code executes. * Adding a Watch: Select a variable or expression in the code editor, right-click, and choose Enable Watch, or click the Watch button on the toolbar. * Monitoring: The Watch pane displays the variable name, its current runtime value, and its data type, updating dynamically as you step through the code.

Calls Window (Call Stack)

When debugging nested procedures, the Calls window displays the execution hierarchy. * It lists the chain of active Sub and Function calls leading up to the current point of execution. * Selecting an entry in the Call Stack navigates to that specific frame’s context within the editor.

Value Tooltips (Data Inspection)

When execution is paused (either at a breakpoint or during a step), you can hover the mouse cursor over any variable in the code editor. A tooltip pops up instantly displaying the variable’s current value.

Execution Control (Run, Pause, Stop)

The Macro toolbar provides core execution controls: * Run Basic (F5): Starts or resumes execution until the next breakpoint or program completion. * Stop (Shift + F5): Terminates the macro execution immediately and resets runtime variables. * Compile: Verifies the macro syntax and prepares the code for execution without running it.