home *** CD-ROM | disk | FTP | other *** search
/ Collection of Hack-Phreak Scene Programs / cleanhpvac.zip / cleanhpvac / SICE-DOC.ZIP / DOC-TXT.ZIP / CHAP11 < prev    next >
Text File  |  1992-05-24  |  14KB  |  369 lines

  1.  
  2.    SECTION III - Advanced Topics
  3.  
  4.    CHAPTER 11
  5.  
  6.  Advanced Features
  7.    11.1 Using Soft-ICE with other Debuggers
  8.    11.1.1 Debuggers that Use DOS
  9.    11.1.2 ACTION Command with other Debuggers
  10.    11.1.3 Special Considerations
  11.    11.1.4 Using Soft-ICE with CODEVIEW
  12.    11.1.5 Debuggers that Use 80386 Break Point
  13.                          Registers
  14.    11.2 User-Qualified Break Points
  15.    11.2.1 Example of a User-Qualified Break Point
  16.    11.3 The Window in Graphics Mode
  17.    11.4 Expanded Memory Debugging Features
  18.    11.5 Extended Memory Debugging Features
  19.  
  20.      209
  21.  
  22. 11.1 Using Soft-ICE with other Debuggers
  23.  
  24. Soft-ICE was designed to work well with other debuggers. Each debugger
  25. offers different features, and therefore can require special treatment.
  26. This section will describe some ways to use several debuggers effectively.
  27.  
  28. 11.1.1 Debuggers that Use DOS
  29.  
  30. Many debuggers use DOS and ROM BIOS to perform their display and keyboard
  31. I/O. Special consideration must be taken when using these debuggers with
  32. Soft-ICE (e.g., DEBUG, SYMDEB, and CODEVIEW), because DOS and ROM BIOS are
  33. not fully re-entrant. If a break point occurs while code is executing in
  34. DOS or BIOS, a re-entrancy problem can occur.
  35.  
  36. Soft-ICE provides optional re-entrancy warning, which is activated with
  37. the WARN command. When WARN mode is on, Soft-ICE checks for DOS or ROM
  38. BIOS re-entrancy before generating the ACTION that wakes up the host
  39. debugger. When a re-entrancy problem is detected, Soft-ICE displays a
  40. warning message and offers you the choice of continuing to execute the
  41. code or returning to Soft-ICE.
  42.  
  43. Note that Soft-ICE itself does not use DOS or ROM BIOS calls in its
  44. debugging commands. This means that you can use Soft-ICE any time, without
  45. the worry of re-entrancy problems.
  46.  
  47. For more information on the WARN command, see section 5.4.
  48.  
  49. 11.1.2 ACTION Command with other Debuggers
  50.  
  51. Different debuggers use different methods of activation For a description
  52. of these methods see section 13.1.
  53.                                                     
  54.  
  55.      210 
  56.  
  57. If you want to return to your debugger after a break point reached, you
  58. must change the ACTION (see section 5.4) to work with your debugger.
  59.  
  60. In most cases, the action that should be taken after a break point is
  61. reached is INT3. For instance, DEBUG and SYMDEB will work best with ACTION
  62. set to INT3.
  63.  
  64. If INT3 doesn't work with your debugger, try INT1 or NMI. CODEVIEW works
  65. best with ACTION set to NMI.
  66.  
  67.  11.1.3 Special Considerations
  68.  
  69. When a break point is set, you must be careful not to set off the break
  70. point unintentionally. For instance, if you set a memory break point at
  71. 0:0, then use your debugger to dump memory location 0:0, Soft-ICE will be
  72. triggered. If ACTION is set to go to your debugger, then your debugger
  73. will be triggered by itself. Since some debuggers cannot be re-entrant,
  74. this could be a fatal problem. This problem can also occur with other
  75. debugging functions, such as editing or unassembling.
  76.  
  77. For this reason, it is a good practice to disable the Soft-ICE break
  78. points once Soft-ICE has helped you get to the point where you want to
  79. look around with your debugger.
  80.  
  81.  11.1.4 Using Soft-ICE with CODEVIEW
  82.  
  83. Soft-ICE works best with CODEVIEW when CODEVIEW is either in Assembler
  84. mode or Mixed mode. When CODEVIEW is in Source mode with higher-level
  85. languages it does not always break correctly.
  86. It is always best to use ACTION NMI when you want Soft-ICE to wake up
  87. CODEVIEW.
  88.  
  89.      211 
  90.  
  91. 11.1.5 Debuggers that Use 80386 Break Point Registers
  92.  
  93. The 80386 has 4 break point registers that are available for use by
  94. debuggers. Soft-ICE uses these for its memory byte, word and double word
  95. break points. If the debugger you are using Soft-ICE with uses these debug
  96. registers there will be a conflict. There are two ways to handle this
  97. problem.
  98.  
  99.     1. Disable the use of 80386 break point registers in the
  100.         debugger you are using Soft-ICE with. Check the
  101.         documentation of your other debugger for a
  102.         description of how to do this.
  103.     2. Some debuggers automatically use the break point
  104.         registers if they detect an 80386 processor with no
  105.         method of turning them off (some versions of
  106.         SYMDEB do this). For these debuggers do the
  107.         following:
  108.         * Bring up the Soft-ICE window before you start
  109.             the other debugger.
  110.         * Turn on Soft-ICE's break mode with the
  111.             BREAK command (you may want to do this in
  112.             the INIT statement of S-ICE.DAT if you are
  113.             doing this frequently).
  114.         * Start up your other debugger.
  115.         * You may now pop up the Soft-ICE window and
  116.             turn the Soft-ICE break mode off if desired.
  117.  
  118. 11.2 User-Qualified Break Points
  119.  
  120. Occasionally you may have the need for a very specific set of break point
  121. conditions. If the special conditions require qualifying register values
  122. or memory values, you can write a break point qualification routine.
  123.  
  124.      212 
  125.  
  126. Soft-ICE contains a very general mechanism for calling user-written break
  127. point qualification routines: the ACTION command. When you use the ACTION
  128. command, Soft-ICE can route all break points through special interrupt
  129. vector. However, before break points can be routed, the qualification
  130. routine must be placed in memory, and the interrupt vector must be
  131. pointing to the qualification routine.
  132.  
  133. All registers are identical to the values when the Soft-ICE break point
  134. occurred. It is the responsibility of the qualification routine to save
  135. and restore the registers. If your qualification routine detects a match
  136. of break point conditions, it can do a variety of activities. Some
  137. examples of useful activities that a routine can do when a match is found
  138. are:
  139.  
  140.     * store information for later
  141.     * send the information directly to a printer or serial
  142.         terminal
  143.     * issue an INT 3 instruction to bring up Soft-ICE
  144.         The command 13HERE must be turned on in order
  145.         for the INT 3 to bring up Soft-ICE (see section 5.4).
  146.  
  147. If conditions do not match, the qualification routine in should execute an
  148. IRET instruction. To summarize:
  149.  
  150.     1. Create a break point qualification routine in your
  151.         code space, or anywhere in free memory. The
  152.         routine must preserve registers. After comparing
  153.         the desired conditions, the routine can execute
  154.         either an INT 3 to bring up Soft-ICE, or an IRET
  155.         to continue.
  156.     2. Point an unused interrupt vector to your
  157.         qualification routine. This can be done either
  158.         within your code or from Soft-ICE.
  159.  
  160.      213
  161.  
  162.    3. In Soft-ICE, set ACTION to the interrupt- number
  163.         that was used to point to your qualification routine.
  164.    4. In Soft-ICE, set 13HERE on. This is necessary to
  165.         bring up Soft-ICE after the conditions have been
  166.         met.
  167.    5. Set the Soft-ICE general break point conditions.
  168.         When any of these break point conditions are met,
  169.         your qualification routine will be called.
  170.  
  171.  
  172.  11.2.1 Example of a User-Qualified Break Point
  173.  
  174. This section contains an example of a user-qualified break point that
  175. compares for the conditions of U = 3, BX = 4 and CX = 5 when a break point
  176. goes off.
  177.  
  178. First, we create the qualification routine. For the purposes of this
  179. example, we will assemble the command directly into memory with the Soft-
  180. ICE interactive assembler. For this example we will arbitrarily assemble
  181. the routine at location 9000:0H. The following statements are entered into
  182. Soft-ICE:
  183.  
  184.    A 9000:0
  185.    9000:0 CMP AX,3
  186.    9000:3 JNE 10
  187.    9000:5 CMP BX,4
  188.    9000:7 JNE 10
  189.    9000:A CMP CX,5
  190.    9000:D JNE 10
  191.    9000:F INT3
  192.    9000:10 IRET
  193.  
  194. Now that the routine is in memory, you must point an interrupt vector to
  195. the routine. For this example, we arbitrarily pick INT 99H. To place
  196. 9000:0H in the INT 99H vector enter:
  197.  
  198.    ED 0:99*4 9000:0
  199.  
  200.      214 
  201.  
  202. Set the ACTION command so that Soft-ICE will call your break point
  203. qualification routine on every break point.
  204.  
  205.    ACTION 99
  206.  
  207. Set 13HERE on so the qualification routine can activate Soft-ICE when the
  208. conditions occur.
  209.  
  210.   13HERE ON
  211.  
  212. Now you need to set the break points. For this example, we are just
  213. interested when the registers are: U = 3, BX = 4, CX = 5 in a specific
  214. program, and we do not want any further qualification. To do this, use a
  215. range break point on memory read:
  216.  
  217.     BPR segment:starting-offset segment:ending-offset
  218.  
  219. This will cause your break point qualification routine to be called after
  220. every instruction is executed in the specified memory range. When the
  221. register conditions do not match, then the IRET instruction is executed.
  222. When the conditions finally match the specified qualifications, the INT 3
  223. is executed and Soft-ICE is popped up.
  224.  
  225. When Soft-ICE pops up, the instruction pointer will be pointing at the
  226. INT3 in your qualification routine (9OOO:FH in our example). To get to the
  227. instruction after the one that caused the break point, you must change the
  228. instruction pointer to point to the IRET instruction (F000: 10H in the
  229. example) and single step one time. This is accomplished with the following
  230. Soft-ICE commands
  231.  
  232.    RIP IP + 1
  233.    T
  234.  
  235. After your break conditions have gone off, remember to change the ACTION
  236. command back to ACTION HERE that subsequent break points do not go through
  237. your qualification routine.
  238.  
  239.      215 
  240.  
  241. 11.3 The Window in Graphics Mode
  242.  
  243. The screen is switched to text mode when Soft-ICE is invoked. If the
  244. screen was in graphics mode or 40-column mode, the graphics display is not
  245. visible while the window is up. For users who must see the graphics
  246. display while debugging, three features are provided. The first feature
  247. allows the Soft-ICE window to display on a second monitor (see the ALTSCR
  248. command, section 5.9). The second feature allows you to restore the screen
  249. while you are doing P or T instruction step commands (see the FLASH
  250. command, section 5.9). The third feature allows you to restore the program
  251. screen temporarily (see the RS command, section 5.9).
  252.  
  253. If Soft-ICE does not seem to be following your program into graphics mode,
  254. try turning WATCHV on (see section 5.9 for details).
  255.  
  256.  11.4 Expanded Memory Debugging Features
  257.  
  258. A range break point or a break point on memory that is set in an EMM
  259. mappable area will stay at that address no matter which EMM page is mapped
  260. in.
  261.  
  262. When debugging EMM programs, the EMMMAP command may also be very useful.
  263. See section 5.6 for more information.
  264.  
  265. The D, E, S, F, and C commands can be used to view or modify any allocated
  266. EMM handle page. The page does not have to be currently mapped in. The
  267. syntax of these commands is similar to that of the commands when being
  268. used for non-EMM pages, except for the following:
  269.     * In the D, E, S, and F commands, the address
  270.        portion of the command must be specified in the
  271.        following way:
  272.        Hhandle# Ppage# offset
  273.  
  274.      216
  275.  
  276.       where handle is a number specifying which EMM
  277.       handle to use, page is a number specifying which
  278.       EMM page to use, and offset is a number from 0 to
  279.       4000H, specifying the offset from the beginning of
  280.       the page.
  281.       Example:
  282.  
  283.       DB H1 P3 0
  284.  
  285.       This command will dump bytes from page 3 of
  286.       handle 1, starting at offset 0.
  287.  
  288.    * The C command must be specified in the following
  289.       way:
  290.  
  291.       C Hhandle# Ppage# offset1 L length offset2
  292.  
  293.       where handle and page are the same as above.
  294.       offset1 is a number from 0 to 4000H, specifying the
  295.       offset from the beginning of the page, where the
  296.       first data block to be compared is located.
  297.       offset2 is a number from 0 to 4000H, specifying the
  298.       offset from the beginning of the page, where the
  299.       second data block to be compared is located.
  300.       Example:
  301.  
  302.       C H2 P4 00 L10 1000
  303.  
  304.       This command will compare the first 10 bytes of
  305.       memory located at offset 0 of page 4 of handle 2
  306.       with the first 10 bytes of memory located at offset
  307.       1000 of page 4 of handle 2.
  308.  
  309. Note:
  310. Subsequent uses of the D, E, S, F, and C commands will continue to use the
  311. handle and page last specified. To get back to conventional memory, use
  312. one of the above
  313.  
  314.      217 
  315.  
  316. commands with a segment specified in the address field, for example:
  317.           D 0:0
  318.  
  319. 11.5 Extended Memory Debugging Features
  320.  
  321. The D, E, S, F, and C commands can be used to view or modify extended
  322. memory. Extended memory reserved by Soft-ICE can not be displayed. The
  323. syntax of these commands is similar to that of the commands when being
  324. used for conventional memory:
  325.  
  326.     * In the D, E, S, and F commands, the address
  327.        portion of the command must be specified in the
  328.        following way:
  329.        M megabyte address
  330.        where megabyte is a number specifying which
  331.        megabyte to use, and address specifies the address
  332.        in the specified megabyte.
  333.        Example:
  334.        DB M 2 0:0
  335.        This command will dump bytes from start of the
  336.        megabyte starting at linear address 200000H.
  337.    * The C command must be specified in the following
  338.        way:
  339.        C M megabyte address1 L length address2
  340.        where megabyte and address1 are the same as above.
  341.        address2 specifies the address in the specified
  342.        megabyte, where the second data block to be
  343.        compared is located.
  344.  
  345.      218 
  346.  
  347.        Example: 
  348.  
  349.        C M 3 1000:2000 L10 3000:4000
  350.  
  351.        This command will compare the first 10 bytes of
  352.        memory located at 1000:2000 with the first 10 bytes
  353.        of memory located at 3000:4000.
  354.  
  355. Note:
  356. Subsequent uses of the D, E, S, F, and C commands will continue to use the
  357. last megabyte specified. To get back to megabyte 0 (conventional memory),
  358. use one of the above commands with 0 specified as the megabyte, for
  359. example:
  360.  
  361.    D M 0
  362.  
  363.      219
  364.  
  365.  Page 220 is BLANK
  366.  
  367.      220
  368.  
  369.