Intellij IDEA Debug

Customize shortcut keymap

change keymap
shortcut key

change intellij’s keymap to eclipse’s

  • F5 step into a method
  • Ctrl + F5 smart step in
  • F6 step over a row
  • F7 step out a method
  • Ctrl + R step to cursor’s raw

Samrt step in

smart step in
Ctrl + F5
when a series method link a callback, smart step in debug is useful.

Thread Block

break point
In default when current thread met breakpoint, other thread will be blocked.
Util current debug thread finished.
If project need to debug in multi thread, set breakpoint the suspend in thread.

Frames

frame opt
Java’s memory model is a thread have multi methods, a method corresponding a frame.
Every frame have a private variable array, it’s 0 index is this.[Stacks Link Invocate]
When drop the frame, debug will roll back.

Thread List

thread list
Show thread list, thread status.

Thread’s Frames

switch thread
Used to switch thread, but it seem can’t debug a thread’s code alone.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
public class DebugTest {

private static Object lock = new Object();

@Test
public void main() {
try {
for(int i=0; i< 3; i++) {
new Line().start();
Thread.sleep(1000);
}
new LineAnother().start();
Thread.sleep(100000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class Line extends Thread {
public void run() {
synchronized (lock) {
// smart step in
if (Thread.currentThread().getContextClassLoader().equals(new Object()))
System.out.println("-_-!");

for (int i = 0; i < 3; i++)
System.out.println(Thread.currentThread().getId() +
"\t" + Thread.currentThread().getName() +
"\t" + i);
test(5);
}
}
// sub frame
public int test(int i) {
i -= 1;
return i;
}
}
1
2
3
4
5
6
class LineAnother extends Thread {
public void run() {
System.out.println("xxx");
System.out.println("ooo");
}
}