home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c480 / 18.ddi / SAMPLES / DBWIN / DBWIN.TX_ / DBWIN.TX
Encoding:
Text File  |  1993-02-08  |  11.1 KB  |  257 lines

  1.             DBWIN Debug Message Logger
  2.             --------------------------
  3.  
  4. The DBWIN utility allows you to see messages produced by the debug system
  5. binaries, even if you don't have a debug terminal or debugger running.
  6.  
  7. In addition, it allows you to see certain errors even when running on a
  8. retail system.
  9.  
  10. DBWIN also allows you to control the output of various kinds of messages:
  11. whether they're displayed, whether you break to the debugger, etc.  You can
  12. save your settings in win.ini so that they'll remain in effect the next time
  13. you run Windows.
  14.  
  15. DBWIN provides a debugging feature that allows you to force allocation
  16. failures, in order to test your code's out-of-memory handling.
  17.  
  18.  
  19.             Setting Up
  20.             ----------
  21.  
  22. DBWIN is designed to be used with the debugging system binaries, though it
  23. can be used with the retail system as well.  So, you'll first need to install
  24. the debugging binaries on your machine.  Because the debug system does run
  25. 10-20% slower than the retail system, you may want to switch back and forth
  26. between them.  The best way to do this is to create two subdirectories in
  27. your SYSTEM directory, RETAIL and DEBUG.  Copy the proper USER, GDI and
  28. KRNL286/386 .exe and .sym files into the appropriate directory, then write
  29. two batch files that will copy one set of files to the SYSTEM directory as
  30. appropriate.  Then, you need only exit Windows and run the proper batch file
  31. to set up the DEBUG or RETAIL system.
  32.  
  33. You may want to disable the default system debug output to AUX, since DBWIN
  34. can be used to control output to COM1 or COM2.  It's a good idea to do this,
  35. since it will improve the performance of your debug system when you have
  36. redirected DBWIN output to NONE, or if DBWIN is not running.
  37.  
  38. To disable the default system debug output to AUX, just add the following to
  39. the [Debug] section of system.ini:
  40.  
  41.     OutputTo=NUL
  42.  
  43. If you disable the default kernel output, and want to send output to COM1 or
  44. COM2, you may need to set the DOS COM port baud rates to match the baud rates
  45. of your debug terminal, using the DOS MODE command.  It's easiest to do this
  46. in your autoexec.bat, e.g., mode 19200,n,8,1.
  47.  
  48.  
  49.             Message Logging
  50.             ---------------
  51.  
  52. You can log messages to the DBWIN window, to a monochrome screen (if you have
  53. one attached), or to the COM1 or COM2 devices.  You can also turn off message
  54. output (which makes the debug system run somewhat faster). By default,
  55. messages are logged to a window.
  56.  
  57. The Options menu allows you to change the destination of debugging message
  58. output.  These settings will be in effect the next time you run DBWIN.
  59.  
  60.  
  61.             System Debug Options
  62.             --------------------
  63.  
  64. The Options.Settings dialog allows you to control the output of various debug
  65. messages produced by the debug system binaries.  There are three groups of
  66. check boxes: Debug options, Break options, and Trace options.
  67.  
  68. The Settings dialog only works when you are running the debug system.
  69.  
  70. Debug options controls what kind of debugging features are enabled in the
  71. system.
  72.  
  73. Break options controls whether and how a message will cause a break to the
  74. debugger with a stack trace (i.e., FatalExit() call, or RIP).
  75.  
  76. Trace options controls whether or not certain kinds of informational messages
  77. are produced.
  78.  
  79. The "App:" field allows you to see only messages related to a particular
  80. application.  Normally, DBWIN will display all debug messages in the system,
  81. but if you enter an application's module name in this entry field, only
  82. messages for that app are displayed.  You must enter the application module
  83. name as found in the app's .def file, which may be different than the file
  84. name of the app.
  85.  
  86.  
  87.             Debug Options
  88.             -------------
  89.  
  90.     Validate Heap
  91.  
  92.         Check the consistency of global and local heaps before every memory
  93.         management call.  Only affects the global heap if set as the default
  94.         boot-time settings (i.e., saved with File.Save Settings). Only
  95.         affects local heaps if set before heap is created and initialized
  96.         (i.e., before you start the app)
  97.  
  98.     Check Free Blocks
  99.  
  100.         Must be used with Validate Heap.
  101.  
  102.         Ensures that freed local blocks aren't written into by writing 0xFB
  103.         into free blocks, and checking to ensure that they're still filled
  104.         with 0xFB when the heap is validated.  Only works with local heaps.
  105.  
  106.     Buffer Fill
  107.  
  108.         Fill buffers passed to APIs with 0xF9.  Ensures that all of supplied
  109.         buffer is writeable.  Helps detect overwrite problems when supplied
  110.         buffer size is not large enough (e.g., GetWindowText).
  111.  
  112.         NOTE: Some applications will not run with this option turned on,
  113.         because the supplied buffer is actually smaller than specified in
  114.         the count parameter, thus causing overwrite of application data.
  115.  
  116.     Break with INT 3
  117.  
  118.         Break to the debugger with an INT 3, rather than a fatal exit.
  119.         Doesn't print a stack back trace.
  120.  
  121.  
  122.     Don't trap faults
  123.  
  124.         Prevent the system from hooking GP and stack overflow faults.
  125.         NOTE: Many faults that result from this would normally be handled
  126.         by the system and restarted -- checking this option will result in
  127.         faults that would not occur otherwise.
  128.  
  129.  
  130.             Using DBWIN on a Retail System
  131.             ------------------------------
  132.  
  133. DBWIN can provide useful debugging messages on a retail system as well. The
  134. setup and alloc break commands are disabled, and you will only see a limited
  135. subset of debugging messages.
  136.  
  137. You should NEVER release an application without testing it under the full
  138. debug system -- only the debug version of the system will inform you when
  139. resources haven't been freed, for example.  There are many other important
  140. errors and warnings that won't be displayed if DBWIN is run with the retail
  141. system.
  142.  
  143.             Alloc Break
  144.             -----------
  145.  
  146. The Alloc break feature is designed to help you ensure that your application
  147. properly deals with out-of-memory conditions that might occur.
  148.  
  149. The idea is that the system counts each global or local memory allocation
  150. performed.  When the number of allocations reaches the allocation break
  151. count, that allocation and all subsequent allocations will fail.
  152.  
  153. Because memory allocations made by the system are failed once the break count
  154. is reached, calls such as CreateWindow, CreateBrush, SelectObject, and others
  155. will fail as well.  Only allocations made within the context of the application
  156. you specify are affected by the alloc break.
  157.  
  158. You can use this feature to cause memory failures in turn for every
  159. allocation your application performs at certain times, such as
  160. initialization, load/save, etc.
  161.  
  162.  
  163.             Setting an alloc break
  164.             ----------------------
  165.  
  166. To set or examine an alloc break, choose the "Alloc Break..." command in the
  167. Options menu.  You enter the module name of the application and the count at
  168. which you want allocations to start failing.
  169.  
  170. The module name is limited to 8 characters.  In some cases the module name
  171. may be different from the file name: it's the name specified in the
  172. application .DEF file.  You can't specify the module name of a DLL: it must
  173. be an application module name.
  174.  
  175. If you set the break count to 0, no allocation break will be set, but the
  176. system will count allocations made by the specified application.  You can use
  177. the "show count" button to determine the current count.
  178.  
  179. You can set an alloc break before the named application is run.  The alloc
  180. count will be set to 0 and allocations will be counted as soon as the
  181. application starts up.  If you run more than one instance of an application,
  182. the alloc break will apply to the last instance run only.
  183.  
  184. The allocation count is also reset to 0 when you choose "Set" or "Inc & Set".
  185.  
  186. If you set the break count to 0, no alloc break will be set, but the system
  187. will update the alloc count allocations.  You can use the "show count" button
  188. to see the current count.
  189.  
  190. The best way to use this feature is to set an alloc break before some
  191. operation (such as running the app, or loading a file, etc), perform the
  192. operation, and ensure that your app deals gracefully with the problem.  Then,
  193. choose "Inc & Set" and repeat the operation, to ensure that the next
  194. allocation failure is handled properly.
  195.  
  196.  
  197.             Recommended Settings
  198.             --------------------
  199.  
  200. Most people find that the extra diagnostics provided by the debugging system
  201. binaries are well worth the small performance degradation that they incur.
  202.  
  203. Applications should run with no errors OR warnings.  With very few
  204. exceptions, it's possible to code around all the warnings that the system can
  205. generate. When an application generates lots of errors or warnings, messages
  206. that indicate a real bug are often lost in the volume of more mundane warnings.
  207.  
  208. During normal testing and development you may want to run with "Don't break
  209. on warnings".  Quite frequently with code you've just written, you'll be able
  210. to figure out what the problem is when you see a message without even having
  211. to break into a debugger.  When you need to use the debugger to track
  212. something down, you can turn off "don't break on errors" and turn on "Break
  213. on warnings".  It's also a bit faster and more efficient to set "break with
  214. INT 3": it saves having to wait for the stack backtrace to display.  With
  215. these settings you will stop at all warnings and errors, giving you a chance
  216. to have a look at what the problem is.
  217.  
  218. Quite a few shipping applications will generate lots of warnings and errors
  219. on a debug system, making them difficult and slow to use sometimes.  You can
  220. avoid this by entering the module name of the application you're debugging,
  221. (so messages won't be generated by other apps), and checking "Don't break on
  222. Errors" so that the system doesn't stop when an error is encountered.
  223.  
  224. Unfortunately, even though you can suppress the output of messages for other
  225. apps in this way, you can't stop other applications from breaking to the
  226. debugger.
  227.  
  228.             Troubleshooting
  229.             ---------------
  230.  
  231. Common problems and their solutions:
  232.  
  233. 1. Output appears on the debugging terminal even though Options.No Output
  234.    is selected.
  235.  
  236.    This will arise if you are using a debugger such as wdeb386 that uses
  237.    COM1 or COM2 as its debugging output
  238.  
  239. 2. Debugging messages are duplicated twice on the debugging terminal.
  240.  
  241.    This will occur if you have not redirected the debug kernel's default
  242.    debugging output to NUL.  You need to add [Debug] OutputTo=NUL to your
  243.    system.ini file before starting Windows.
  244.  
  245. 3. My serial mouse doesn't work right when DBWIN runs.
  246.  
  247.    This problem can arise when DBWIN is set up to output its debug
  248.    information to the same COM port where you have your mouse installed.
  249.    Just change the output to another com port or to a window.
  250.  
  251. 4. No monochrome debug output appears when I'm running CVW or another
  252.    application that uses the monochrome display
  253.  
  254.    DBWIN tries to detect that another app is using the monochrome display
  255.    memory, and suppresses any output.  You can redirect output elsewhere,
  256.    if you're not seeing the messages in your debugger.
  257.