home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 6.ddi / DOC.ZIP / HELPME!.TD < prev    next >
Encoding:
Text File  |  1992-06-10  |  23.0 KB  |  533 lines

  1. /*************************************************************************/
  2.                       TURBO DEBUGGER TIPS AND HINTS
  3.  
  4. CONTENTS:
  5. 1.  Answers to common questions
  6. 2.  Turbo Debugger for Windows (TDW), Windows debugging hints
  7. 3.  TDW mouse support
  8. 4.  TD mouse support
  9.  
  10. 1. Answers to common questions
  11. ------------------------------
  12.   Following is a list of the most commonly asked questions about Turbo
  13.   Debugger.
  14.  
  15.   1. How does Turbo Debugger handle screen output for graphics-
  16.      and text-based programs?
  17.  
  18.      There are a number of strategies that can be used to control
  19.      how and when the screen gets refreshed. You should review the
  20.      following tips if you are debugging a program that uses a graphics
  21.      display mode and you want to do either of the following:
  22.  
  23.         - use a Borland pop-up utility such as SideKick or
  24.           Sidekick Plus while inside Turbo Debugger
  25.  
  26.         - run programs from Turbo Debugger's DOS Shell that write
  27.           directly to video memory
  28.  
  29.      The default screen-updating mode, "Swap," causes Turbo Debugger
  30.      to use a single display adapter and display page and swap the
  31.      contents of the user and Turbo Debugger screens in software.
  32.      "Swap" is the slowest method of display swapping, but is the most
  33.      protective and least disruptive.
  34.  
  35.      Pop-up utilities might not appear on the screen if your screen
  36.      updating is set to "Flip," even though they are active and proces-
  37.      sing your keystrokes. You must select "Swap" mode for display
  38.      updating in order for these programs to work properly. Use Turbo
  39.      Debugger's -ds command-line option to do this or use the TDINST
  40.      utility to permanently set this mode. "Swap" mode makes screen
  41.      updating slower, but it ensures that Turbo Debugger's screen
  42.      doesn't interfere with either your program's or any other program's
  43.      display.
  44.  
  45.      You might also need to use "Swap" when you use the DOS Shell
  46.      command or run an editor from within Turbo Debugger. Most programs
  47.      expect to run on video page 0 and don't check to see what
  48.      the current video page is. Turbo Debugger's DOS Shell and any
  49.      editors that Turbo Debugger runs in "Flip" mode don't run from
  50.      video page 0, and the programs might appear to hang, even though
  51.      you will be able to type in keystrokes normally. If this happens,
  52.      use the -ds command-line option when you run Turbo Debugger or
  53.      reinstall Turbo Debugger to use "Swap" instead of "Flip."
  54.  
  55.      If you are debugging a graphics mode application, you must specify
  56.      the -ds command-line option ("Swap" contents), and you might want
  57.      to use Turbo Debugger's -vg command-line option (Graphics Save). This
  58.      option causes additional memory to be set aside for saving the
  59.      entire graphics image your program produces. If you don't use this
  60.      option, a "red cloud" may appear on your program's screen. These
  61.      options can also be set permanently by using the TDINST program.
  62.      The Graphics Save option takes an additional 8K of memory and slows
  63.      screen-swapping.
  64.  
  65.      If you're running a graphics program that changes the EGA or VGA
  66.      palette, make sure you use the -vp command-line option to save the
  67.      palette.
  68.  
  69.   2. Can Turbo Debugger execute other programs while you're still debugging?
  70.  
  71.      The DOS Shell and Edit commands in the Module and File
  72.      windows can swap to disk the program you are debugging in
  73.      order to make room to run DOS or your editor. The default
  74.      amount of memory to swap is 128K. You can use TDINST to set a
  75.      different amount if that's not enough memory to run your editor
  76.      or other programs. Setting the swap size to 0K tells Turbo Debugger
  77.      to swap the entire user program to disk before running the DOS
  78.      command processor.
  79.  
  80.      Only your program gets swapped to disk; Turbo Debugger remains in memory.
  81.  
  82.   3. How can I break out of a program even though interrupts are
  83.      disabled?
  84.  
  85.      If you have an 80386 computer and are using TD386, the -B option
  86.      allows a break even when interrupts are disabled. For example, this
  87.      option enables a break from
  88.  
  89.        CLI
  90.        JMP $
  91.  
  92.   4. Why can't I press Ctrl-Break to get out of a program
  93.      running on a remote machine?
  94.  
  95.      The program running on the remote machine has taken control
  96.      of Interrupt 1B (Ctrl-Break). TDREMOTE and WREMOTE don't take
  97.      back control of Interrupt 1B until you stop execution of the
  98.      running program. To stop execution, run the program to completion
  99.      or press Ctrl-F2 (Program Reset) on the local machine.
  100.  
  101.  
  102.   5. What are some of the syntactic and parsing differences
  103.      between Turbo Debugger's built-in assembler and the
  104.      standalone Turbo Assembler?
  105.  
  106.      A discussion follows this short example program:
  107.  
  108.               .model small
  109.               .data
  110.  
  111.        abc    struc
  112.        mem1   dd      ?
  113.        mem2   db      ?
  114.        mem3   db      "   "
  115.        abc    ends
  116.  
  117.               align   16
  118.        a      abc     <1,2,"xyz">
  119.  
  120.        msg1   db      "testing 1 2 3", 0
  121.        msg2   db      "hello world", 0
  122.        nmptr  dw      msg1
  123.        fmptr  dd      msg1,msg2
  124.        nfmptr dw      fmptr
  125.        xx     dw      seg a
  126.  
  127.               .code
  128.  
  129.               push   cs
  130.               pop    ds
  131.               mov    bx,offset a
  132.               mov    bx,nmptr
  133.               les    si,fmptr
  134.               mov    ah,4ch
  135.               int    21h
  136.               end
  137.  
  138.      Because the assembler expression parser does not accept all legal
  139.      TASM instruction operands, Turbo Debugger assembler expressions
  140.      can be more general than those of TAMS and can use multiple levels
  141.      of memory-referencing, much like C and Pascal. However, there are a
  142.      few constructs that you may be used to that you'll have to specify
  143.      differently for the TD assembler expression parser to accept them:
  144.  
  145.        a. Size overrides should always appear inside the
  146.           brackets; PTR is optional after the size. Also, when
  147.           referring to a structure, you must use the name of the
  148.           struc, not the name of the variable:
  149.  
  150.             OK:  [byte ptr bx]   [dword si]        [abc bx]
  151.  
  152.             BAD: byte ptr[bx]    [struc abc bx]    [a bx]
  153.  
  154.        b. You must specify a structure name when accessing the
  155.           members of a structure with a register pointer.
  156.  
  157.             OK:  [abc ptr bx].mem1  [abc bx].mem3 + 1
  158.  
  159.             BAD: [bx].mem1
  160.  
  161.        c. You can't use multiple instances of brackets ([]) unless they are
  162.           adjacent, and you can only follow a bracketed expression with
  163.           a dot and a structure member name or another bracketed
  164.           expression:
  165.  
  166.             OK:  4[bx][si]    [abc bx].mem2
  167.  
  168.             BAD: [bx]4[si]    [bx]+4
  169.  
  170.        d. If you use a register as part of a memory expression
  171.           and you don't specify a size, WORD is assumed:
  172.  
  173.             [bx] is the same as [word bx]
  174.  
  175.        e. You can use any register you want between brackets ([]),
  176.           not just the combinations of BX, BP, SI, and DI allowed in
  177.           instruction operands. For example,
  178.  
  179.             [ax+bx]
  180.             [bx+sp]
  181.  
  182.        f. You can use multiple levels of brackets to follow chains of
  183.           pointers. For example,
  184.  
  185.             [byte [[nfmptr]+4]]
  186.  
  187.        g. Be careful with using registers to access memory locations.
  188.           You might get unexpected results if your segment
  189.           registers are not set up properly. If you don't
  190.           explicitly specify a segment register, Turbo Debugger
  191.           uses the DS register to reference memory.
  192.  
  193.        h. When you do specify a segment register, make sure you
  194.           follow the same rule for size overrides: put it
  195.           INSIDE the brackets, as follows:
  196.  
  197.             OK:  [byte es:di]    [es:fmptr]
  198.  
  199.             BAD: es:[byte di]
  200.  
  201.        i. Use the OFFSET operator to get the address of a
  202.           variable or structure. Turbo Debugger automatically
  203.           supplies the brackets around a variable name if you just type
  204.           the variable name alone.
  205.  
  206.             a            contents of structure a
  207.             [a]          contents of structure a
  208.             offset a     address of structure a
  209.  
  210.        j. You can use the type overrides and the format control
  211.           count to examine any area of memory displayed as you
  212.           wish.
  213.  
  214.             [byte es:bx],10  10 bytes pointed to by es:bx
  215.             [dword ds:si],4  4 dwords pointed to by ds:si
  216.  
  217.           This is very useful when specifying watch expressions.
  218.  
  219.        k. Sometimes you use a word memory location or register to
  220.           point to a paragraph in memory that contains a data
  221.           structure. Access the structure with expressions like
  222.  
  223.             [abc [xx]:0].mem1
  224.             [abc es:0].mem3
  225.  
  226.   6. Are there any syntactic or parsing differences between Turbo
  227.      Debugger's C expression evaluation and Borland C++'s?
  228.  
  229.      You can't pass constant-string arguments when evaluating
  230.      functions.
  231.  
  232.        OK:   myfunc(123)   myfunc(string_variable)
  233.  
  234.        BAD:  myfunc("constant")
  235.  
  236.   7. What should I be aware of when I'm debugging multilanguage
  237.      programs with Turbo Debugger?
  238.  
  239.      Turbo Debugger's default source language is "Source," which
  240.      means it chooses the expression language based on the current
  241.      source module. This can cause some confusion if your program
  242.      has source modules written in different languages (like C
  243.      and assembler). Since you are actually entering a language
  244.      expression any time Turbo Debugger prompts you for a value
  245.      or an address, you can encounter unexpected results.
  246.  
  247.      a. Even if you are in a CPU window or a Dump window, you
  248.         must still enter addresses in the source language,
  249.         despite the fact that the window displays in hex.
  250.         For example, to display the contents of memory address
  251.         1234:5678, you must type one of the following
  252.         expressions, depending on your current source language:
  253.  
  254.           C            0x1234:0x5678
  255.           Pascal        $1234:$5678
  256.           Assembler     1234H:5678H
  257.  
  258.      b. When your current language is assembler, you must be
  259.         careful when entering hex numbers, since they are
  260.         interpreted EXACTLY as they would be in an assembler
  261.         source file. This means that if you want to enter a
  262.         number that starts with one of the hex digits A - F, you
  263.         must first precede the letter with a 0 so Turbo Debugger
  264.         knows you are entering a number. Likewise, if your
  265.         number ends in B or D (indicating a binary or decimal
  266.         number), you must add an H to indicate that you really want
  267.         a hex number. For example,
  268.  
  269.           OK:   0aaaa   123dh   89abh
  270.  
  271.           BAD:  aaaa    123d    89ab
  272.  
  273.   9. Why does the text "Cannot be changed" come up when I do an
  274.      assignment in the Data|Evaluate|Modify "New value" pane?
  275.  
  276.      If you use the Data|Evaluate|Modify command (Ctrl-F4) to
  277.      change a variable by direct assignment, the "New value" pane
  278.      will say "Cannot be changed." This doesn't mean the
  279.      assignment didn't take effect. What it does mean is that the
  280.      assignment expression as a whole is not a memory-referencing
  281.      expression whose value you can change by moving to the
  282.      bottom pane. Here are some examples of direct assignment
  283.      expressions.
  284.  
  285.        C              x = 4
  286.        Pascal         ratio := 1.234
  287.        Assembler      wval = 4 shl 2
  288.  
  289.      If you had typed just "x", "ratio", or "wval" into the top
  290.      pane, you would be able to move to the bottom pane and
  291.      enter a new value. The direct assignment method using the
  292.      "=" or ":=" assignment operator is quicker and more
  293.      convenient if you don't care about examining the value of
  294.      the variable before modifying it.
  295.  
  296.  10. Why does an inspector occasionally display question marks
  297.      when inspecting a Borland C++ register variable?
  298.  
  299.      If you inspect a register variable that is not in the
  300.      current scope, you'll see ???? for the value. A register
  301.      variable only displays a value if the register is in your
  302.      current scope (valid at the current location in your
  303.      program).
  304.  
  305.  11. What is the most likely reason for Turbo Debugger to hang
  306.      when starting up on a PC-compatible computer?
  307.  
  308.      If your computer is a Tandy 1000A, IBM PC Convertible, or NEC
  309.      MultiSpeed, or if Turbo Debugger hangs when loading on your system,
  310.      run TDINST and change an item in the Options|Miscellaneous
  311.      menu so that NMI Intercept isn't set. Some computers use the NMI
  312.      (Non-Maskable Interrupt) in ways that conflict with Turbo Debugger,
  313.      so you must disable Turbo Debugger's use of this interrupt in order
  314.      to run the program.
  315.  
  316.      Also, if you're using an 80386-based machine and have the
  317.      SuperKey utility loaded, be careful not to press a key when
  318.      TD386 is loading, since SuperKey may capture the keystroke
  319.      and cause unexpected results.
  320.  
  321.  12. What could happen when global breakpoints are set on local
  322.      variables?
  323.  
  324.      When you set global breakpoints using local variables, make
  325.      sure the breakpoints are cleared before you exit the
  326.      procedure or function that the variables are defined in. The
  327.      best way to do this is to put a breakpoint on the last line
  328.      of the procedure or function. If you do not clear the
  329.      breakpoints, your program will break unexpectedly and may
  330.      even hang on some machines because the breakpoints are being
  331.      set in memory that is not currently being used by the
  332.      procedure or function.
  333.  
  334.  13. How can I save options set in TDINST to TD286.EXE?
  335.  
  336.      If you have a configuration file (tdconfig.td) already made for
  337.      TD.EXE, TD286.EXE will automatically use this configuration file.
  338.      You can save a configuration made in TDINST to TD286.EXE directly
  339.      if you state this on the command line. For instance,
  340.  
  341.        TDINST TD286.EXE
  342.  
  343.      When you want to save this configuration in TDINST, just select
  344.      Save\Modify td.exe.
  345.  
  346.  14. Why is execution slower when tracing (F7) than when stepping
  347.      (F8) through my programs?
  348.  
  349.      Turbo Debugger can do reverse execution. When you're tracing
  350.      through your program, Turbo Debugger is saving all the information
  351.      about the source line you just traced over. If you want faster
  352.      execution you can (F8) step over the instruction or toggle the
  353.      Full History option to "No" in the Execution History window.
  354.      (Although reverse execution is always available in the CPU
  355.      viewer this option must be toggled to "Yes" to work in the Module
  356.      viewer.  The default setting is "No".)
  357.  
  358.  15. What are some of the issues I should be aware of with TD386?
  359.  
  360.      TD386.EXE is a small kernel program that puts the processor into
  361.      virtual-86 mode, maps one chunk of extended memory into the low
  362.      640K area, and loads TD.EXE into it.  It communicates with TD.EXE
  363.      through the TDH386.SYS device driver.  When instructed to, TD386 maps a
  364.      different chunk of extended memory into the low 640K area. It then
  365.      loads the program to be debugged, into that same area.
  366.  
  367.      The debugging process continues with TD's telling TD386 what to do
  368.      through TDH386.  When any exceptions occur, they are vectored off to
  369.      the resident TD386 code which handles them. TD386 either switches back
  370.      to TD's area and informs TD that an exception occurred or, if TD386
  371.      can't figure out what happened, it simply dumps the registers to
  372.      the screen and halts the CPU (since something bad could have
  373.      happened to cause the exception)
  374.  
  375.      Because TD386 uses the virtual-86 mode of the 80386, it cannot
  376.      coexist with any other programs that put the processor into v-86
  377.      mode.  Programs that simulate EMS memory on a 386 or 486 machine
  378.      usually use virtual-86 mode to do so.  These programs (such as
  379.      QEMM, 386^MAX, CEMM, EMM386,...) are not compatible with TD386.
  380.  
  381.      If you need to use one of these EMS simulators for your program,
  382.      then you should consider using TD286.EXE, which uses a different
  383.      aspect of protected mode and IS compatible with these other
  384.      programs.
  385.  
  386.      Note: HIMEM.SYS does not use virtual-86 mode and behaves
  387.            just fine with TD386.
  388.  
  389.  
  390.      As well as providing a communication path between TD386 and TD,
  391.      TDH386 (the device driver) allows for the use of hardware
  392.      breakpoints.  You can use the hardware breakpoints on any 386 or
  393.      486 machine that has the device driver loaded and is running TD.EXE,
  394.      TD286.EXE, or TD386.EXE.
  395.  
  396.      The only real difference between TD386 and the other two debuggers
  397.      is that TD386 allows some extra breakpoints that the other debuggers
  398.      do not (I/O access breaks, ranges greater than 16 bytes, and so on).
  399.  
  400.      A typical setup would be to load QEMM and then load TDH386.SYS into
  401.      high memory.  With this setup, both TD.EXE and TD286.EXE will support
  402.      hardware breakpoints and will take up the same amount of memory as
  403.      they do without the device driver loaded.
  404.  
  405.      If you are using a SCSI device in your machine and TD386 gives you
  406.      unexpected interrupt reports, make sure that the SCSI device driver
  407.      is protected-mode-aware.  Adaptech SCSI cards come with a driver that
  408.      should work just fine.  IBM PS/2's usually have a driver called
  409.      DISK386.SYS that works in this situation.
  410.  
  411.  16. Why does TD286INS tell me that my A20 line is already enabled?
  412.  
  413.      If you are using a version of DOS that allows you to specify the
  414.      "DOS=HIGH" command in CONFIG.SYS, you won't be able to run
  415.      TD286INS.  What you should do is remove the 'DOS=HIGH' line, then run
  416.      TD286INS, and then replace the "DOS=HIGH" line in CONFIG.SYS.
  417.  
  418.  17. Why do I have mouse problems when debugging Windows programs?
  419.  
  420.      When debugging, the first time you execute a Windows program, the mouse
  421.      will work normally. For the second and subsequent runs, you must press
  422.      any key before the mouse will function. This is a known problem with
  423.      Windows.
  424.  
  425.      When the mouse driver is disabled for Windows, it will be disabled for
  426.      TDW as well.  Starting TDW with the mouse support option (-p) has no
  427.      effect.
  428.  
  429.  
  430.  
  431.  
  432. 2. Turbo Debugger for Windows (TDW), Windows debugging hints
  433. ------------------------------------------------------------
  434.   View|Windows Messages
  435.  
  436.       If you set up View|Windows Messages to display messages for
  437.       more than one procedure or handle or both, do not log all
  438.       messages.  Instead, log specific messages for each procedure or
  439.       handle.  If you log all messages, the system might hang, in
  440.       which case you will have to reboot to continue.  This behavior
  441.       is due to the large number of messages being transferred
  442.       between Windows and TDW.
  443.  
  444.       When setting a break on the Mouse class of messages, note that
  445.       a "mouse down" message must be followed by a "mouse up" message
  446.       before the keyboard will become active again.  When you return
  447.       to the application, you might have to press the mouse button
  448.       several times to get Windows to receive a "mouse up" message.
  449.       You'll know Windows has received the message when you see it in the
  450.       bottom pane of the Windows Message window after the program breaks.
  451.  
  452.       If you enter a handle name but indicate that it's a
  453.       procedure, TDW will accept your input and will not complain.
  454.       However, when you run your program, TDW will not log any
  455.       messages.  If TDW is not logging messages when you think you've
  456.       set a handle, check the Add Window dialog box of the top left pane of
  457.       the Windows Messages window to see if you've pressed the Handle button.
  458.  
  459.   View|Module
  460.  
  461.       The Debug Startup radio buttons are used for DLLs only.  To
  462.       debug EXE startup, begin TDW with the Assembler-mode Startup
  463.       command-line option (-l).
  464.  
  465.       When a program loaded into TDW is reset, the Load symbols
  466.       radio buttons default to YES for all DLLs and applications
  467.       with symbols, even if you specified NO for a given DLL or
  468.       application prior to resetting the program.
  469.  
  470.  
  471. 3. TDW mouse support
  472. --------------------
  473.   TDW provides mouse support that allows you to manipulate elements
  474.   of the user interface. Most TDW mouse operations are similar to
  475.   Windows mouse operations. In the material that follows, we discuss
  476.   tips for using a mouse under Windows and some uses of the mouse under
  477.   TDW that are different from Windows mouse usage.
  478.  
  479.   o When the mouse driver is disabled for Windows, it will be disabled
  480.     for TDW as well.  Starting TDW with the mouse support option
  481.     (-p) has no effect unless you enable the Windows mouse driver.
  482.  
  483.   o If you have a mouse driver installed by default, TDW and the
  484.     installation utilities will try to use your mouse. If you
  485.     don't want to use your mouse during a debugging session, you
  486.     can use the command-line switch '-p-' to turn the mouse off.
  487.     You can also set this option in TDWINST in the Options\Input &
  488.     Prompting dialog box.
  489.  
  490.   o When you're debugging a Windows application that uses the mouse
  491.     and you reset the application and then run the program, it won't
  492.     accept mouse clicks until you make a keyboard entry.
  493.  
  494.   o Using the mouse
  495.  
  496.     -  Most mice provide two or three buttons that allow for various
  497.        functions inside an application. With TDW you can, among other
  498.        things, use the left mouse button to select options, move items
  499.        around on the screen, and set breakpoints.
  500.  
  501.     -  Double-clicking the mouse on an item in a list chooses the item.
  502.        For instance, in the File|Open dialog box clicking the mouse once
  503.        just highlights a file. Double-clicking loads the file.
  504.  
  505.     -  The right mouse button has some of the same functionality as the
  506.        left mouse button, but you can also open local menus within TDW
  507.        windows by using this button.
  508.  
  509.   o You can also choose the commands shown at the bottom of the screen,
  510.     like F1-Help, by using the mouse.
  511.  
  512.  
  513. 4. TD mouse support
  514. -------------------
  515.   You use the mouse with TD just as you do with TDW. However, with
  516.   TD you must install a mouse driver, which makes your mouse active
  517.   with TD and other programs. Most mouse drivers will work with TD,
  518.   but might have to be updated to a newer version if you're having
  519.   problems using your current version. If you have problems with the
  520.   mouse after you've loaded TD or TDINST, you might try using the
  521.   Display Swap option that you can specify either in TDINST or on
  522.   the command-line with the -ds switch.
  523.  
  524.   Consult your mouse manual to ensure proper use of the mouse
  525.   and its driver. Early versions of mouse drivers don't support
  526.   screen display modes larger than 80 columns by 24 lines. As a
  527.   result, your mouse driver might not work correctly when you
  528.   use TD's enhanced display modes (EGA 80x43, VGA 80x50, or
  529.   EGA/VGA graphics modes).
  530.  
  531. /**************************** END OF FILE ********************************/
  532.  
  533.