home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / err_trap / errtrace / errtrace.doc next >
Encoding:
Text File  |  1988-10-06  |  4.4 KB  |  100 lines

  1. ErrTrace - a unit for TurboPascal v4.0 to display an error traceback
  2.            information.
  3.  
  4. Author : Michal Jankowski <sieminski@rzsin.sin.ch>
  5.                           <sieminski%rzsin.sin.ch@cernvax> (Bitnet)
  6.  
  7. Program Version  : 1.0  1988.09.16
  8. Document Version : 1.1  1988.10.06
  9. ------------------------------------------------------------------------------
  10.  
  11. If your TurboPascal program stops due to runtime error, all you get from
  12. Turbo is error message and address. There is no traceback information -
  13. if that error was in a procedure or function some 10 levels deep and
  14. used in 20 different places in your program, you have no way of answering
  15. simple question 'Where was this function called from?'.
  16. Even debuggers (like T-DebugPLUS) will not help you here.
  17. My solution to this problem is a small unit (written entirely in Pascal),
  18. which you can use in any TurboPascal program. Afterwards all errors
  19. result in a message like this:
  20.  
  21.  
  22. Runtime error 200 at 0013:002F                                <- 1
  23. Division by zero                                              <- 2
  24. Traceback                                                     <- 3
  25. F Procedure at 0013:0000 Called from 0000:004F                <- 4
  26. N Procedure at 0000:0014 Called from 0000:0082                <- .
  27. N Procedure at 0000:0014 Called from 0000:0082                <- .
  28. N Procedure at 0000:0014 Called from 0000:0116                <- N
  29.  
  30.  
  31. Addresses in this table correspond exactly to that in .MAP file
  32. produced by TPMAP, so you can easily find all information you need.
  33. The so-called 'normalized pointers' returned by all 80x87 errors
  34. are properly adjusted.
  35.  
  36. Line 1 : Error number and location (adjusted if necessary)
  37. Line 2 : Full error message
  38. Line 3 : Header
  39. Lines 4..N : Traceback information
  40.               col 1 : 'F' for far (iter-unit) calls
  41.                       'N' for near (intra-unit) calls
  42.                           (intra-unit call have 'N' even if compiled with
  43.                           $F+ in effect)
  44.               cols 16..24 : address of procedure/function in traceback chain
  45.                             You can find the name of that procedure in
  46.                             .MAP file.
  47.               cols 38..46 : address of 'call' instruction (it is always
  48.                             somewhere in procedure/function specified in next
  49.                             line). You can find the source line of this
  50.                             instruction in .MAP file.
  51.  
  52. ------------------------------------------------------------------------------
  53. Usage:
  54.  
  55. 1. Compile ERRTRACE.PAS to ERRTRACE.TPU (you can use precompiled unit)
  56. 2. Just 'use' it in your program:
  57.  
  58.    Program Test;
  59.    uses ErrTrace;
  60.    .
  61.    .
  62.    .
  63.  
  64. 3. Compile program to disk and run it (ErrTrace works also if you compile
  65.    to memory, but segments do not correspond to .MAP file)
  66.  
  67. ------------------------------------------------------------------------------
  68.  
  69. If you use any other units, ErrTrace should be specified first. There are
  70. two reasons for it:
  71. 1. It will catch and trace errors in initialization parts of other units;
  72. 2. If you use a graphics unit, you can install an exit procedure to restore
  73.    text mode on your screen. If ErrTrace is 'used' first, it is executed
  74.    last, so its output will be in text mode.
  75.  
  76. ------------------------------------------------------------------------------
  77.  
  78. There is a boolean flag you can access anywhere in your program as
  79. 'ErrTrace.Continue'.
  80. It is 'false' by default, which means that ErrTrace will halt your program
  81. after displaying traceback information.
  82. If you change it to 'true', your program will print the default TurboPascal
  83. error message (and also execute remaining exit procedures in chain, if
  84. ErrTrace was not 'used' as a first unit - not recommended).
  85. Its main use is to allow TurboPascal to point you to exact location of error
  86. in the source file.
  87.  
  88. ------------------------------------------------------------------------------
  89.  
  90. This program has to look for the traceback information on the stack,
  91. and it is possible (but highly unlikely) that some data on the stack may
  92. look like the traceback information and confuse ErrTrace, causing it
  93. to produce improper traceback.
  94.  
  95. ------------------------------------------------------------------------------
  96.  
  97. Any questions, bug reports and suggestions are welcome.
  98.  
  99. ------------------------------------------------------------------------------
  100.