Idea's debug breakpoint debugging

A summary of thread breakpoints in Idea's debug mode:

Breakpoint introduction:

img

As shown in the figure, breakpoints can be all breakpoints and thread breakpoints, and each type of breakpoint can also set conditions, and the breakpoint will only be entered when the conditions are met.

1. When set to All

img

Click the drop-down box of the delivery, you can see that two threads are intercepted at this time, and the value on the right side will change accordingly when switching. But when you click next, the breakpoint ends. And the one I used most and most familiar with before is also this one. After each breakpoint is gone, it is gone. When I want to enter again, I can only call the method where the breakpoint is located again.

2. When set to thread

img

When the breakpoint is entered for the first time, thread-0 can be clearly seen below, indicating that the first thread is entered, which is the same as the case of All. Click the drop-down box below and the second thread will still appear. When switching to the second thread, you can clearly see that the output on the right is different.

img

But if you click next again, it still stays at the breakpoint. But the bottom becomes thread-1, and the thread-0 thread is no longer in the drop-down box below, as shown in the following figure:

img

So when you set more than one thread and click next, you will find that you have entered a breakpoint again. The breakpoint will not end until all threads have finished walking. This will clearly see the state of the breakpoint in different threads.

3. Set a conditional breakpoint,

When multiple requests are initiated, sometimes you want to see the state of a certain piece of data when it enters the breakpoint. When setting the breakpoint, right-click and enter the condition for entering the breakpoint in the condition input box. , whether it is a multi-threaded or single-threaded breakpoint, it will only be entered when the conditions are met. The debugging time is reduced, and the debugging effect can be achieved directly and quickly.

Disable all breakpoints:

In the process of debugging, I don't know which breakpoint is wrong. There is a bug in a line of code, and I want to skip all breakpoints,

insert image description here

After clicking, the breakpoint changes from red to gray-white. After pressing F9, all breakpoints are skipped and will not stop.

Conditional breakpoints
insert image description here

Assuming that the breakpoint is here, the string s needs to satisfy the content of Zhang San before the breakpoint is made.

insert image description here

A condition window will appear

Enter java expression

insert image description here

The string s satisfies the content for Zhang Sancai to make a breakpoint

After setting, it will stay when the conditions are met,

Guess you like

Origin blog.csdn.net/qq_43842093/article/details/123908878