wiki:ControlSystems/SoftwareTeam/Training/GettingStarted/Debugger

Microsoft VSCode includes a powerful tool called a debugger. A debugger lets you control the execution of your program and examine it while it's running.

With the VariablesExample.java program from the last lesson open in the editor click to the left of the line number (7) for the line a=3; and a red dot will appear called a breakpoint.

  1. Click Debug->Start Debugging (or press function key F5)
  2. The program will start running but will stop (break) at line 7

  1. Click on the Step-over icon above the editor (or press function key F10) to execute that line of code and then stop again
  2. Observe the Variables window in the left navigation panel and note that there is now a variable named 'a' with the value 3

  1. Press F10 again to execute the line b=4 and observe the variable appearing in the Variables window
  2. Double click on the variable b in the Variables window and change its value to 5
  3. Press F10 again to execute the line c=a*b and observe the variable c appearing in the Variables window with the value 15.
  4. Press the Continue tool (or function key F5) above the editor window to allow the program to continue running to the end. Observe the value printed in the output terminal window.

The VSCode debug toolbar offers a complete set of tools to control the execution of your program:

  • Continue / Pause F5
  • Step Over F10
  • Step Into F11
  • Step Out Shift+F11
  • Restart Ctrl+Shift+F5
  • Stop Shift+F5
Last modified 19 months ago Last modified on Nov 4, 2019, 3:11:06 PM

Attachments (7)

Download all attachments as: .zip