当前位置:网站首页>Introduction to program debugging and its use
Introduction to program debugging and its use
2022-08-10 15:21:00 【Seven, seven.】
Article table of contents
Debug
First, the concept of program debugging
Program debugging is the process of testing
, correcting syntax errors and logic errors by hand or compiling the program before putting it into actual operation.
Second, program debugging steps
1. Find the existence of program errors.
2. Locate the found error
3. Find out the cause of the error
4. Correct the error
5. Re-test the corrected program
Third, debugging in Windows environment
We use VS to debug in the Windows environment, and gdb in the linux environment.Debugging on VS is divided into two versions: Debug version and release version.
Debug version contains program debugging information without optimization.
The release version has carried out various optimizations to the program, so that the size and speed of the program code have been improved.Mainly for user use.
You can compare the running size of the two versions, as shown in the figure:
Obviously debug is much bigger than release.Normal debugging can only be performed under the debug version.
Fourth, debugging shortcuts
F5: Start debugging, often used to jump directly to the next breakpoint.
F9: The important role of creating breakpoints and canceling breakpoints. Breakpoints can be set anywhere in the program.In this way, the program can be stopped at the desired position at will, and then executed step by step.
F10: by procedure, used to process a procedure can be a function call, or a statement.
F11: statement by statement, execute a statement each time, this shortcut key can make our execution logic enter the function.
5. What debugging can do
1. View the value of the temporary variable
Enter debugging, initialize the a array to 0 in the code as shown in the figure, and enter a in the monitor, and the values from 0 to 9 will be initialized to 0 as shown in the figure:
2. View memory information
Enter a in the memory to display the addresses of these 10 numbers:
Of course, you can also see &a in the monitor, for example, enter &a[1], &a[9].As shown:
3. View the call stack
From the picture, we can see that the program only calls one main function.
4. View assembly information
5. View register information
6. Common compilation errors
(1), compilation error
Look directly at the error message in the box below, or solve it with your own experience
(2), link error
Look at the error message and find the identifier in the error message in the code. Generally, the identifier name does not exist or is misspelled. For example, main is written as mian or a non-existent function name is written.
(3), runtime error
This is relatively hard to find and requires debugging to gradually locate the error.
边栏推荐
- Zhaoqi Technology Innovation High-level Talent Entrepreneurship Competition Platform
- epoll学习:思考一种高性能的服务器处理框架
- 无线网络、HTTP缓存、IPv6
- Parallels 将扩展桌面平台产品,以进一步改善在 Mac 上运行 Windows 的用户体验和工作效率
- Basic use of Go Context
- 学习MySQL 临时表
- 从全球价值链视角看,京东云数智供应链对未来经济有何影响?
- pm2 static file service
- JS entry to proficient full version
- Redis -- Nosql
猜你喜欢
随机推荐
基于ArcGIS水文分析、HEC-RAS模拟技术在洪水危险性及风险评估
NFT数字藏品——数字藏品发行平台开发
【语义分割】DeepLab系列
SWIG教程《二》
软件测试用例篇
TCP为什么是三次握手和四次挥手?
Summary of tensorflow installation stepping on the pit
2022-08-10日报: Swin Transformer作者曹越加入智源,开展视觉基础模型研究
Mysql statement analysis, storage engine, index optimization, etc.
Alibaba的秒杀系统—千亿级并发设计手册上线了
scala 基础篇
Appium进行APP自动化测试
PyTorch 多机多卡训练:DDP 实战与技巧
How to code like a pro in 2022 and avoid If-Else
SWIG tutorial "two"
E. Cross Swapping(并查集变形/好题)
SWIG tutorial "four" - package of go language
面试面到了一个腾讯30k出来的,有见识到何为精通MySQL调优
程序调试介绍及其使用
Basic learning of XML