Update Debugging In Intellij authored by Gregory Neibert's avatar Gregory Neibert
The Intellij documentation has a really in-depth explanation of how to use the debugger [(linked here)](https://www.jetbrains.com/help/idea/debugging-code.html#refreshers), so if you desire to use a more complex tool than those explained here, that documentation is a good place to start. However, due to it being very in-depth, a summary for the basic debugger is provided here. The Intellij documentation has a really in-depth explanation of how to use the debugger [(linked here)](https://www.jetbrains.com/help/idea/debugging-code.html#refreshers), so if you desire to use a more complex tool than those explained here, that documentation is a good place to start. However, due to it being very in-depth, a summary for the basic debugger is provided here.
## Basics # Basics
The Debugger is a tool primarily used to step through the code to help find the exact location where things went wrong. The Debugger is a tool primarily used to step through the code to help find the exact location where things went wrong.
### Creating and Removing Breakpoints ## Creating and Removing Breakpoints
In order to step through the code, a stopping point (breakpoint) must be set for the debugger. In order to step through the code, a stopping point (breakpoint) must be set for the debugger.
A breakpoint can be created and deleted simply by clicking to the right of the line number, as shown below. A breakpoint can be created and deleted simply by clicking to the right of the line number, as shown below.
...@@ -10,24 +10,24 @@ A breakpoint can be created and deleted simply by clicking to the right of the l ...@@ -10,24 +10,24 @@ A breakpoint can be created and deleted simply by clicking to the right of the l
<img src="https://i.imgur.com/P1sduNJ.gif"/> <img src="https://i.imgur.com/P1sduNJ.gif"/>
</p> </p>
### Running the Debugger ## Running the Debugger
Once the breakpoints are set, the debugger can be run by selecting whatever it is you desire to run and clicking the bug icon, as shown below. Once the breakpoints are set, the debugger can be run by selecting whatever it is you desire to run and clicking the bug icon, as shown below.
<p align="center"> <p align="center">
<img src="https://i.imgur.com/pGyAdOs.gif"/> <img src="https://i.imgur.com/pGyAdOs.gif"/>
</p> </p>
### Using the Debugger ## Using the Debugger
Now that we have run the debugger and stopped at the breakpoint, a lot of information is given in the Debug window. Now that we have run the debugger and stopped at the breakpoint, a lot of information is given in the Debug window.
#### Variables and Values ### Variables and Values
The primary benefit to using the debugger is being able to see every variable and its currently assigned value. These are displayed in the main window. As the program is stepped through, these values will update, allowing the user to easily see when a value is assigned incorrectly. The primary benefit to using the debugger is being able to see every variable and its currently assigned value. These are displayed in the main window. As the program is stepped through, these values will update, allowing the user to easily see when a value is assigned incorrectly.
#### Step Over ### Step Over
If you would like to skip over a function, use the Step Over button. This causes the debugger to run until the function is returned from, at which point it will pause again, giving control back to the user. If you would like to skip over a function, use the Step Over button. This causes the debugger to run until the function is returned from, at which point it will pause again, giving control back to the user.
#### Step Into ### Step Into
If you would like to view the internals of a function, you use the Step Into button. In this case, the user remains in control and see exactly how a function uses/modifies the data that it is given. If you would like to view the internals of a function, you use the Step Into button. In this case, the user remains in control and see exactly how a function uses/modifies the data that it is given.
#### Step Out ### Step Out
If you have determined that you have gone too many functions deep, you can quickly return to the line that called the function you are currently in by using the Step Out button. If you have determined that you have gone too many functions deep, you can quickly return to the line that called the function you are currently in by using the Step Out button.
#### Resume Program ### Resume Program
If you would relinquish control to the computer, simply press the Resume Program button, and everything will be run as usual. If you would relinquish control to the computer, simply press the Resume Program button, and everything will be run as usual.
<p align="center"> <p align="center">
... ...
......