Fundamentals 18 min read

Comprehensive Guide to IntelliJ IDEA Debugging Features

This article provides a detailed walkthrough of IntelliJ IDEA's debugging capabilities, covering preparation, main interface components, step controls, variable inspection, conditional breakpoints, expression evaluation, frame dropping, force return, multithreaded and stream debugging, as well as remote debugging techniques, supplemented by a Java code example.

Top Architect
Top Architect
Top Architect
Comprehensive Guide to IntelliJ IDEA Debugging Features

Debugging is one of the most frequently used features in IDEs like IntelliJ IDEA, allowing developers to trace code execution, monitor parameter changes, locate errors, and explore third‑party frameworks. This guide explains how to use the Debug tool effectively, including stepping, variable inspection, and remote debugging.

Preparation

Before using the Debug function, ensure you have IntelliJ IDEA installed and a sample code to debug. The example used is a classic LeetCode problem "Two Sum":

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class ToSum {
    public static int[] twoSum(int[] nums, int target) {
        Map
map = new HashMap<>();
        for (int i = 0; i < nums.length; i++) {
            int sub = target - nums[i];
            // if remainder exists, return indices
            if (map.containsKey(sub)) {
                return new int[]{map.get(sub), i};
            }
            map.put(nums[i], i);
        }
        throw new IllegalArgumentException("No two sum solution");
    }

    public static void main(String[] args) {
        int[] nums = {2, 7, 11, 15};
        int target = 9;
        int[] ints = twoSum(nums, target);
        System.out.println(Arrays.toString(ints));
    }
}

Main Debug Interface

The Debug window contains several sections:

Debug: Start debugging.

Breakpoint: Click the left gutter to set breakpoints.

Service Buttons: Controls such as Rerun, Edit Configuration, Resume (F9), Pause, Stop (Ctrl+F2), View Breakpoints, Mute Breakpoints, Get Thread Dump, Settings, Pin Tab.

Debug Buttons: Show Execution Point, Step Over (F8), Step Into (F7), Force Step Into, Step Out (Shift+F8), Drop Frame, Run to Cursor, Evaluate Expression, Trace Current Stream Chain.

Frames: Shows the call stack for the current thread.

Variables: Displays current variable values and allows editing.

Watches: Lets you monitor selected variables continuously.

Key Function Keys

Service buttons let you restart debugging, edit run configurations (including remote debugging), resume or pause execution, stop the program, and manage breakpoints. Debug buttons control execution flow, such as stepping over/into code, forcing entry into methods, dropping frames to revert to a previous call, and evaluating expressions on the fly.

Viewing and Changing Variables

Variable values appear inline next to code lines, can be hovered for details, or inspected in the Variables pane where they can be edited via Set Value… . Adding a variable to the Watches pane keeps it visible across steps.

Conditional Breakpoints

You can set a condition (e.g., n == null ) so the breakpoint only triggers when the condition is true, avoiding manual stepping through many iterations.

Evaluating Expressions

Use Evaluate Expression… to compute values like map.keySet() without modifying the source code, which is useful for hypothesis testing during debugging.

Drop Frame (Rollback)

The Drop Frame button allows you to roll back to the previous method call, effectively re‑executing that method, though side effects such as database changes cannot be undone.

Force Return

If you want to exit a method early without executing the remaining code, use Force Return to supply a return value (e.g., new int[]{2, 7} ) or throw an exception.

Multithreaded Debugging

By default, Debug blocks all threads except the current one. You can enable multithreaded debugging so only threads hitting breakpoints pause, while others continue running.

Stream Debugging

The Trace Current Stream Chain button becomes active when a breakpoint is set on a Stream expression, allowing you to step through each transformation step and view intermediate results.

Remote Debugging

To debug code running on a remote server, start the JVM with the agent option -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 , then configure a Remote JVM Debug configuration in IDEA with the server's IP and port. Once connected, breakpoints in your local IDE will trigger on the remote process.

Conclusion

All essential IDEA Debug features have been covered, enabling developers to efficiently trace, inspect, and modify program execution for both local and remote scenarios.

debuggingjavaIntelliJ IDEAIDEdevelopment toolsRemote Debugging
Top Architect
Written by

Top Architect

Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.