当前位置:网站首页>Idea breakpoint debugging skills, multiple dynamic diagram package teaching package meeting.
Idea breakpoint debugging skills, multiple dynamic diagram package teaching package meeting.
2022-07-06 17:05:00 【Smart popcorn】
List of articles
One . How to start breakpoint debugging ?
With the development in depth , I feel more and more that efficient debugging methods are very important , But we usually type some code , Who will calm down and learn some debugging skills that seem useless ? But this is exactly the difference between novice and veteran .
Breakpoint debugging is very simple , Just click idea Bugs above , Start debugging , As shown below .
This is certainly not the focus of this article , Just start .
Two . There are so many buttons in the debugging interface ?
Let's first introduce the interface .
I marked these areas Number , Let's focus on .
1. Return to the breakpoint location
1 Button No , This one doesn't use much , If you want to go back to the breakpoint from other places , Just click , as follows GIF Shown .
2. Step over
2 Button No , Speaking human words is to carry out line by line , Will not enter the method , As shown below .
3. Stepping into
3 Button No , You can enter our customized method , If it is the method of other class libraries, it will not enter , As shown below .
4,5. Forced entry , Step out
4 Number 5 Button No , The former can enter the deep method , Including the official source code , The latter is from the corresponding method , The demonstration is as follows .
6. Fallback breakpoint
6 Button No. 1 is very special , If your code doesn't call methods elsewhere , So it's gray , Can't use , There is only a deeper way , To be able to use , In fact, that is Regret , Many times, when debugging, we accidentally press it a little faster , It's easy to miss the place you want to see , Can I restart again ? No , Use this drop frame
That's all right. , The demonstration is as follows .
You can see , Here's the next step add, But it's not finished , Press this button , Again, before calling the method , But for operations such as database insertion , In fact, there is no retreat , The fallback here is only possible because the stack information is recorded .
But be careful , If one of your methods is called , If you want to go back, there is no way .
7. The breakpoint jumps to the cursor
7 Button No It doesn't use much , Mainly to quickly jump to the line pointed by the cursor , As shown below .
8. Expression evaluation
8 Button No. is used to calculate the expression , We simulate getting collections from a database , Query the corresponding element with an expression , As shown below .
9. Recovery procedure
9 The No. button is called Resume Program
, It can jump to the specified breakpoint , We are 10 Xing He 100 Add a breakpoint to each line , You need to click this button to jump to 100 Line? ? The answer is once , The first breakpoint will be at 10 Okay, stop , Click the change button to fly directly 90 Go to the first place 100 That's ok , As shown below .
10. Stop program
10 Button No. is to stop debugging , But notice , Even if you stop debugging , The program will continue to run , How do you want him to stop at the breakpoint ? I'll talk about it later .
11. View all breakpoints
11 When button No. 1 is turned on, there is something else , The basic functions are shown in the figure below , It's mainly about setting up , View breakpoint information , Let's see , I will talk about the practical methods below .
12. Disable breakpoints
12 Button No. 1 is simple , Disable breakpoints temporarily , It is convenient for the program to continue , General coordination Resume Program
.
13. other
13 No. is not a button , It's an area , There are many variables stored in it , It's convenient for us to check .
14 Button No. 1 was actually ignored by me before , This time take it out and talk about , stay watch It can monitor the changes of variables , Some students said , You can also see the variable column in the middle , But pull it out alone , It seems more convenient , The demonstration is as follows .
3、 ... and . There are so many debugging breakpoints ?
Ordinary line breakpoint debugging is omitted here , After all, it is the simplest , Everyone will .
1. Method breakpoint
Method breakpoints are not used for ordinary methods , The best use is on the interface , When we are debugging the source code , If a breakpoint is made on the interface , Go down again , You can jump directly to the implementation method of the implementation class , We don't need to find one by one .
In the case , There's an interface DemoInterface
, It has two implementation classes , Let's take a look at the effect , The demonstration is as follows .
Be careful , Method breakpoint is a diamond symbol .
In fact, you can directly break points on interface methods , Jump directly to the corresponding implementation method , This is to slow down the demo .
2. Property breakpoint
Attribute breakpoints are set on attributes , We don't have to getter setter Break in the way , Put a breakpoint on the attribute , A small eye sign will appear , As shown below .
Right click on the eye to set .
We usually go through getter,setter Method set , So I will stay on these two methods .
to glance at GIF Show me .
3. Exception Breakpoint
The null pointer appears on the line BUG, We want to quickly locate where the null pointer appears , What should be done , The answer is , Exception Breakpoint ! The demonstration is as follows .
Be careful , Abnormal breakpoint is a sign of lightning .
You can see , We made a null pointer breakpoint in the global , Whenever a null pointer appears , It will stop there , It's so convenient !
4. Terminate breakpoint
We said earlier , Even if you stop the program , It won't let the code we run later cancel execution , Then I must cancel the execution, ok ? Of course you can , Demo such as , Right click on the method stack , There is one Force Return
, Then click Resumer Program
, You can directly terminate and return .
5. Conditional breakpoints
I want to break when a certain condition is met , And don't want to go step by step , Is there any way ? Of course. , Right click on the breakpoint , stay condition Fill in the corresponding conditions , The demonstration is as follows .
6. Flow breakpoint
When we use streams , It's hard to see what's done in the middle , But in fact idea Just help us solve , I use breakpoints to debug the following code , Show you .
In fact, you just need to find this button
List<Integer> list = new ArrayList<>(Arrays.asList(1, 3, 3, 4, 4, 4, 5, 6, 78));
List<Integer> collect = list.stream()
// First filter even numbers , Go back to the heavy , Back to the assembly
.filter(s -> s % 2 == 0)
.distinct()
.collect(Collectors.toList());
7. Multithreaded breakpoint
Show you two situations , Debugging under multithreading , Debug under scheduled tasks .
This demonstration is relatively simple , Maybe some students don't think so , You can try , If you use the default All To debug multithreaded programs , Maybe a thread ran away , No stay , This method can capture all running threads .
There is a benefit of debugging scheduled tasks like this , Even if we are in the process of debugging, the next task is time , And will not execute , Prevent interference caused by multiple scheduled task execution , I started the program one minute before the demonstration , every other 10 Print every second , But because the thread execution is suspended , Click the Resumer Program
, It is found that there is no further implementation , But wait 10 Execute in seconds .
8. Remote breakpoint
This is ignored , Because there is really no remote breakpoint , If you have time to add , I feel dispensable .
In fact, everyone's life is a world , Even the most ordinary person has to fight for the world he lives in .
边栏推荐
- 我走過最迷的路,是字節跳動程序員的腦回路
- The difference between URI and URL
- J'ai traversé le chemin le plus fou, le circuit cérébral d'un programmeur de saut d'octets
- MySQL date function
- @RequestMapping、@GetMapping
- ~78 radial gradient
- @RestController、@Controller
- Shell_ 02_ Text three swordsman
- ByteDance 2022 school recruitment R & D advance approval publicity meeting, students' top 10 issues
- was unable to send heartbeat
猜你喜欢
Assembly language addressing mode
The "advertising maniacs" in this group of programmers turned Tiktok advertisements into ar games
Activiti目录(五)驳回、重新发起、取消流程
原型链继承
How to configure hosts when setting up Eureka
Shell_ 05_ operator
Which is more important for programming, practice or theory [there are some things recently, I don't have time to write an article, so I'll post an article on hydrology, and I'll fill in later]
Activiti目录(三)部署流程、发起流程
Activiti directory (IV) inquiry agency / done, approved
Many papers on ByteDance have been selected into CVPR 2021, and the selected dry goods are here
随机推荐
Solr word segmentation analysis
Eight part essay that everyone likes
DOS function call
The daemon thread starts redis and modifies the configuration file
README. txt
面试集锦库
Alibaba cloud server docker installation mysql5.5
Shell_ 00_ First meeting shell
MySQL string function
Some instructions on whether to call destructor when QT window closes and application stops
Yum install XXX reports an error
~83 form introduction
~82 style of table
koa中间件
Shell_ 01_ data processing
~81 long table
Activiti directory (III) deployment process and initiation process
TypeScript基本操作
数据传送指令
js垃圾回收机制和内存泄漏