当前位置:网站首页>Code debugging core step memory
Code debugging core step memory
2022-07-07 02:41:00 【Handsome drop point C】
Location method :
- gdb:
- adopt gdb For memory break points (watch) , See who illegally accessed the memory area . Then gradually narrow the scope . Until the corresponding function segment is found , such as :
- For example, discovery 0x800 The address is trampled .
- First, judge whether the address is legal , That is to say 0x800 Whether it should exist , If it should not exist , Then you can watch This address , You can also keep the code running , During this period, the address is continuously printed , See which code has been modified .
- For example, discovery 0x800 The address is trampled .
- limited
- The problem occurs in the startup phase , There is no time to set a breakpoint , Bad positioning ,
- Some systems do not support gdb
- Trampled address is not fixed
- adopt gdb For memory break points (watch) , See who illegally accessed the memory area . Then gradually narrow the scope . Until the corresponding function segment is found , such as :
- Problems like memory leaks , Predetermination , Post positioning , Through memory proc Information (meminfo/media-mem) Judgment is a specific module , Memory segment . It can also be used. MMU(linux You can use mrotect) Protect specific areas
- limited
- MMU The smallest unit of protection is a memory page , The area that may be trampled is small , No use mmu To protect
- limited
- Subtraction reduces the range , Clipping module , Modify the application , Find the smallest scene
- Add print , Print out the abnormal and suspicious address ; It's fine too dump Output the data of the trampled address , View data characteristics , Analyze where it comes from according to data characteristics .
- valgrind+effence+ksan Tools such as
Common questions
- Type conversion error
- For example, small to large , Including common char and int, And custom structures
- Including formal parameters
- Use the address that has been released
- such as malloc Or use without applying for control
- The requested memory is too small , Not enough use , Similar and cross-border
How to avoid
- Function nesting should not be too deep
- Code should be symmetrical ,malloc The corresponding position must be released
- Pay attention to the size of the array
边栏推荐
猜你喜欢
随机推荐
QPushButton-》函数精解
Douban average 9 x. Five God books in the distributed field!
NuScenes数据集关于Radar数据的统计
Linear list --- circular linked list
AWS learning notes (I)
Increase 900w+ playback in 1 month! Summarize 2 new trends of top flow qiafan in station B
The so-called consumer Internet only matches and connects industry information, and does not change the industry itself
Code line breaking problem of untiy text box
[C # notes] use file stream to copy files
Common fitting models and application methods of PCL
MySQL
PCL 常用拟合模型及使用方法
Electrical engineering and automation
[node learning notes] the chokidar module realizes file monitoring
Introduction to the internal structure of the data directory of PostgreSQL
实施MES管理系统时,哪些管理点是需要注意的
C#/VB.NET 删除Word文檔中的水印
3 -- Xintang nuc980 kernel supports JFFS2, JFFS2 file system production, kernel mount JFFS2, uboot network port settings, and uboot supports TFTP
unity中跟随鼠标浮动的面板,并可以自适应文字内容的大小
wzoi 1~200