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.
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.
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.
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.
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:
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:
You can use immediate expression evaluation to temporarily fix errors at the command window prompt. For instance, if your program calls a function that you have not yet defined, execution will halt and InstantC will point out the problem. As noted earlier, you can immediately define the function, or just execute a return statement in the command window, supplying an appropriate value if needed. InstantC will evaluate it, just as it does any other valid C statement, and let you continue execution following the function call.
Expression evaluation also allows you to test expressions to make sure they produce the result you want. For example, perhaps your program runs to completion but doesn't return the value you expect. You trace the program, watching variables to make sure that they change in the way you planned. If you find that the problem turns out to be a complicated expression or macro that does not evaluate as you expected, you can try alternative expressions until you get the correct result. Any error in the expression causes a new debug window to appear, along with a detailed error message.
Immediate expression evaluation saves time by letting you try code in the context of your program without having to write, compile, link, and debug separate test programs. This eases experimentation, speeds debugging, and lets you test code thoroughly as you go.
You can bring the function in the debug window into the editor with a single keystroke. If a run-time error halted execution, the caret will be positioned at the line containing the error. You can correct the code, compile it, and return to the debug window to restart execution or perform other debugging tasks. If you stopped execution with a breakpoint, trace, or monitor, you can edit the code, compile it, and continue executing the original version of the function, still displayed in the debug window, to find other bugs.
InstantC's code and data analysis tools, such as the browser, the cross-referencer, and the memory dump utility, are also available. The browser and cross-referencer, discussed in detail in the next section, help you find all references to a source element, or see where it fits in your overall program structure. InstantC's memory dump, shown in action below, lets you examine any region of memory or multiple regions at once -- displaying the contents in a variety of formats and number systems.
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]