home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bc45 / tddoc.pak / TD_HELP.TXT < prev    next >
Text File  |  1997-07-23  |  15KB  |  422 lines

  1. /***********************************************************************/
  2.                             TURBO DEBUGGER
  3.                             TIPS AND HINTS
  4.  
  5. This file contains tips and hints concerning problems you might
  6. encounter while using TD.EXE, TDW.EXE, and TD32.EXE. The following
  7. topics are covered:
  8.  
  9. 1.  TDW.INI
  10. 2.  TDW Hardware Debugging
  11. 3.  Running TDW under Windows For Workgroups
  12. 4.  Restart Information/Session State Saving
  13. 5.  Program Reset
  14. 6.  Program Interrupt Key
  15. 7.  Resetting and restarting programs
  16. 8.  Video Support
  17. 9.  Windows debugging hints
  18. 10. Answers to common questions
  19.  
  20.  
  21. ------------
  22.  1. TDW.INI
  23. ------------
  24. You must have a single copy of TDW.INI located on your system, and
  25. it must be located in your main Windows directory (usually "\WINDOWS").
  26. Be sure to delete any extra copies of TDW.INI that you might have on
  27. your system.
  28.  
  29. By default, TDW.INI contains the following text:
  30.  
  31.    [TurboDebugger]
  32.    VideoDll = <Your_BorlandC_Bin_Directory>\SVGA.DLL
  33.    debuggerDll = <Your_BorlandC_Bin_Directory>\TDWINTH.DLL
  34.  
  35.    [VideoOptions]
  36.  
  37. You can use TD32 to debug under Win32s. However, to do so, you must
  38. ensure you use SVGA.DLL or equivalent support in the VideoDLL entry
  39. in the [TurboDebugger] section of TDW.INI. Use the Turbo Debugger Video
  40. Configuration utility (TDWINI.EXE) to set the required option.
  41.  
  42.  
  43. ---------------------------
  44.  2. TDW Hardware Debugging
  45. ---------------------------
  46. In order to support hardware debugging in TDW, you need to load
  47. the device driver TDDEBUG.386. Edit your SYSTEM.INI file in the \WINDOWS
  48. directory and add the following statement to the [386enh] section:
  49.  
  50.    device=<Your_BorlandC_Bin_Directory>\TDDEBUG.386
  51.  
  52. Make sure that you comment out the line that loads the Windows driver
  53. WINDEBUG.386 with a semicolon. For example:
  54.  
  55.    ;c:\windows\windebug.386
  56.  
  57.  
  58. ---------------------------------------------
  59.  3. Running TDW under Windows For Workgroups
  60. ---------------------------------------------
  61. If you use Windows for Workgroups 3.11, you must use TDWINTH.DLL when
  62. you debug with TDW. Be sure the DebuggerDll setting in your
  63. TDW.INI file explicitly points to TDWINTH.DLL. For example:
  64.  
  65.    debuggerDll=<Your_BorlandC_Bin_Directory>\TDWINTH.DLL
  66.  
  67.  
  68. ---------------------------------------------
  69.  4. Restart Information/Session State Saving
  70. ---------------------------------------------
  71. Turbo Debugger saves Breakpoint, Inspector, and other session information
  72. when you exit a debugging session. Then, when you restart a debugging
  73. session, Turbo Debugger restores this information. To ignore the restart
  74. information, use Turbo Debugger's -ji command line switch when you load
  75. Turbo Debugger.
  76.  
  77. If your system crashes during a debugging session, your configuration
  78. file is likely to become corrupt. This can cause Turbo Debugger to hang
  79. on startup. Because of this, it is advisable to delete any .TR, .TRW, or
  80. .TR2 files from your hard disk if you crash during a debugging session.
  81.  
  82.  
  83. ------------------
  84.  5. Program Reset
  85. ------------------
  86. Dialog applications that do not have a parent window will cause your
  87. system to hang if you reload the application.
  88.  
  89.  
  90. --------------------------
  91.  6. Program Interrupt Key
  92. --------------------------
  93. Under TD:       Ctrl-Break
  94. Under TDW:      Ctrl-Alt-SysReq
  95. Under Win32s:   Ctrl-Alt-F11
  96. Under NT:       F12
  97.  
  98.  
  99. --------------------------------------
  100.  7. Resetting and restarting programs
  101. --------------------------------------
  102. When you reload or reset a program a number of times under Windows 32s,
  103. it is likely that you will run out of memory. This problem has been
  104. reported to Microsoft.
  105.  
  106. If Turbo Debugger fails to start correctly, especially after a system
  107. crash, the debugger session state and configuration files may be
  108. corrupted. Try removing the following files:
  109.  
  110. For TD: TDCONFIG.TD
  111.              ***.TR
  112.  
  113. For TDW: TDCONFIG.TDW
  114.               ***.TRW
  115.  
  116. For TD32: TDCONFIG.TD2
  117.                ***.TR2
  118.  
  119. Where *** equals your application's name.
  120.  
  121. These files will be found in either the working directory,
  122. the \BorlandC\Bin directory, or the \Windows directory.
  123.  
  124.  
  125. ------------------
  126.  8. Video Support
  127. ------------------
  128. Turbo Debugger requires that you use the correct Windows video driver
  129. for your video card. For example, if you have a TSENG card, make sure
  130. that you are using the TSENG Windows video driver (the generic VGA
  131. video driver does not work correctly with this video card).
  132.  
  133. To find out what type of video card you have installed in your
  134. machine, type MSD <Enter> at the DOS prompt. Use the TDWINI.EXE
  135. utility to set up your video driver.
  136.  
  137. SVGA.DLL supports most video card configurations, provided that you
  138. are using the correct Windows video drivers. Use the Turbo Debugger Video
  139. Configuration utility (TDWINI.EXE) to determine the correct Video Support
  140. for your adapter. 
  141.  
  142.  
  143. Screen not being repainted
  144. --------------------------
  145. Ensure that the "ForceRepaint" flag is set to "Yes" in the
  146. VideoOptions section of TDW.INI:
  147.  
  148.      [VideoOptions]
  149.      ForceRepaint=Yes
  150.  
  151. This can be done through the Turbo Debugger Video Configuration
  152. utility (TDWINI.EXE).
  153.  
  154.  
  155. Dual Monitor Support under Windows 32s
  156. --------------------------------------
  157. TD32 can support dual monitor debugging under Windows 32s.
  158. Ensure that a monochrome adapter is installed in your machine
  159. and set the Mono flag in the [VideoOptions] section of TDW.INI
  160. to "Yes."
  161.  
  162.      [VideoOptions]
  163.      MONO=yes
  164.  
  165. This can be done through the Turbo Debugger Video Configuration
  166. utility, TDWINI.EXE.
  167.  
  168.  
  169. ---------------------------
  170. 9. Windows debugging hints
  171. ---------------------------
  172. View|Windows Messages
  173.  
  174. 1) If you set up View|Windows Messages to display messages for
  175.    more than one procedure or handle or both, do not log all
  176.    messages. Instead, log specific messages for each procedure or
  177.    handle. If you log all messages, the system might hang, in
  178.    which case you will have to reboot to continue. This behavior
  179.    is due to the large number of messages being transferred
  180.    between Windows and Turbo Debugger.
  181.  
  182. 2) When setting a break on the Mouse class of messages, note that
  183.    a "mouse down" message must be followed by a "mouse up" message
  184.    before the keyboard will become active again. When you return
  185.    to the application, you might have to press the mouse button
  186.    several times (or press the <ALT> key) to get Windows to receive a
  187.    "mouse up" message. You'll know Windows has received the message
  188.    when you see it in the bottom pane of the Windows Message window
  189.    after the program breaks.
  190.  
  191.  
  192. --------------------------------
  193. 10. Answers to common questions
  194. --------------------------------
  195. Following is a list of the most commonly asked questions about TDW:
  196.  
  197. 1) Are there any syntactic or parsing differences between Turbo
  198.    Debugger's C expression evaluation and Turbo C++ for Windows'?
  199.  
  200.    You can't pass constant-string arguments when evaluating
  201.    functions.
  202.  
  203.      OK:   myfunc(123)   myfunc(string_variable)
  204.  
  205.      BAD:  myfunc("constant")
  206.  
  207. 2) What should I be aware of when I am debugging multilanguage
  208.    programs with Turbo Debugger?
  209.  
  210.    Turbo Debugger's default source language is "Source," which
  211.    means it chooses the expression language based on the current
  212.    source module. This can cause some confusion if your program
  213.    has source modules written in different languages (like C
  214.    and assembler). Since you are actually entering a language
  215.    expression any time Turbo Debugger prompts you for a value
  216.    or an address, this can cause some unexpected results:
  217.  
  218.    a. Even if you are in a CPU window or a Dump window, you
  219.       must still enter addresses in the source language,
  220.       despite the fact that the window is displaying in hex.
  221.       For example, to display the contents of memory address
  222.       1234:5678, you must type one of the following
  223.       expressions, depending on your current source language:
  224.  
  225.        C            0x1234:0x5678
  226.        Pascal        $1234:$5678
  227.        Assembler     1234H:5678H
  228.  
  229.    b. When your current language is assembler, you must be
  230.       careful when entering hex numbers, since they are
  231.       interpreted EXACTLY as they would be in an assembler
  232.       source file. This means that if you want to enter a
  233.       number that starts with one of the hex digits A - F, you
  234.       must first precede the letter with a 0 so Turbo Debugger
  235.       knows you are entering a number. Likewise, if your number
  236.       ends in B or D (indicating a binary or decimal number), you
  237.       must add an H to indicate that you really want a hex number:
  238.  
  239.        OK:   0aaaa   123dh   89abh
  240.  
  241.        BAD:  aaaa    123d    89ab
  242.  
  243. 3) Why does the text "Cannot be changed" come up when I do an
  244.    assignment in the Data/Evaluate/Modify "New value" pane?
  245.  
  246.    If you use the Data/Evaluate/Modify command (Ctrl-F4) to
  247.    change a variable by direct assignment, the "New value" pane
  248.    will say "Cannot be changed." This doesn't mean the 
  249.    assignment didn't take effect. What it does mean is that the
  250.    assignment expression as a whole is not a memory-referencing
  251.    expression whose value you can change by moving to the
  252.    bottom pane. Here are some examples of direct assignment
  253.    expressions:
  254.  
  255.      C              x = 4
  256.      Pascal         ratio := 1.234
  257.      Assembler      wval = 4 shl 2
  258.  
  259.    If you had typed just "x," "ratio," or "wval" into the top
  260.    pane, then you would be able to move to the bottom pane and
  261.    enter a new value. The direct assignment method using the
  262.    "=" or ":=" assignment operator is quicker and more
  263.    convenient if you don't care about examining the value of
  264.    the variable before modifying it.
  265.  
  266.  
  267. 4) What could happen when global breakpoints are set on local
  268.    variables?
  269.  
  270.    When you set global breakpoints using local variables, make
  271.    sure the breakpoints are cleared before you exit the
  272.    procedure or function that the variables are defined in. The
  273.    best way to do this is to put a breakpoint on the last line
  274.    of the procedure or function. If you do not clear the
  275.    breakpoints, your program will break unexpectedly and may
  276.    even hang on some machines because the breakpoints are being
  277.    set in memory that is not currently being used by the
  278.    procedure or function.
  279.  
  280. 5) Why is execution slower when tracing (F7) than when stepping
  281.    (F8) through my programs?
  282.  
  283.    TDW can do reverse execution, which means that when you are
  284.    tracing through your program, TDW could be saving all the
  285.    information about each source line you trace over. TDW only
  286.    saves this information in the Module window if you have chosen
  287.    View|Execution History and toggled the Full History local menu
  288.    command to 'Yes'.
  289.  
  290.    If you want faster execution you can step over (F8) the instruction
  291.    or toggle the Full History option to 'No' in the Execution History
  292.    window. (Although reverse execution is always available in the
  293.    CPU view, you must toggle this option to 'Yes' for it to work
  294.    in the Module view. The default setting in the Module view is 'No'.)
  295.  
  296. 6) What are some of the syntactic and parsing differences
  297.    between Turbo Debugger's built-in assembler and the
  298.    standalone Turbo Assembler?
  299.  
  300.    A discussion follows this short example program:
  301.  
  302.           .model small
  303.           .data
  304.  
  305.    abc    struc
  306.    mem1   dd      ?
  307.    mem2   db      ?
  308.    mem3   db      "   "
  309.    abc    ends
  310.  
  311.           align   16
  312.    a      abc     <1,2,"xyz">
  313.  
  314.    msg1   db      "testing 1 2 3", 0
  315.    msg2   db      "hello world", 0
  316.    nmptr  dw      msg1
  317.    fmptr  dd      msg1,msg2
  318.    nfmptr dw      fmptr
  319.    xx     dw      seg a
  320.  
  321.           .code
  322.  
  323.           push   cs
  324.           pop    ds
  325.           mov    bx,offset a
  326.           mov    bx,nmptr
  327.           les    si,fmptr
  328.           mov    ah,4ch
  329.           int    21h
  330.           end
  331.  
  332.    Because the assembler expression parser does not accept all legal
  333.    TASM instruction operands, Turbo Debugger assembler expressions
  334.    can be more general than those of TASM and can use multiple levels
  335.    of memory-referencing, much like C and Pascal. However, there are a
  336.    few constructs that you may be used to that you'll have to specify
  337.    differently for the Turbo Debugger assembler expression parser to
  338.    accept them:
  339.  
  340.      a. Size overrides should always appear inside the
  341.         brackets; PTR is optional after the size. Also, when
  342.         referring to a structure, you must use the name of the
  343.         structure, not the name of the variable:
  344.  
  345.           OK:  [byte ptr bx]   [dword si]        [abc bx]
  346.  
  347.           BAD: byte ptr[bx]    [struc abc bx]    [a bx]
  348.  
  349.      b. You must specify a structure name when accessing the
  350.         members of a structure with a register pointer.
  351.  
  352.           OK:  [abc ptr bx].mem1  [abc bx].mem3 + 1
  353.  
  354.           BAD: [bx].mem1
  355.  
  356.      c. You can't use multiple instances of brackets ([]) unless they are
  357.         adjacent, and you can only follow a bracketed expression with
  358.         a dot and a structure member name or another bracketed
  359.         expression:
  360.  
  361.           OK:  4[bx][si]    [abc bx].mem2
  362.  
  363.           BAD: [bx]4[si]    [bx]+4
  364.  
  365.      d. If you use a register as part of a memory expression
  366.         and you don't specify a size, WORD is assumed:
  367.  
  368.           [bx] is the same as [word bx]
  369.  
  370.      e. You can use any register you want between brackets ([]),
  371.         not just the combinations of BX, BP, SI, and DI allowed in
  372.         instruction operands. For example,
  373.  
  374.           [ax+bx]
  375.           [bx+sp]
  376.  
  377.      f. You can use multiple levels of brackets to follow chains of
  378.         pointers. For example,
  379.  
  380.           [byte [[nfmptr]+4]]
  381.  
  382.      g. Be careful with using registers to access memory locations.
  383.         You might get unexpected results if your segment
  384.         registers are not set up properly. If you don't
  385.         explicitly specify a segment register, Turbo Debugger
  386.         uses the DS register to reference memory.
  387.  
  388.      h. When you do specify a segment register, make sure you
  389.         follow the same rule for size overrides: put it
  390.         INSIDE the brackets, as follows:
  391.  
  392.           OK:  [byte es:di]    [es:fmptr]
  393.  
  394.           BAD: es:[byte di]
  395.  
  396.      i. Use the OFFSET operator to get the address of a
  397.         variable or structure. Turbo Debugger automatically
  398.         supplies the brackets around a variable name if you just type
  399.         the variable name alone.
  400.  
  401.           a            contents of structure a
  402.           [a]          contents of structure a
  403.           offset a     address of structure a
  404.  
  405.      j. You can use the type overrides and the format control
  406.         count to examine any area of memory displayed as you wish.
  407.  
  408.           [byte es:bx],10  10 bytes pointed to by es:bx
  409.           [dword ds:si],4  4 dwords pointed to by ds:si
  410.  
  411.         This is very useful when specifying watch expressions.
  412.  
  413.      k. Sometimes you use a word memory location or register to
  414.         point to a paragraph in memory that contains a data
  415.         structure. Access the structure with expressions like
  416.  
  417.           [abc [xx]:0].mem1
  418.           [abc es:0].mem3
  419.  
  420. /************************* END OF FILE *****************************/
  421.  
  422.