home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 10 / 10.iso / l / l350 / 3.ddi / EXAMPLES / SB386 / DEBUG.SCR next >
Encoding:
Text File  |  1993-02-11  |  2.5 KB  |  95 lines

  1. * We will type G to run the program until it fails
  2. pause
  3. g
  4. * There seems to be a problem on line 198 of module kaboom1.
  5. * Let's look at BOARD's definition to check its size
  6. pause
  7. x board 
  8. * Ok, BOARD is 15 by 9
  9. * Let's check I and J to see if they might be out of range
  10. pause
  11. v i
  12. pause
  13. v j
  14. pause
  15. * The _are_ out of range, so it might be a problem with
  16. * the random number generation function.  Let's set the
  17. * source mode to mixed and then start back at line 196 and
  18. * step over a call to nRandom to see what value it returns.
  19. pause
  20. l #196
  21. src both
  22. pause
  23. p =#196
  24. pause
  25. p
  26. * We can see in the register window that the nRandom
  27. * routine returned a big number in EAX.  It was supposed to
  28. * be a number between 0 and 14.  The problem must lie
  29. * in that routine.  Let's bring up its source
  30. * code in the source window.
  31. pause
  32. src src
  33. pause
  34. l nRandom
  35. pause
  36. * We can't see the end of the line in nrandom.  We can use
  37. * the offset command to shift the source window to the left
  38. * by 8 characters.
  39. pause
  40. offset 8
  41. pause
  42. * That initialization of maxint to 0x7fff looks suspicious.
  43. * In 32-bit protected mode, ints are 32-bits wide so we appear
  44. * to have a portability problem.  In order to scale the return value
  45. * from the rand routine to between zero and one, we must divide
  46. * by 0x7fffffff, not 0x7fff.  Let's patch the value of maxint
  47. * to 0x7fffffff and start at line 196 again.
  48. pause
  49. ed $kab2bug.nrandom.maxint 0x7fffffff
  50. pause
  51. v $kab2bug.nrandom.maxint
  52. pause
  53. offset 0
  54. src both 
  55. pause
  56. p =$kaboom1#196 
  57. pause
  58. pause
  59. * Ok, the return code from nRandom in EAX looks good.
  60. * It looks like nRandom is working correctly now.  Let's
  61. * see if the program works now.  We'll switch the display
  62. * back to source mode let the program continue from here.
  63. pause
  64. src src
  65. pause
  66. g
  67. * Uh, oh.  We got a memory protection fault.  But where are
  68. * we?  Let's use the KA command to do a stack backtrace.
  69. pause
  70. ka
  71. pause
  72. * There appears to be a problem in the DisplayChar routine.
  73. * Our arguments look good, though.  Let's look at the value
  74. * of the cPos pointer to see if it is valid.
  75. pause
  76. v cPos
  77. pause
  78. * There is the problem!  A segment selector value of B800
  79. * is illegal in protected mode.  We should instead use selector
  80. * 001C to reference the screen memory.
  81. pause
  82. * We can patch the scr_sel variable to 001C.
  83. pause
  84. ew scr_sel 1c
  85. pause
  86. v scr_sel
  87. pause
  88. * Let's continue starting back at line #96 and see if the
  89. * program works now.
  90. pause
  91. g =#96
  92. * Ok, we are all done.  You can terminate the debugging session
  93. * with the Q command.
  94.