April 9, 2020
Estimated Post Reading Time ~

Debugging in IntelliJ IDEA: Part 1

IntelliJ IDEA provides a handy debugger for grails, which simplifies debugging. Many people try avoiding using this awesome feature just because, either, they don’t want to leave the old habit of using printlns or they complain about the performance issue and bla bla bla. As per my observation, there is no performance difference between the run-app and debug the app. 

Maybe they just need to change the mindset to take advantage of this helpful feature. If we run the app in debug mode, for evaluating any expressions, we just set the breakpoints and evaluate the expressions with no need to reload the app, thereby increasing our productivity.

I have decided to cover ‘Debugging in IntelliJ IDEA’ in three-part blog series as listed below;
Part 1- Simple Debugging in IntelliJ IDEA
Part 2- Remote debugging in IntelliJ IDEA
Part 3- Debug JavaScript in IntelliJ IDEA
The following are some steps to run your grails application in debug mode.

Setting breakpoints
Set breakpoints in your grails-app. This is most easy – just click the left gutter at the line you want the script to suspend.


Run the grails-app in debug mode
Select the run menu and click on debug, now your application start in debug mode.
Examining the debugging information
After starting application your program execution suspends when the first breakpoint is hit. Such a breakpoint is marked with a blue stripe.


You can press F8 to step to the next statement and f9 to step to the next breakpoint.
As you step through your application, the corresponding information appears in the debugger window.
Select examining variable then click on Add to Watches button in Watches window, the output gets displayed.


Evaluate Expression
You can evaluate any expression on clicking the Evaluate Expression button in the debugger window.


Enter any expression which you want to evaluate then click on the Evaluate button.


View and Mute Breakpoints
You can view all breakpoints on clicking the View BreakPoints button in the debugger window and also can remove or add breakpoints here.


There is also a button Mute Breakpoints button in this window.


This covered Simple debugging in IntelliJ IDEA and We’ll introduce Remote debugging in IntelliJ IDEA in the next coming part.



By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.