当前位置:网站首页>BUG destroyer!!Practical debugging skills are super comprehensive
BUG destroyer!!Practical debugging skills are super comprehensive
2022-07-31 04:01:00 【vpurple__】
目录
4.1一些调试的实例(Memory with stack area、Array element memory storage related knowledge
1.什么是bug?
第一次被发现的导致计算机错误的飞蛾,也是第一个计算机程序错误.
2.调试
2.1什么是调试
找bugThe process is debugging
调试(英语:Debugging / Debug),又称除错,是发现和减少计算机程序或电子仪器设备中程序 错误的一个过程.
2.2调试的基本步骤
1.发现程序错误的存在.
2.以隔离、消除等方式对错误进行定位.
3.确定错误产生的原因.
4.提出纠正错误的解决办法.
5.对程序错误予以改正,重新测试.
2.3.debug和release的介绍.
Debug 通常称为调试版本,它包含调试信息,It can be debugged step by step without any optimization,便于程序员调试程序.
Release 称为发布版本,It is often that there is no debug information,Can't debug step by step进行了各种优化,使得程序在代码大小和运行速度上都是最优的,以便用户很好地使用.
3.windows环境调试介绍
3.1调试准备
在环境中选择 debug 选项,才能使代码正常调试.
3.2学会快捷键
最常使用的几个快捷键:
F5
启动调试,经常用来直接跳到下一个断点处.
F9
创建断点和取消断点, 断点的重要作用,可以在程序的任意位置设置断点. 这样就You can make the program stop execution at will at the desired position,继而一步步执行下去.(F5+F9常常搭配使用)
条件断点
F10
逐过程,通常用来处理一个过程,A process can be一次函数调用(When you encounter a function, go directly to it,不进入函数内部),或者是一条语句.
F11
逐语句,就是每次都执行一条语句,但是这个快捷键We can make our execution logic go inside the function(这是最常用的).
CTRL + F5
开始执行不调试,直接执行.如果你想让程序直接运行起来而不调试就可以直接使用
vs2022The screenshot of the debugging shortcut key is as follows:
If you want to know more shortcut keys,Click the link to the blog post below:(16条消息) VS中常用的快捷键_MrLisky的博客-CSDN博客_vs快捷键https://blog.csdn.net/mrlisky/article/details/72622009
3.3 调试的时候查看程序当前信息
A watch window is recommended.
观察内存
函数调用堆栈
查看汇编代码
when debugging is possible,右键转到反汇编
查看寄存器信息
4.多多动手,尝试调试,才能有进步.
一定要熟练掌握调试技巧.
初学者可能80%的时间在写代码,20%的时间在调试.
但是一个程序员可能20%的时间在写 程序,但是80%的时间在调试.
我们所讲的都是一些简单的调试.
以后可能会出现很复杂调试场景:多线程程序的调试等.
多多使用快捷键,提升效率.
4.1一些调试的实例(Memory with stack area、Array element memory storage related knowledge
#include <stdio.h>
int main()
{
int i = 0;
int arr[10] = {0};
for(i=0; i<=12; i++)
{
arr[i] = 0;
printf("hehe\n");
}
return 0;
}//死循环 在vs2019下
5.常见的coding技巧:
5.1注意事项
1. 使用assert
2. 尽量使用const修饰
3. 养成良好的编码风格
4. 添加必要的注释
5. 避免编码的陷阱
5.2示范,实现函数strcpy
/***
*char *strcpy(dst, src) - copy one string over another
*
*Purpose:
* Copies the string src into the spot specified by
* dest; assumes enough room.
*
*Entry:
* char * dst - string over which "src" is to be copied
* const char * src - string to be copied over "dst"
*
*Exit:
* The address of "dst"
*
*Exceptions:
*******************************************************************************/
char * strcpy(char * dst, const char * src)
{
char * cp = dst;
assert(dst && src);
while( *cp++ = *src++ )
; /* Copy src over dst */
return( dst );
}
5.3补充const修饰指针变量
const修饰指针变量的时候:
1. const如果放在*的左边,修饰的是指针指向的内容.
const int *p;
保证指针指向的内容不能通过指针来改 变.但是指针变量本身的内容可变.
2. const如果放在*的右边,修饰的是指针变量本身.
int *const p;
保证了指针变量的内容不能修改,但是指 针指向的内容,可以通过指针改变.
6. 编程常见的错误
6.1 编译型错误
语法错误.
直接看错误提示信息(双击),解决问题.或者凭借经验就可以搞定.相对来说简单.
6.2 链接型错误
出现在链接期间.
看错误提示信息,主要在代码中找到错误信息中的标识符,然后定位问题所在.一般是标识符名不 存在或者拼写错误.
6.3 运行时错误
借助调试,逐步定位问题.最难搞.
大家好,这里是媛仔!!Welcome to Yuanzic语言进阶之路(复习中~,Hope this content can be helpful to you,也欢迎大家和我多多交流!!
边栏推荐
- Understanding and Using Unity2D Custom Scriptable Tiles (4) - Start to build a custom tile based on the Tile class (below)
- LocalDate加减操作及比较大小
- ClickHouse:设置远程连接
- 识Flutter 基本组件之showTimePicker 方法
- pom文件成橘红色未加载的解决方案
- 从滴滴罚款后数据治理思考
- Win10 CUDA CUDNN 安装配置(torch paddlepaddle)
- 顺序表的实现
- SocialFi 何以成就 Web3 去中心化社交未来
- (树) 最近公共祖先(LCA)
猜你喜欢
LocalDate addition and subtraction operations and comparison size
web容器及IIS --- 中间件渗透方法1
Zotero如何删除自动生成的标签
A brief introduction to the showDatePicker method of the basic components of Flutter
Thinking about data governance after Didi fines
Redis implements distributed locks
[C language] General method for finding the sum of the greatest common factor and the least common multiple of two integers m and n, the classical solution
Mysql 45 study notes (twenty-four) MYSQL master-slave consistency
[C language] General method of base conversion
扫雷游戏(c语言写)
随机推荐
Know the showTimePicker method of the basic components of Flutter
【论文阅读】Mastering the game of Go with deep neural networks and tree search
No qualifying bean of type 问题
顺序表的实现
C language from entry to such as soil, the data store
安全20220709
(tree) Last Common Ancestor (LCA)
【AUTOSAR-RTE】-4-Port和Interface以及Data Type
浅识Flutter 基本组件之CheckBox组件
(树) 最近公共祖先(LCA)
els block to the right
BP神经网络
【AUTOSAR-RTE】-4-Port and Interface and Data Type
qlib架构
Win10 CUDA CUDNN 安装配置(torch paddlepaddle)
安全20220715
问题7:列表的拼接
《DeepJIT: An End-To-End Deep Learning Framework for Just-In-Time Defect Prediction》论文笔记
Mysql 45 study notes (twenty-four) MYSQL master-slave consistency
Summary of Huawei Distributed Storage FusionStorage Knowledge Points [Interview]