12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

NOTE<br />

Us<strong>in</strong>g the Debugger<br />

builds. Remember that when you change optimization sett<strong>in</strong>gs, you<br />

need to do a Build All for all modules to be rebuilt us<strong>in</strong>g the new<br />

sett<strong>in</strong>gs.<br />

The IDE debugger has two primary stepp<strong>in</strong>g commands that you can use to aid <strong>in</strong> your<br />

debugg<strong>in</strong>g operations: Step Over and Trace Into. Step Over means to execute the next l<strong>in</strong>e<br />

<strong>in</strong> the source code and pause on the l<strong>in</strong>e immediately follow<strong>in</strong>g. Step Over is sort of a<br />

misnomer. The name would seem to <strong>in</strong>dicate that you can step over a source l<strong>in</strong>e and the l<strong>in</strong>e<br />

would not be executed. That is not the case, however. Step Over means that the current l<strong>in</strong>e<br />

will be executed and any functions that that source l<strong>in</strong>e calls will be run at full speed. For<br />

<strong>in</strong>stance, let’s say you have set a breakpo<strong>in</strong>t at a l<strong>in</strong>e that calls another function <strong>in</strong> your<br />

program. When you tell the debugger to step over the function, the debugger executes the<br />

function and stops on the next l<strong>in</strong>e. (Contrast this with how Trace Into works, which you’ll<br />

learn about <strong>in</strong> a m<strong>in</strong>ute, and it will make more sense.) To use Step Over to step through your<br />

program, you can either press F8 or choose Run | Step Over from the ma<strong>in</strong> menu.<br />

As you step through various source code units <strong>in</strong> your program, the<br />

Code Editor automatically loads and displays the needed source units if<br />

they are not already open.<br />

The Trace Into command allows you to trace <strong>in</strong>to any functions that are encountered as you<br />

step through your code. Rather than execut<strong>in</strong>g the function and return<strong>in</strong>g to the next l<strong>in</strong>e<br />

as Step Over does, Trace Into will place the execution po<strong>in</strong>t on the first source code l<strong>in</strong>e <strong>in</strong><br />

the function be<strong>in</strong>g called. You can then step through that function l<strong>in</strong>e by l<strong>in</strong>e us<strong>in</strong>g Step<br />

Over or Trace Into as necessary. The keyboard shortcut for Trace Into is F7.<br />

After you have <strong>in</strong>spected variables and done whatever debugg<strong>in</strong>g you need to do, you can<br />

aga<strong>in</strong> run the program at full speed by click<strong>in</strong>g the Run button. The program will then<br />

function as normal until the next breakpo<strong>in</strong>t is encountered.<br />

TIP<br />

If you have enabled the L<strong>in</strong>k Debug Version of VCL L<strong>in</strong>ker option,<br />

when you encounter a VCL method Trace Into will take you <strong>in</strong>to the<br />

VCL source code for that method. Once <strong>in</strong> the VCL source, you can<br />

<strong>in</strong>spect whatever variables you need to see. If you turn on this option,<br />

you must do a Build All for it to take effect. As I said earlier, stepp<strong>in</strong>g<br />

<strong>in</strong>to the VCL source is of doubtful benefit to most programmers.<br />

417<br />

11

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

Saved successfully!

Ooh no, something went wrong!