C.1.1 Logging Debugging Messages

You can log messages to the DBWIN window, to a debugging monitor, or to the device attached to the COM1 port. The Options menu allows you to change the destination of debugging messages.

C.1.1.1 Settings Command

Choosing the Settings command from the Options menu produces a dialog box that allows you to control the display of debugging messages produced by the debugging system. This dialog box contains the following check boxes:

Check box Description

Break Controls whether and how a message causes a break to the debugger with a stack trace.
Trace Controls whether certain kinds of informational messages are produced.
Debugging Controls the kind of debugging features enabled in the system.
  Following is a selected list of debugging options:
Option Meaning

Validate Heap Check the consistency of global and local heaps before every call to a memory-management function. This option affects the global heap only when it is one of the default start-up settings (that is, when it is saved by choosing the Save Settings command from the File menu). This option affects local heaps only if it is set before the application is started.
Check Free Blocks Ensure that freed local blocks are not written into. The value 0xFB is written into free blocks and when the heap is validated, a check is performed to ensure that the blocks are still filled with this value. This option works only with local heaps. It must be used with the Validate Heap option.
Buffer Fill Fill buffers that are passed to Windows functions with the value 0xF9. This option ensures that all of the supplied buffer is writable and helps detect overwrite problems that can occur when the buffer is too small.
Break with INT 3 Break to the debugger with an int 3 instruction, instead of a fatal exit. This option does not display a stack back-trace.

Note:

Some applications will not run when the Buffer Fill option is turned on. If the supplied buffer is smaller than the size specified in the count parameter of the calling function, the application data is overwritten.

C.1.1.2 Alloc Break Command

The Alloc Break command on the Options menu ensures that an application deals properly with out-of-memory conditions. This command displays a dialog box into which you can enter the module name of your application and the number of memory allocations you want to succeed before subsequent allocations fail.

The system counts each global or local memory allocation performed by your application. When the number of allocations reaches the allocation break count, that allocation and all subsequent allocations fail. Because memory allocations made by the system fail once the break count is reached, calls to certain functions (such as CreateWindow, CreateBrush, and SelectObject) will fail as well. Only allocations made within the context of the application you specify are affected by the allocation break count.

The module name is limited to 8 characters. In some cases the module name may be different from the filename. (The module name is specified in the module-definition file for the application.) You cannot specify the module name of a DLL.

If you set the break count to zero, no allocation break is set, but the system counts allocations made by the specified application. You can choose the Show Count button to display the current allocation count.

You can set an allocation break before the named application is run. The allocation count is then set to zero and allocations are counted as soon as the application starts. If you run more than one instance of an application, the allocation break applies only to the most recent instance.

The allocation count is also reset to zero when you choose the Set command or the Inc & Set command. You can set an allocation break before performing an operation, to ensure that your application handles the problem effectively, and then choose Inc & Set and repeat the operation, to ensure that the next allocation failure is also handled properly.