Once you are comfortable displaying and changing variables, stepping through the program, and using dynamic replay, you might want to experiment with the advanced techniques explained below.
You can debug protected-mode and bound programs under CodeView. See the Debug Multiple Processes and Debug Multiple Threads sections of CodeView online help for information about executing threads and multiple processes.
If your program retrieves command-line arguments, you can specify them with the Set Runtime Arguments command from the Run menu. Type the arguments in the Command Line field before you begin execution. (Arguments entered after execution begins cause an automatic restart.)
You can open two Source windows at the same time. The windows can display two different sections of the same program, or one window can show the calling program and the other a procedure file. You can move freely between the windows, executing lines of code as you like.
Any procedure in your program (whether user-written or from a library) can be called from the Command window or the Watch window. In the Command window, use the Display Expression command as follows:
?procname (arglist)
The procedure procname is evaluated with the arglist arguments and the returned value is displayed in the Command window. (Note that CodeView cannot evaluate a function that returns an aggregate type.) In the Watch window, simply enter the procedure call. If the procedure does not return a value, the value displayed is the value of the AX register upon return from the procedure.
You can evaluate any procedure, not just those called by your program. All object code specified to the linker is linked into the program. Any public functions in this code can be evaluated from the Command window.
You can use this feature to call functions from within CodeView that you would not normally include in the final version of your program. For example, you could include the OS/2 API functions that control semaphores, then execute them from the Command window to manipulate the run-time environment at any point in the debugging process. (Remember that altering the environment during program execution may have unexpected side effects.)
Breakpoints can slow execution. You can increase CodeView's speed with the /R command-line option if you have an 80386/486-based computer and are running CodeView under DOS. This option enables the four debug registers, which support breakpoint-checking in hardware rather than in software. (The CodeView options are described in Section 15.7.)
You can print all or part of the contents of any window with the Print command from the File menu. In the Print dialog box, a check box lets you print selected text from the window, the material currently displayed in the window, or the complete contents of the window. Select text by dragging the mouse across it, or by holding down the SHIFT key and pressing the direction keys (LEFT, RIGHT, UP, DOWN).
By default, print output is to the file CODEVIEW.LST in the current directory. You can choose whether the new material is appended to an existing file or overwrites it, using the Append/Overwrite check box. If you want print output to go to a different file, type its name in the To File Name field. If you want the output to go to a printer, enter the appropriate device name such as LPT1 or COM2.
The Command window accepts DOS-like commands that redirect input and output. These commands can also be included on the command line that invokes CodeView. Whatever items follow the /C option on the command line are treated as CodeView commands to be immediately executed at start-up.
CV /c "<infile; t>outfile" myprog
In the example above, input is redirected from infile, which can contain start-up commands for CodeView. When CodeView exhausts all commands in the input file, focus automatically shifts to the Command window. Output is sent to outfile and echoed to the Command window. The t must precede the > command for output to be sent to the Command window.
Redirection is a useful way to automate CodeView start-up. It also lets you keep a viewable record of command-line input and output, a feature not available with dynamic replay. No record is kept of mouse operations. Some applications (particularly interactive ones) may need modification to allow for redirection of input to the application itself.
If you are running DOS and your computer uses expanded or extended memory, you can increase CodeView's execution speed by selecting the /X or /E option. CodeView moves as much as it can of itself and the symbolic CodeView information to higher memory (above the first megabyte).
The /X option uses extended memory and gives the greatest speed increase. This option requires the HIMEM.SYS driver, which is included on your distribution disks. Add DEVICE = HIMEM.SYS to your CONFIG.SYS file to load HIMEM.SYS at boot time.
The /E option uses expanded memory. The speed increase is not as great as that supplied by the /X option. The expanded memory manager (EMM) must be LIM 4.0, and no single module's debug information can exceed 48K. If the symbol table exceeds this limit, try reducing file-name information by not specifying full path names at compile time and by specifying CodeView information (/Zi) only with those program modules that need debugging.
If you do not specify either /X or /E (or the /D disk-overlay option), CodeView automatically searches for the HIMEM.SYS driver and extended memory so it can implement the /X option. If it fails, CodeView searches for expanded memory to implement the /E option. If that search fails, CodeView uses a default disk overlay of 64K. (See the description of the /D option in the next section.)