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 run-app and debug app. May be they just need to change the mindset to take advantage of this helpful feature. If we run app in debug mode, for evaluating any expressions, we just set the breakpoints and evaluate the expressions with no need to reload the app, there by increasing our productivity.

I have decide 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

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 grails app in debug mode

Select 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, output get displayed.

Evaluate Expression

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

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

View and Mute Breakpoints

You can view all breakpoints on clicking View BreakPoints button in 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 next coming part.


comments (4)

Leave a Reply

Your email address will not be published. Required fields are marked *