当前位置:网站首页>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 .
边栏推荐
- ~83 form introduction
- 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]
- ~Introduction to form 80
- Koa Middleware
- Ruoyi-Cloud 踩坑的BUG
- README. txt
- Eureka single machine construction
- Assembly language addressing mode
- Activiti directory (III) deployment process and initiation process
- How to generate six digit verification code
猜你喜欢
字节跳动海外技术团队再夺冠:高清视频编码已获17项第一
~Introduction to form 80
~69 other ways to use icon fonts
Fdog series (4): use the QT framework to imitate QQ to realize the login interface, interface chapter.
Activiti directory (V) reject, restart and cancel process
Activit零零碎碎要人命的坑
The "advertising maniacs" in this group of programmers turned Tiktok advertisements into ar games
Yao BanZhi and his team came together, and the competition experts gathered together. What fairy programming competition is this?
Some instructions on whether to call destructor when QT window closes and application stops
Assembly language segment definition
随机推荐
Fdog series (I): think about it. It's better to write a chat software. Then start with the imitation QQ registration page.
Activiti目录(四)查询代办/已办、审核
How to generate six digit verification code
8086 分段技术
唯有学C不负众望 TOP1环境配置
QT system learning series: 1.2 style sheet sub control lookup
Redis standalone startup
Only learning C can live up to expectations top5 S1E8 | S1E9: characters and strings & arithmetic operators
Eureka single machine construction
吴军三部曲见识(七) 商业的本质
~77 linear gradient
ByteDance open source Gan model compression framework, saving up to 97.8% of computing power - iccv 2021
~70 row high
Error occurred during initialization of VM Could not reserve enough space for object heap
Alibaba cloud server builds SVN version Library
Activiti directory (IV) inquiry agency / done, approved
服务器端渲染(SSR)和客户端渲染(CSR)的区别
Shell_ 01_ data processing
~69 other ways to use icon fonts
Activiti directory (III) deployment process and initiation process