home *** CD-ROM | disk | FTP | other *** search
- ErrTrace - a unit for TurboPascal v4.0 to display an error traceback
- information.
-
- Author : Michal Jankowski <sieminski@rzsin.sin.ch>
- <sieminski%rzsin.sin.ch@cernvax> (Bitnet)
-
- Program Version : 1.0 1988.09.16
- Document Version : 1.1 1988.10.06
- ------------------------------------------------------------------------------
-
- If your TurboPascal program stops due to runtime error, all you get from
- Turbo is error message and address. There is no traceback information -
- if that error was in a procedure or function some 10 levels deep and
- used in 20 different places in your program, you have no way of answering
- simple question 'Where was this function called from?'.
- Even debuggers (like T-DebugPLUS) will not help you here.
- My solution to this problem is a small unit (written entirely in Pascal),
- which you can use in any TurboPascal program. Afterwards all errors
- result in a message like this:
-
-
- Runtime error 200 at 0013:002F <- 1
- Division by zero <- 2
- Traceback <- 3
- F Procedure at 0013:0000 Called from 0000:004F <- 4
- N Procedure at 0000:0014 Called from 0000:0082 <- .
- N Procedure at 0000:0014 Called from 0000:0082 <- .
- N Procedure at 0000:0014 Called from 0000:0116 <- N
-
-
- Addresses in this table correspond exactly to that in .MAP file
- produced by TPMAP, so you can easily find all information you need.
- The so-called 'normalized pointers' returned by all 80x87 errors
- are properly adjusted.
-
- Line 1 : Error number and location (adjusted if necessary)
- Line 2 : Full error message
- Line 3 : Header
- Lines 4..N : Traceback information
- col 1 : 'F' for far (iter-unit) calls
- 'N' for near (intra-unit) calls
- (intra-unit call have 'N' even if compiled with
- $F+ in effect)
- cols 16..24 : address of procedure/function in traceback chain
- You can find the name of that procedure in
- .MAP file.
- cols 38..46 : address of 'call' instruction (it is always
- somewhere in procedure/function specified in next
- line). You can find the source line of this
- instruction in .MAP file.
-
- ------------------------------------------------------------------------------
- Usage:
-
- 1. Compile ERRTRACE.PAS to ERRTRACE.TPU (you can use precompiled unit)
- 2. Just 'use' it in your program:
-
- Program Test;
- uses ErrTrace;
- .
- .
- .
-
- 3. Compile program to disk and run it (ErrTrace works also if you compile
- to memory, but segments do not correspond to .MAP file)
-
- ------------------------------------------------------------------------------
-
- If you use any other units, ErrTrace should be specified first. There are
- two reasons for it:
- 1. It will catch and trace errors in initialization parts of other units;
- 2. If you use a graphics unit, you can install an exit procedure to restore
- text mode on your screen. If ErrTrace is 'used' first, it is executed
- last, so its output will be in text mode.
-
- ------------------------------------------------------------------------------
-
- There is a boolean flag you can access anywhere in your program as
- 'ErrTrace.Continue'.
- It is 'false' by default, which means that ErrTrace will halt your program
- after displaying traceback information.
- If you change it to 'true', your program will print the default TurboPascal
- error message (and also execute remaining exit procedures in chain, if
- ErrTrace was not 'used' as a first unit - not recommended).
- Its main use is to allow TurboPascal to point you to exact location of error
- in the source file.
-
- ------------------------------------------------------------------------------
-
- This program has to look for the traceback information on the stack,
- and it is possible (but highly unlikely) that some data on the stack may
- look like the traceback information and confuse ErrTrace, causing it
- to produce improper traceback.
-
- ------------------------------------------------------------------------------
-
- Any questions, bug reports and suggestions are welcome.
-
- ------------------------------------------------------------------------------