Debugging a robot program
A debugger is used to control program flow and monitor variables in order to assist in debugging a program. This section will describe how to set up a debug session for a Java FRC robot program.
Set a Breakpoint
Clicking the “Debug” button does several things. It changes the Workbench to the Debug Perspective which has the views Debug, Breakpoints, and Variables along the right side of the window. It starts the robot task and connects to it with the debugger
Now double-click in the left margin of the source code window to set a breakpoint in your user program: A small blue circle indicates the breakpoint has been set on the corresponding line. (You can see all your breakpoints in the Workbench’s Breakpoints view.)
Start Debugging
- Right click on the project
- Select Debug As
- Click WPILib Java Deploy
The Debug Perspective will open automatically and the debug process will begin running. Note that the Java debugger does not break at the first program instruction so if you wish to catch the program before it executes the constructor or RobotInit or a similar method you should set a breakpoint (described below) before you start debugging.
The Debug window
The Debug window shows all processes and threads spawned by your code running on the roboRIO. When your breakpoint is reached, make sure your program is selected in the task list and your source code is displayed with a program pointer. You can continue stepping through your code using “Resume,” “Step Into,” “Step Over,” and “Step Return” buttons: If you don't see Java code displayed, it’s because you’ve stepped down into library code where the source is not available to the debugger. “Step Return” will bring you back up a level.
If the debug toolbar (resume, terminate and step controls) is not visible, click the down arrow at the top right of the debug window and select the Show Debug Toolbar option
The code will automatically run until it hits a breakpoint. Note that if the breakpoint you have placed is inside one of the Teleoperated or Autonomous methods, the robot will have to be set to the appropriate mode and enabled with the Driver Station in order to reach the breakpoint.
Your Breakpoint
The Variables Tab
The Variables view shows the current values of variables. To see a variable that is not displayed, select the “Expressions” tab and enter the variable name. This will show the variable’s value if it’s in scope. You may also want to click on the arrows next to a variable to expand the tree and show it's members. For example, expanding our Robot Demo variable ("this") shows our "myRobot" and "stick" variables.
Stopping Debugging
Subsequent Debugging
If you would like to change code and relaunch the debugger from the Debug perspective:
- Click the top level of the existing debug session in the Debug pane
- Click the Terminate button
- Click in the window where your project source code is located. Putting the focus on this window is necessary for Eclipse to know what project to run.
- Click the Run menu
- Select Debug As
- Click WPILib Java Deploy
If you see grayed out menu items or don't see the WPILib Java Deploy menu option, make sure that the window focus is on source code from your project as described in Step 3.
Debugging with Console
Another way to debug your program is to use System.out.println statements in your code and receive them using the RioLog in Eclipse.








0 Report Errors
Use this form to report any errors with the documentation. For help with WPILib, please use the FIRST Forums at http://forums.usfirst.org For reporting WPILib bugs, please submit an issue on GitHub at https://github.com/wpilibsuite/allwpilib/issues/new