By
default, if a program includes the ON
statement or has been compiled with the +fp_exception
option, a procedure traceback is produced for any error that causes
the program to abort. (This option is described in Chapter 13.)
You can use the traceback information when debugging. For example,
the following traceback,
( 0) 0x0000203c subr + 0x98 [./a.out] |
( 1) 0x00001f4c main + 0x74 [./a.out] |
identifies the absolute address of the faulting instruction
(0x0000203c),
the name of the procedure (subr)
that contains the instruction and the instruction's offset
(0x98) within
the procedure, and the name of the executable.
But you may wish to allow a core dump
for one or more signals for a program that includes the ON
statement. To do so, you must revise the program to restore the
default behavior for each signal. For example, you may wish to handle
floating-point conditions with the ON
statement, but still allow a core dump to be generated for other
signals (for example, a bus error).
The
following program uses the libU77
signal routine to reset the default behavior for a bus error signal.
The program uses the ON
statement to handle floating-point conditions, but allows a core
dump when a bus error occurs:
POINTER (ip, d) !Cray-style pointer |
! Set the action for bus error to be the default |
! (DUMP CORE). This overrides the action of |
! generating a procedure traceback that is |
! established by using the ON statement. |
sigrtn = SIGNAL(sigbus, 0, sigdfl) |
! The next statements cause a real overflow |
! Bus error is caused by the next statements |
ip = ip + 4 ! ip is now 4-byte aligned |
Use the following command line to compile this program: