That gets us to debugging.
这就需要我们去调试了。
This is the place where people typically slip up in debugging. They don't think in advance what they expect the result to be.
实验就推翻了你的假设了,人们在做调试的时候往往忽略了这一点,他们做实验之前并没有想想。
But just so you've been teased with them, "-ggdb" is a flag that's going to enable what are going to be called "debugging symbols."
但是你们刚才被他们忽悠了,“-ggdb“是用来使能“调试标志“功能,的一个标记“
PROFESSOR: I want to take a few minutes at the start of today's lecture to wrap up a few more things about debugging.
教授:我想在今天讲座的开头,再花几分钟讲完调试的剩余内容,然后我们再讲主要内容。
You find some way of systematically going through the list. Yet, I often see people, when they're debugging, proceeding at what, to me, looks almost like a random fashion of looking for the bug.
是不是目标元素,我们有一种系统化的,遍历数组的方法,然后我经常看到,有些人调试的时候。
I emphasize this because it often leads to a different debugging strategy.
因为这会导致不同的调试策略,所以我要强调这一点。
So one of the things I want you to notice here is that testing and debugging are not the same thing. When we test, we compare an input output pair to a specification.
这里我想大家注意的一件事,就是测试和调试是不同的两件事情,我们测试的时候,我们把输入输出,跟程序的规格说明书对比下。
Does it give you the answer that you expected it to give? Often, in practical problems, you'll spend just as much time doing performance debugging. Why is it slow?
它返回了期待中的结果了么?通常,在实际的问题中你会花,同样多的时间在性能调试上,它为什么运行这么慢?
There's a lecture I've given several times at hospitals, to doctors, on doing diagnosis of complex multi illnesses. And I go through it and almost the same kind of stuff I'm going to talk to you about, about debugging.
一个实验室内的实验,为什么实验不对呢?,我也在医院给医生关于,诊断复杂的多种疾病做过很多讲座,我想了想,那和我给你们讲的,关于调试其实都是一回事。
So I'm going to have an assignment of y, I'm going to have an assignment of iters left, I've got a comment that I had borrowed in order to do some debugging, and then what do I want it to do?
因此我需要对y进行赋值,需要对iters,left进行赋值,还有一个我用的别人的,用来调试的一些注释,那么接下来我希望程序怎么运行呢?
Typically, even though they don't breed, there are many bugs. And keep in mind that the bug goal of debugging is not to eliminate one bug.
这是件好事,其实即使bugs不会繁殖,也会有很多,并且请记住调试的目的,并不是去消除一个。
How to fix it. When I think about debugging, I think about it in terms of what you learned in high school as the scientific method.
怎么来修复bug,当我谈论到调试的时候,我认为你们应该依照在高中,在科学方法学中学过的。
应用推荐