15.04.2018 Views

programming-for-dummies

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

98<br />

Fixing a Program with a Debugger<br />

your program that caused that problem. Then you can fix the problem, as<br />

shown in Figure 4-5.<br />

Sometimes when programmers find one error and fix it, their fix accidentally<br />

creates another error in the program.<br />

Here are the two types of debuggers:<br />

✦ Source-level: Lets you examine your source code line by line. So if you<br />

write a program in BASIC, a source-level debugger shows you each line<br />

of your entire BASIC program.<br />

✦ Machine-language: Lets you examine the machine language code, line<br />

by line, that your compiler created from your source code. Programmers<br />

often use machine-language debuggers to examine programs when they<br />

don’t have access to the source code, such as a computer virus or a<br />

rival’s program.<br />

Stepping line by line through a small program may be feasible, but in a large<br />

program that consists of a million lines of code, stepping line by line would<br />

take far too long. So to make stepping easier, most debuggers include breakpoints<br />

and stepping over/stepping out commands.<br />

Figure 4-5:<br />

Stepping<br />

through a<br />

program,<br />

line by line,<br />

can help<br />

you find<br />

errors or<br />

bugs in your<br />

program.<br />

Breakpoints<br />

A breakpoint lets you skip over the parts of your program that you already<br />

know work. So if you have a program that’s 10,000 lines long and you know<br />

the problem is somewhere in the last 1,000 lines of code, there’s no point<br />

stepping through those first 9,000 lines of code.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!