Skip to main content

Debugger

Introduction to the debugger​

The JARU IDE debugger runs your program in its own VM and stops it at the lines you mark, so you can step through it line by line and look at the values of your variables. Its buttons are in the Build tab of the ribbon, in the Debug group.

Breakpoints​

A breakpoint stops the program when it reaches that line.

  • To set one, click in the left margin of the code editor, next to the line number, or put the cursor on the line and press F9.
  • A red mark appears in the margin.
  • To remove it, click the mark again or press F9 on the line.

Starting a debug session​

  1. Set at least one breakpoint.
  2. Press Debug, or F5 in the code editor. The IDE compiles the project and starts it in its own VM.
  3. When it reaches the breakpoint, the program stops, the editor highlights the line and the Output says at which line and file it is paused. The IDE comes to the front.
The program waits

While it is paused, the game window does not respond, and Windows may say "Not responding". That is normal: it is waiting for you to let it go on.

Controls​

ActionButtonShortcutWhat it does
DebugDebugF5Compiles and starts the program for debugging
ContinueContinueF5Runs on to the next breakpoint
Step OverStep OverF10Runs the highlighted line without going into the functions it calls
Step IntoStep IntoRuns the highlighted line going into the function it calls
StopStopCloses the program and its console

The shortcuts work with the cursor in the code editor. Stop is in the Compiler group of the same tab.

Watch window​

Watch, in the Debug group, opens a window that shows the variables you ask for:

  1. Type the name of the variable in the box at the top. It comes with "New Variable..." written in it: delete that first.
  2. Press Enter.
  3. While the program is paused, the window shows its value (Value), its type (Type) and its context (Context), for example local.

Long lists are shown in pages: Items/page says how many items fit in each one.

You can also add it from the code editor: put the cursor on the name of the variable, or select it, right-click and choose Add Watch. If Watch is closed, it opens it; if the program is paused, it shows its value straight away, and if the variable was already in the list, it tells you so. The right click does not move the cursor: it takes the word where the cursor is, not the one under the mouse.

Practical example​

func factorial(n)
if (n <= 1) then // Put the breakpoint here
return 1
end
return n * factorial(n - 1)
end

var result = factorial(5)
print(result)
  1. Set a breakpoint on the if line, with a click in the margin or with F9.
  2. Press F5 to debug. The program stops at the if.
  3. In Watch, add n: it is 5.
  4. Press F5 to go on. The program stops at the if again with the next call, and Watch shows the new n.

What it does not have yet​

The debugger has no conditional breakpoints, and a breakpoint cannot be disabled without removing it. It does not show the call stack or a panel with the local variables, and it has no console to evaluate expressions. There is no button to step out of the current function (Step Out) either.

Tips​

Efficient debugging

Step Over (F10) does not go into functions: it is the quickest way when you already know a function does what it should.

Performance

Step-by-step debugging is slower than normal execution. Put breakpoints where you need them instead of stepping through all the code line by line.