|
| 1 | +# MusicBlocks Debugger Guide |
| 2 | + |
| 3 | +## Introduction |
| 4 | + |
| 5 | +Debugging is a crucial skill for any programmer. The MusicBlocks JSeditor debugger tool is designed to help learners and educators understand, trace, and fix issues in their code by providing interactive, visual, and step-by-step debugging capabilities. This guide will walk you through all aspects of using the debugger in MusicBlocks. |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +## Key Features of the Debugger |
| 10 | + |
| 11 | +1. **Breakpoint System:** |
| 12 | + - Set breakpoints directly in the JSeditor by clicking next to the line numbers. |
| 13 | + - Breakpoints are visually indicated and can be toggled on/off. |
| 14 | + |
| 15 | +2. **Step-by-Step Execution:** |
| 16 | + - Use the “Run Slowly” or “Step” buttons to execute your program one step at a time. |
| 17 | + - Execution pauses at each breakpoint or debugger block. |
| 18 | + |
| 19 | +3. **Variable Inspection:** |
| 20 | + - When execution pauses, you can create a status block, showing all user-defined and MusicBlocks variables. |
| 21 | + - The status block is automatically populated with relevant variables for easy inspection. |
| 22 | + |
| 23 | +4. **Visual Block Integration:** |
| 24 | + - Breakpoints in code are converted to debugger blocks in the visual interface. |
| 25 | + - The currently executing block is highlighted for clear tracking. |
| 26 | + |
| 27 | +5. **Flexible Debugging Controls:** |
| 28 | + - Resume, step, or stop execution at any paused point. |
| 29 | + - Debugger blocks only affect execution in debug modes (not during normal “Play”). |
| 30 | + |
| 31 | +--- |
| 32 | + |
| 33 | +## Step-by-Step Guide to Debugging |
| 34 | + |
| 35 | +### 1. Setting Breakpoints |
| 36 | + |
| 37 | +- **In the JSeditor:** |
| 38 | + Click the area next to the line number where you want to pause execution. A breakpoint marker will appear. |
| 39 | +- **In Block View:** |
| 40 | + Add a “debugger” block at the desired location in your block stack. |
| 41 | + |
| 42 | +### 2. Running and Pausing |
| 43 | + |
| 44 | +- When your program hits a breakpoint or debugger block, execution will pause. |
| 45 | +- The currently executing block will be highlighted in the block view. |
| 46 | + |
| 47 | +### 3. Inspecting Variables |
| 48 | + |
| 49 | +- Create a status block from the widget palette, and the status window will automatically pop up, displaying all variables. |
| 50 | +- You can see both user-defined and system variables (e.g., loop counters, music parameters). |
| 51 | +- The status block in the workspace will also show these variables. |
| 52 | + |
| 53 | +### 5. Resuming or Stepping |
| 54 | + |
| 55 | +- Use the "run slowly" button to run to the next breakpoint. |
| 56 | +- Use the “Step” button to execute the next block or line. |
| 57 | + |
| 58 | +### 6. Modifying and Re-running |
| 59 | + |
| 60 | +- You can edit your code or blocks while paused. |
| 61 | +- After making changes, restart the blocks to test your fixes. |
| 62 | + |
| 63 | +--- |
| 64 | + |
| 65 | +## Best Practices for Effective Debugging |
| 66 | + |
| 67 | +- **Set Breakpoints Strategically:** Place breakpoints before and after sections where you suspect issues. |
| 68 | +- **Inspect Variables Frequently:** Check variable values at each pause to understand program state. |
| 69 | +- **Use Step Execution:** Step through loops and conditionals to see how your logic unfolds. |
| 70 | +- **Leverage Visual Feedback:** Follow the highlighted blocks to trace execution flow. |
| 71 | +- **Keep the Status Window Open:** It provides a live snapshot of all relevant variables. |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Advanced Tips |
| 76 | + |
| 77 | +- **Single Status Block:** Only one status block is active at a time to avoid confusion. |
| 78 | +- **Debugger Blocks in Block View:** You can manually add or remove debugger blocks for more granular control. |
| 79 | +- **Debugging Only in Debug Modes:** Debugger blocks and breakpoints only pause execution in debug/step modes, not during normal play. |
| 80 | +- **Automatic Variable Detection:** The debugger automatically includes all custom variables in the status block for you. |
| 81 | + |
| 82 | +--- |
0 commit comments