The following interface is the interface of MAC 2020.1. First, take a look at the interface in debug mode in idea.
- 1. Express with
Debug modeTo start the service, the first button on the left starts in the run service mode. In development, we generally start the debug mode directly to facilitate debugging the code at any time.
breakpoint: left click in the line number column on the left, or
F8Mark / cancel breakpoints, and the color of the breakpoint line can be set by yourself.
Debug window: after the access request reaches the first breakpoint, the debug window is automatically activated. If it is not activated automatically, you can set it in the settings.
Debug button: you can find the same corresponding function in run in the menu bar.
Service button: you can turn off / start the service, set breakpoints, etc. here.
Method invocation stack: all the methods debugged by this thread are displayed here. Check the [show all frames] button in the upper right corner, and the methods of other class libraries will not be displayed. Otherwise, there will be a lot of methods here. The following figure shows the methods of other class libraries.
Variables: in the variables area, you can view the variables in the current method before the current breakpoint.
In the process of debugging, it is very necessary to track and view the changes of variables. Here are a few places where variables can be viewed in the idea. I believe most people understand it.
Evaluate ExpressionThis expression can not only be a general variable or parameter, but also a method. When you call several methods in a row of code, you can look at the return value of a method in this way.
Think about how to select only one method to enter when there are several methods in one line of code. You can use step into or force step into, but these two operations will enter at one time according to the order of method calls, which is troublesome, so smart step into is very convenient.
How to interrupt the request during debugging without going through the rest of the process.
You can see that this is where we broke on line 797.
It can be handled by forcing a return or throwing an exception.
This method returns a string of type string, so you only need to add any return value, and then click
Resume Program, you can forcibly terminate debug.
This work adoptsCC agreement, reprint must indicate the author and the link to this article