6. Integrated Debugging Environment

The InstantC debugger is actually not one component but many. Tightly integrated within the overall InstantC environment, the components work together to give you a clear, complete view of problem code. The run-time error checking and diagnosis described above is one of the primary ways that InstantC helps speed the debugging process. But InstantC also provides many other debugging capabilities, some familiar and some that may be new to you, some automatically invoked and others accessible at your command.

Multiple Debugging Windows

The debug window appears automatically whenever program execution is suspended because of a run-time error, or because you used a debugging feature such as a breakpoint to halt your program. The window displays the code for the function that was executing when the program stopped. Below, the debug window appears at the top of the InstantC frame window, with the function's name in the title bar. Note the detailed error message in the status bar, courtesy of the run-time checker.

[image]

A locals window pops up below the debug window to show you the values of all local variables, as shown. Note the expanded display style that shows the members of compound data elements indented under the top-level name and type. This expansion is under your control. You can expand any compound data element as far as necessary to show the finest levels of detail, or collapse the display to see only the top-most level. You can also display or remove the locals window at will.

InstantC also provides a watch window, shown above, that opens below the locals window when you set a watch. (You can set a watch on any expression that represents an lvalue.) The watch window displays the values of watched expressions, whose values are updated whenever InstantC pauses your program's execution. It uses the same expansion technique as the locals window for displaying compound data elements and can be displayed or removed at will.

You can resize the debug, locals, and watch windows to see as much (or as little) of their content as you need. They also resize themselves automatically to accomodate their data without wasting screen space.

Fine-Grained Execution Control

InstantC gives you many ways to control your program's execution. You can set unconditional breakpoints, so that execution will halt when a specified line is reached. You can set conditional breakpoints to stop execution only when a specified condition is met, using special InstantC breakpoint functions and any condition that can be expressed in C. (Other debuggers, with their limited coverage of the C language, don't allow you to use enumerated types or function calls when you describe breakpoint conditions.)

InstantC also lets you trace functions. When you set a trace, InstantC sets two breakpoints, one at the beginning of the function and one at its end. When you run your program, execution will halt as soon as the function is entered. You can then step through as much of the function as you wish, checking values or performing other tasks. If you resume execution while still in the function, InstantC will run your program until it reaches the end of the function and then stop, letting you check the values of variables before the function returns.

You can monitor data, so that execution will halt when the value of a data element changes. Once execution is suspended, you can use a wide variety of commands for stepping through code. When you're ready, you can continue execution from the point where you suspended it. Depending on the nature of the problem, you may also be able to resume execution after a run-time error stops your program. For example, if execution halts because InstantC encounters an undefined function, you can immediately define the function -- or simply execute an appropriate return statement at the prompt -- and then continue running your program.

InstantC also lets you control execution through the use of wrappers, special functions you create to help you debug code and fine-tune program performance. A wrapper intercepts calls to a designated function in your program, performs any sort of action you want (such as testing parameters for validity), and then calls the wrapped function with the original call's parameters. Without InstantC, using a wrapper would mean changing every call to a function to call the wrapper instead, and then recompiling. InstantC lets you direct calls to the wrapper, or to the wrapped function, with a single command and no recompilation.

Flexible Code and Data Viewing

InstantC helps you examine your program code and data in as many ways as possible. For example, we've already seen that when your program's execution is suspended, you automatically see the function that was executing when the interruption occurred, as well as the values of the variables local to that function. Immediate expression evaluation and the built-in editor are other important data and code viewing tools. As noted above, you can also watch data and expressions, observing value changes as you step through code.

Here are some other important ways InstantC helps you view code and data:

Strong Integration with Other Components

When you're debugging with program execution suspended, you still have access to the rest of InstantC's functionality. Because InstantC is always aware of the current state of your executing program and its source code, you can easily use its other components to help you diagnose and correct errors:

The memory dump utility's flexible design eases use and encourages thorough examination. Exploration of surrounding memory areas is as easy as enlarging a dump window in the direction of the data you want to see, or scrolling up and down to browse through memory as far as you need. It's also simple to modify the format of an existing dump window, so you can examine the same memory in a different way.


[Previous] * [Tour Index] * [Next]

[Back to the InstantC Home Page]


[Home] * [Tenberry] * [News] * [InstantC] * [DOS/4G] * [DOS/16M] * [Rational Systems]
Last modified 97/04/18, <webmaster@tenberry.com>