Debugging and Efficiency |
C C C |
|
16C |
|
C C C |
|
C C |
the file’s buffer after each write. Otherwise, you could lose the most important part of the program’s output if the program fails without closing the file or flushing the buffer.
When programming under Windows, you could call OutputDebugString() rather than fprintf(). The OutputDebugString() Windows function writes a string to the debugging terminal (or whatever destination you choose if you use the DBWIN program), without halting the program or destroying the contents of the Window’s screen.
Debuggers
Every compiler comes with a debugger. Regardless of the environment (DOS, Windows, OS/2, or UNIX), the concept behind the use of a debugger is the same: to allow access to various commands while the program runs so that you can monitor its execution.
Typical services offered by most debuggers follow:
•Execution in an environment similar to the typical operating environment. This involves using as little memory as possible (a requirement that was difficult with DOS on a PC, but is easier with the rapid acceptance of protected-mode operating systems such as Windows and OS/2) and not interfering with the output device (the screen). To avoid interfering with the screen, the debugger generally uses a serial terminal, a second monitor (often a monochrome adapter, or MDA), or two workstations (with network-based debugging).
•Memory examination. This includes simple memory dumps, examination of external variables (by name), and examination of local variables.
•Memory modification. This generally is limited to changing variables, both global and local.
•Program breakpoints. At a program breakpoint (a specified point of interruption), the debugger is given control before the line or instruction is executed. At a breakpoint, you might examine variables, registers, or memory.
•Memory breakpoints. These are similar to program breakpoints, but the memory specified need not be an instruction. For example, the breakpoint