当前位置:网站首页>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 17:20:00 【Yile】
* 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 isDefinition 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
边栏推荐
- Talk about several methods of interface optimization
- [2. Basics of Delphi grammar] 2 Object Pascal data type
- Leetcode13. Roman numeral to integer (three solutions)
- [RT thread] NXP rt10xx device driver framework -- Audio construction and use
- 设计电商秒杀
- How to train mask r-cnn model with your own data
- How SVN views modified file records
- C语言按行修改文件
- 跨境电商:外贸企业做海外社媒营销的优势
- When absolutely positioned, the element is horizontally and vertically centered
猜你喜欢
Thread pool: the most common and error prone component of business code
29: Chapter 3: develop Passport Service: 12: develop [obtain user account information, interface]; (use VO class to package the found data to meet the requirements of the interface for the returned da
国内如何购买Google Colab会员
Play with fancy special effects. This AE super kit is for you
PS screen printing brush 131, many illustrators have followed suit
鸿蒙第四次培训
Redis:关于列表List类型数据的操作命令
Free data | new library online | cnopendata complete data of China's insurance intermediary outlets
Analysis of variance summary
线程池:业务代码最常用也最容易犯错的组件
随机推荐
免费数据 | 新库上线 | CnOpenData中国保险中介机构网点全集数据
[RT thread] construction and use of --hwtimer of NXP rt10xx device driver framework
大变局!全国房价,跌破万元大关
Solution to long waiting time of SSH connection to remote host
聊聊接口优化的几个方法
一位普通程序员一天工作清单
Simple configuration of postfix server
How do large consumer enterprises make digital transformation?
Vs code plug-in korofileheader
STM32H7 HAL库SPI DMA发送一直处于busy的解决办法
Great changes! National housing prices fell below the 10000 yuan mark
问题随记 —— 在 edge 上看视频会绿屏
kubernetes资源对象介绍及常用命令(三)
在iptables防火墙下开启vsftpd的端口
[error reporting] omp: error 15: initializing libiomp5md dll, but found libiomp5md. dll already initialized.
C language string inversion
vs2013已阻止安装程序,需安装IE10
Assignment examination questions of advanced English (III) for the course examination of Fujian Normal University in February 2022
When absolutely positioned, the element is horizontally and vertically centered
C language string practice