当前位置:网站首页>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
边栏推荐
- Torch learning notes (4) -- torch's dynamic calculation diagram
- 编程中常见的 Foo 是什么意思?
- [combinatorics] generating function (example of using generating function to solve the number of solutions of indefinite equation)
- Golang string (string) and byte array ([]byte) are converted to each other
- SSH 远程执行命令简介
- How to analyze the rising and falling rules of London gold trend chart
- 虚拟机和开发板互Ping问题
- SDNUOJ1015
- [combinatorics] exponential generating function (concept of exponential generating function | permutation number exponential generating function = combinatorial number ordinary generating function | e
- Boost. Asio Library
猜你喜欢
Bidding procurement scheme management of Oracle project management system
Computer graduation design PHP campus address book telephone number inquiry system
On Data Mining
2022-2028 global scar care product industry research and trend analysis report
[Yu Yue education] theoretical mechanics reference materials of Shanghai Jiaotong University
知其然,而知其所以然,JS 对象创建与继承【汇总梳理】
Lesson 13 of the Blue Bridge Cup -- tree array and line segment tree [exercise]
Nodejs (01) - introductory tutorial
Have you learned the correct expression posture of programmers on Valentine's day?
Administrative division code acquisition
随机推荐
Torch learning notes (1) -- 19 common ways to create tensor
[combinatorics] generating function (positive integer splitting | repeated ordered splitting | non repeated ordered splitting | proof of the number of repeated ordered splitting schemes)
[combinatorics] exponential generating function (example of exponential generating function solving multiple set arrangement)
Xception for deeplab v3+ (including super detailed code comments and original drawing of the paper)
Chisel tutorial - 06 Phased summary: implement an FIR filter (chisel implements 4-bit FIR filter and parameterized FIR filter)
Should I be laid off at the age of 40? IBM is suspected of age discrimination, calling its old employees "dinosaurs" and planning to dismiss, but the employees can't refute it
Sensor 调试流程
SDNUOJ1015
A. Berland Poker & 1000 [simple mathematical thinking]
Win 11 major updates, new features love love.
How about the Moco model?
Grammaire anglaise Nom - Classification
圖像24比特深度轉8比特深度
Count the number of pixel values in the image
Have you learned the correct expression posture of programmers on Valentine's day?
Read the paper glodyne global topology preserving dynamic network embedding
G1 garbage collector of garbage collector
Mature port AI ceaspectus leads the world in the application of AI in terminals, CIMC Feitong advanced products go global, smart terminals, intelligent ports, intelligent terminals
189. Rotation array
[combinatorics] generating function (property summary | important generating function)*