当前位置:网站首页>How to read the source code [debug and observe the source code]
How to read the source code [debug and observe the source code]
2022-07-03 18:37:00 【1 Yile】
Welcome to Lele's blog Garden
* Compiler knowledge required for reading source code ( Compiler is eclipse As an example )
Commissioning preparations ( step :Window -> Show View -》...):
□ Open debug breakpoint Breakpoint:

□ Turn on variable monitoring

It depends on the internal details of a method , Press f5, Get into

Jump to a certain position quickly 【 Make a breakpoint at the target location 】, Then press f8

Details of the observation method ( Execute the process ), Step by step , Press f6

Remove all breakpoints ( The compiler is eclipse)

□ Pay attention to whether the execution position of the start tag is correct

f5 Enter by debugging 【
If the entry is irrelevant , Press f7 return , Press again f5 Enter once】 give an example :
User user = mapper.get(1L); // Make a breakpoint here to enter , Will enter first Long class , Because the order of execution is (1L) Execute first , So after entering it first , Re execution get Method
Press ctr and As debugged f5 The difference between : □ ctr: Is to enter “ The selected code ( class 、 Interface 、 Method )” The location of the definition of 【 The emphasis is
Definition of code】 □ f5: It is to execute the current code in the order of execution , Get into 、 Execute its internal 【 The emphasis isExecution of code】Press ctr With the mouse , You can know the next step of the code ( Press ctr Details to pay attention to :ctr The default entry is the definition of the selected code , Not an implementation process , After entering, I found that I didn't see any helpful code , return Return press and hold ctr, Selective implementation ( If there are multiple implementations ,
I don't know which one to choose , It can be debugged f5 Get into), Press the mouse again to enter .

Restart debugging details : (1) Close the last debugging (2) Click on Before commissioning , Keep the... In front of the breakpoint at the start position √, Before other breakpoints √ Remove first ( Start debugging before √ Come back )

After entering a method, learn the details of the method , Want to go back and then proceed , Press f7 return 【
Back to press f7】 Generally, after in-depth understanding of a module , You can press return , return ... Then move on to the next module
* The idea of reading source code
1、 Focus on understanding the execution logic ( The execution process can be carried out as control Enter a method or class , Understand the next step after , The cursor returns to the current position 【 Shortcut keys are alt+←】)
2、 Look at the source code process to clarify ideas , Abnormally related (error、exception、throw), The details that make the code more robust can be ignored ; Stack related stack, The bottom layer can be ignored
3、 In the code , See the selection Branch , You can observe the value of the variable ( Judge the condition ) Know which branch to enter
4、 In the code , See incomprehensible code , You can go down first , Then understand by observing the value of the variable 【 It can also be understood in combination with the official website 】
5、 Read stream 、 load resources 、 Binding namespace 、 Parameter conversion is not the point
6、 Constructing constructors is not the point , The point is to see The construction process of the constructor
7、 Constructing parsers is not the point , The point is to see The parsing process of the parser
8、 When you create a subclass, you should pay attention to : What kind of subclasses ? When a subclass has an encapsulated parent or sibling , Note what type of parent or sibling class is encapsulated ?
* How to focus on reading source code ( With mybatis The source code of )
■ 1、 The process of reading the source code , Which one should I read , Which is the key point of reading ?
Read the source code to build the source code of the session factory object , I learned that : Created a SqlSessoinFactory The session factory object is through the default SqlSessoinFactory Created , When creating, you need to pass in a configuration object 【 That is, when creating the session factory object, a configuration object is also created 】, thus , Study the creation process of configuration objects . 
Read the source code to build the source code of the session factory object , I learned that : Create a sqlSession The session object is through the default sqlSession, You need to pass in three parameters when creating , The key is to observe which ?
□ configuration Configuration object ( I learned about it when I read the source code of session factory object construction , Is not the point ) □ executor actuator ( a key , Because in return The session object was previously built executor actuator ) □ autoCommit ( Submit or not , Boolean value , Is not the point ) 
Combine to understand logic , also return The hint of , Know that the key point of reading is list The process of 
* Words to master when reading the source code
map mapping mapper mapper factory factory build structure config To configure parse analysis parser Parser parsed Has been resolved parseConfiguration Parsing configuration interceptor Interceptor plugin “ install [ enhance ]”、 plug-in unit proxy agent prepared precompiled callable Stored statment Statement object preparedStatement Precompiled statement object callableStatement Stored statement object cursor cursor instantiate Instantiation instantiateStatement Instantiate the statement object handler processor typeHandler Type processor row That's ok
● Reprint please indicate the source
边栏推荐
- Opencv learning notes (continuously updated)
- Software development freelancer's Road
- Valentine's day, send you a little red flower~
- The number of incremental paths in the grid graph [dfs reverse path + memory dfs]
- [combinatorics] generating function (positive integer splitting | unordered non repeated splitting example)
- Install apache+php+mysql+phpmyadmin xampp and its error resolution
- [enumeration] annoying frogs always step on my rice fields: (who is the most hateful? (POJ hundred practice 2812)
- Multifunctional web file manager filestash
- CTO and programmer were both sentenced for losing control of the crawler
- The second largest gay dating website in the world was exposed, and the status of programmers in 2022
猜你喜欢

Administrative division code acquisition
![The number of incremental paths in the grid graph [dfs reverse path + memory dfs]](/img/57/ff494db248171253996dd6c9110715.png)
The number of incremental paths in the grid graph [dfs reverse path + memory dfs]
![[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*](/img/e8/67961bf8a589869bde2a0aa3e09605.jpg)
[combinatorics] dislocation problem (recursive formula | general term formula | derivation process)*

2022-2028 global marking ink industry research and trend analysis report

Valentine's day, send you a little red flower~

Nodejs (01) - introductory tutorial
![[Godot] add menu button](/img/44/ef1e6ac25bcbc8cc3ecc00c52f8ee2.jpg)
[Godot] add menu button
![[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)](/img/e6/9880e708aed42dc82c94aea002020c.jpg)
[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)

On Data Mining
![Bloom filter [proposed by bloom in 1970; redis cache penetration solution]](/img/f9/27a75454b464d59b9b3465d25fe070.jpg)
Bloom filter [proposed by bloom in 1970; redis cache penetration solution]
随机推荐
2022-2028 global sepsis treatment drug industry research and trend analysis report
Multifunctional web file manager filestash
What is the function of registering DLLs- What does registering a DLL do?
SQL injection -day16
[combinatorics] generating function (commutative property | derivative property | integral property)
Graduation summary
204. Count prime
Computer graduation design PHP makeup sales Beauty shopping mall
SDNUOJ1015
Redis on local access server
The vscode code is automatically modified to a compliance code when it is formatted and saved
Analysis of the reasons why enterprises build their own software development teams to use software manpower outsourcing services at the same time
[combinatorics] generating function (generating function application scenario | using generating function to solve recursive equation)
[Godot] add menu button
How to analyze the rising and falling rules of London gold trend chart
Opencv learning notes (continuously updated)
Unity2018 to wechat games without pictures
VLAN experiment
圖像24比特深度轉8比特深度
Computer graduation design PHP sports goods online sales system website