home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / sharew / a86 / deb_doc / d05.doc < prev    next >
Encoding:
Text File  |  1988-01-14  |  9.4 KB  |  205 lines

  1. CHAPTER 5   COMMAND LANGUAGE
  2.  
  3. In addition to immediate-execution assembly language commands,
  4. there is a set of commands recognized by the debugger.  They are
  5. identified by the first keyword on the line being a single letter
  6. (i.e., the second character of the line is a non-letter, usually
  7. a comma or ENTER).
  8.  
  9.  
  10. General Operands to Debugger Commands
  11.  
  12. Most of the debugger commands consist of their single-letter
  13. identifier, followed by a comma, followed by one or more general
  14. operands, separated by commas.  General operands can be one of
  15. the following:
  16.  
  17.    a. a numeric constant, whose format is just as in the assembly
  18.       language (leading zero means default hex, otherwise default
  19.       decimal)
  20.  
  21.    b. a register name
  22.  
  23.    c. a user symbol from the assembly language program being
  24.       debugged.
  25.  
  26.  
  27. Format of Debugger Command Examples
  28.  
  29. Many of the examples given below will be given in double quotes.
  30. Note that the double quotes are not part of the command.  You are
  31. encouraged to try out the example on the debugger, by typing the
  32. string within the quotes, not including the quotes, and always
  33. followed by the ENTER key. Note further that the double-quoted
  34. string may be broken across two lines of this manual, but that
  35. does not mean you should type a ENTER where the string is broken
  36. --debugger commands always consist of a single line, always
  37. terminated by ENTER.
  38.  
  39.  
  40. The Debugger Command Set
  41.  
  42. Following is a description of the debugger commands recognized:
  43.  
  44. B  sets and clears the fixed breakpoints of the program.  The
  45.    debugger has four breakpoints.  Two are transitory; they are
  46.    automatically cleared after each return from the program to
  47.    the debugger.  They can be set by the G command. The other two
  48.    are fixed-- they will remain in effect until you explicitly
  49.    clear them.  The fixed breakpoints are controlled by this B
  50.    command.
  51.  
  52.    You follow the B with zero, one, or two general operands.  If
  53.    there are zero operands (the B is followed immediately by a
  54.    ENTER), then both fixed breakpoints are cleared.  If there are
  55.    one or two operands, then the fixed breakpoints are set to the
  56.    operands.
  57.                                                               5-2
  58.  
  59.    Note that previously-set breakpoints can be implicitly
  60.    cleared, by overwriting them with other breakpoints.  If your
  61.    B command has one operand, and there was one breakpoint
  62.    previously set, the debugger sets the unused breakpoint, so
  63.    that both remain in effect.  If your B command has one
  64.    operand, and both breakpoints were previously set, the most
  65.    recently set breakpoint is saved, and the older breakpoint is
  66.    overwritten.
  67.  
  68.    The status screen, displayed by typing Ctrl-S, shows you the
  69.    B-command breakpoints in effect.
  70.  
  71.    Examples: if you type "b,numout", the debugger will set a
  72.    breakpoint at location NUMOUT, which should be a label in the
  73.    program being debugged. You may start and stop the program
  74.    many times, and the breakpoint will stay there.  You may even
  75.    allow the program to stop at NUMOUT repeatedly; the breakpoint
  76.    is not cleared even if the program stops there.  If you
  77.    subsequently type the command "b,01000", then there will be
  78.    breakpoints at both NUMOUT and location hex 01000.  If you
  79.    then type "b,01200", the first breakpoint NUMOUT is
  80.    overwritten; the two breakpoints now in effect are 01000 and
  81.    01200.  The 01000 breakpoint will be next in line to be
  82.    overwritten.  You may clear both breakpoints by typing "b".
  83.    There is no way to clear one breakpoint at a time.
  84.  
  85.  
  86. F  finds a string of memory bytes.  The memory to be searched
  87.    starts at the current CS:IP location.  The string being sought
  88.    is contained in memory at the CS:IP location marked with the
  89.    last Shift-F7 command.  The number of bytes in the target
  90.    string is given as the first operand to the F command.  For
  91.    example, "F,1" finds the next instance of a single byte value
  92.    after the current CS:IP.  If the marked location points to a
  93.    NOP, "F,1" will find the next NOP code.
  94.  
  95.    If you provide a second operand to F, it is a "retreat
  96.    number".  For example, "F 2,10" assumes that you are looking
  97.    for a 2-byte sequence, and you have retreated 10 bytes from
  98.    the starting location for your search.  When the string is
  99.    found, F will retreat 10 bytes from that string.  That way you
  100.    can view the instructions that preceded the found string.  I
  101.    use this feature when I am searching for BIOS and DOS
  102.    interrupt calls in a program.  I want to retreat before the
  103.    calls, to see what function numbers were loaded into
  104.    registers.  I can use the F3 key to repeat the searches,
  105.    giving me a sequence of disassembly displays with the
  106.    interrupt in the middle.
  107.  
  108.    F with no operands returns CS:IP to the marked location, in
  109.    case you want to use F7 to deposit another string to be
  110.    searched.
  111.  
  112.    If you have never pressed Shift-F7 in this session, the marked
  113.    location is 0C000 of the program's starting segment.  That's
  114.    often a good "scratchpad" area for small programs, far from
  115.    both the program and the stack.
  116.                                                               5-3
  117.  
  118. G  starts the user program.  You can give one or two operands to
  119.    G, specifying locations within the program at which you wish
  120.    to return to the debugger.  These are "transitory
  121.    breakpoints"; both of them are cleared when the program
  122.    returns to the debugger for any reason.
  123.  
  124.    Whenever you start the program, at least one instruction from
  125.    the program will be executed, even if there is a breakpoint at
  126.    the current instruction pointer location.  This means you can
  127.    set a breakpoint at the current location; instructing the
  128.    program to return to the debugger the next time it gets back
  129.    to the current location.
  130.  
  131.  
  132. J  jumps to the location indicated by the operand, within the
  133.    current code segment.  J is useful when you are exploring
  134.    memory outside of your program's memory area.  In that case,
  135.    the immediate JMP command is executed from a buffer within
  136.    your program's original code segment.  JMP would therefore
  137.    return you to that segment.  J will keep you in the distant
  138.    segment.
  139.  
  140.  
  141. L  creates a disassembly listing, with addresses, hex bytes, and
  142.    disassembled code.  You can output either the entire COM
  143.    program, or a section of memory beginning with the current
  144.    CS:IP location.  You omit the first operand if you want the
  145.    entire COM program.  If you want a section of memory, you
  146.    provide the offset beyond the memory section as the first
  147.    operand.  You give the name of the output file for the listing
  148.    as the second operand.  If you omit the second operand, the
  149.    listing goes to the printer.  Examples: L,,FOO.LST outputs the
  150.    entire COM program to FOO.LST.  L,0200,SEG.LST outputs the
  151.    section of memory from CS:IP up to CS:0200 to SEG.LST.
  152.  
  153.  
  154. O  sets a special fixed breakpoint.  Whenever your program calls
  155.    MSDOS via INT 021, the debugger will monitor the function
  156.    number passed in the AH register.  If the function number
  157.    falls within the range specified by this command, the program
  158.    will trap back to the debugger.  If you give two operands to
  159.    O, the operands are the lower and upper bounds for the range
  160.    of trapped functions.  If you give one operand, only that
  161.    function number will be trapped.  If you give no operands, any
  162.    previous O-trap setting is cleared.
  163.  
  164.    For example, note that function 3F hex is the READ function
  165.    for MSDOS version 2.  If you want to trap whenever this READ
  166.    function is invoked, you can issue the command O,03F and then
  167.    start up your program with the G command.  Another example:
  168.    suppose you want to insure that a program does not make any of
  169.    the new Version 3 DOS calls, 59 hex and above.  You can issue
  170.    the command O,059,0FF and then start your program.
  171.                                                               5-4
  172.  
  173.    NOTE: if the second operand is less than the first, then the
  174.    range wraps around through zero.  For example, O,059,030 traps
  175.    on 059 through 0FF, and also 0 through 030-- both version 3
  176.    and version 1 calls.
  177.  
  178.    SECOND NOTE: The EXIT function, hex 4C is always trapped by
  179.    D86, regardless of your O-command settings.  The only way you
  180.    should be able to exit from D86 is via the Q-command.  (If you
  181.    do succeed in exiting some other way, I want to hear about it.
  182.    In that case, D86 will become very confused if you reinvoke it
  183.    before rebooting the computer.)
  184.  
  185.  
  186. Q  exits the debugger and goes back to the operating system.
  187.  
  188.  
  189. W  writes the program (if it was a COM format) and the symbol
  190.    table back to the disk.  In this present version, you don't
  191.    have any options as to what to name the files.  The program
  192.    name given when D86 was invoked is always used, except that
  193.    the files are always written to the current directory.  The
  194.    program file has the same extension as the file that was
  195.    loaded, and the symbols file has the SYM extension.
  196.  
  197.    D86 writes the program from location 0100 in the original code
  198.    segment, up to the end-of-file location saved when the program
  199.    was loaded, and possibly extended by a patch-memory operation
  200.    while at the end of the program.  Any symbols added while in
  201.    the patch-memory mode are saved in the symbols file, so that
  202.    you can "reverse engineer" programs for which you do not have
  203.    source, and save the symbol table results you have gleaned.
  204.  
  205.