home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / PROG / PASCAL / ERROR87.ZIP / ERROR87.DOC < prev    next >
Encoding:
Text File  |  1990-08-15  |  5.3 KB  |  133 lines

  1. ERROR87 1.1 - Turbo Pascal units to improve coprocessor error reports.
  2.  
  3. Copyright (c) 1990, D.J. Murdoch.  All rights reserved.
  4.  
  5. Portions of DECODE87.PAS copyright 1985,86, L. David Baldwin.
  6.  
  7. INTRODUCTION
  8.  
  9. Turbo Pascal 5.5 doesn't handle floating point errors well.  The 
  10. number of errors that are reported as run-time "Error 207" is large, 
  11. and often the error address is miscalculated, so you don't have a clue 
  12. where to look for them.  ERROR87 is a unit that attempts to address 
  13. both of these problems - it gives more informative error messages, and 
  14. it tries to improve on the calculation of the error address.
  15.  
  16. METHOD
  17.  
  18. The ERROR87 unit doesn't interface anything.  When you use it, it 
  19. patches the loaded copy of the system library, and installs an exit 
  20. procedure that looks for run-time coprocessor errors.  (It does the 
  21. patch in memory; it won't affect the copy of the library that's on 
  22. disk, or the executable file on disk.)
  23.  
  24. When an error occurs, transfer is passed to the ERROR87 exit 
  25. procedure.  If the error was an "Invalid Floating Point Operation", 
  26. i.e. run-time error 207, ERROR87 springs into action.  First, it saves 
  27. the state of the coprocessor in memory.  (The patch to the system 
  28. library was to prevent it from clearing the coprocessor's registers 
  29. before ERROR87 could get a look at them.)  Then, it dissects the 
  30. state record to try to work out the cause of the error.  
  31.  
  32. The first part of the post-mortem is to decode the instruction, using 
  33. code based on L. David Baldwin's excellent UNINLINE disassembler.  
  34. It then looks at the coprocessor's record of which instruction caused 
  35. the error, to see if TP has given the wrong error address.   Finally,  
  36. it proceeds through tests of what I think are the most likely causes 
  37. of invalid operations:  
  38.  
  39.   - taking the square root of a negative
  40.   - dividing 0/0
  41.   - overflowing the stack by recursive calls, or very complicated 
  42.     expressions
  43.   - operating on NaNs ("Not a Number"s), probably because variables 
  44.     weren't properly initialized, or a library routine like ln() has
  45.     been passed a negative number
  46.   - underflowing the stack, by a bug in assembler or inline code
  47.  
  48. It prints a message describing the error, and passes control on to the 
  49. next exit procedure.
  50.  
  51.  
  52. LIMITATIONS
  53.  
  54. ERROR87 adds several kilobytes to the size of the program, and writes 
  55. messages to the standard output device, so you would probably only 
  56. want to use it while debugging.  
  57.  
  58. TP calculates the trunc() function in a funny way.  ERROR87 will often 
  59. be unable to recognize the error if the truncation overflows.
  60.  
  61. It doesn't know the code segment of an instruction, only the linear 
  62. address.  If TP can't find the instruction based on the pointer given 
  63. by ERROR87, you'll have to generate a .MAP file, figure out which 
  64. segment the address is in, and manually adjust the value for TP.  For 
  65. example, if the program dies with the messages
  66.  
  67.  Operand is not a number!
  68.  Runtime error 207 at 0000:46E3.
  69.  
  70. and TP can't find location 0000:46E3, take a look at the link map:
  71.  
  72.  Start  Stop   Length Name               Class
  73.  
  74.  00000H 0008CH 0008DH TEST               CODE
  75.  00090H 00ABEH 00A2FH ERROR87            CODE
  76.  00AC0H 0135FH 008A0H DECODE87           CODE
  77.  01360H 04927H 035C8H SYSTEM             CODE   <--- it's in here!
  78.  04930H 073B9H 02A8AH DATA               DATA
  79.  073C0H 0B3BFH 04000H STACK              STACK
  80.  0B3C0H 0B3C0H 00000H HEAP               HEAP
  81.  
  82. From this map it's clear that one of the system routines had the 
  83. error, and there's not much you can do to find it.  (This example 
  84. tried to calculate ln(-1).)  If it had turned out to be in one of your 
  85. units, you could ask the compiler to find it by looking for the 
  86. address 0136:3383, i.e. (start div $10):(reported address - start).
  87.  
  88. CONTENTS OF PACKAGE
  89.  
  90. In this package, you should find the following files:
  91.  
  92.  ERROR87.DOC  - this file
  93.  ERROR87.PAS  - source code to the error handling unit
  94.  DECODE87.PAS - source code used to decode the instructions
  95.  DV87.ZIP     - a little TSR to fix a bug in Desqview 2.26 that 
  96.                 crashes windows on coprocessor errors 
  97.  NMI.ZIP      - a little program to turn on NMI handling on XT clones,
  98.                 so that they don't crash on coprocessor errors 
  99.  
  100.  
  101. REGISTRATION
  102.  
  103. ERROR87 is shareware.  That means you can try it out for free, but if 
  104. you find that it helps you and you want to keep it, you must register.  
  105. Registration is only $10; send a cheque or money order for that amount 
  106. in Canadian or U.S. funds to
  107.  
  108.  D.J. Murdoch
  109.  79 John St W
  110.  Waterloo, Ontario, Canada,
  111.  N2L 1B7.
  112.  
  113. I'll answer technical questions from registered users, if they're 
  114. mailed to me at the above address, or by email to me at
  115.    
  116.  dmurdoch@watstat.waterloo.edu on Internet
  117.  DJ Murdoch at node 1:221/177.40 on Fidonet
  118.  71631,122 on Compuserve
  119.  
  120. I'd like bug reports from you even if you don't register.
  121.  
  122. The unit DECODE87 is closely based on L. David Baldwin's UNINLINE 
  123. program.  I release my contributions to it to the public domain, but 
  124. the actual decoding remains under his copyright.  He has released it 
  125. for free non-commercial use.
  126.  
  127. RELEASE HISTORY
  128.  
  129. 1.1 - August 1990 - added detection of trunc() and round() overflows 
  130.                     that I forgot in 1.0
  131. 1.0 - August 1990 - Initial release
  132.  
  133.