Error trapping for multiprocessor systems: A primer
last update: 04/18/2003

Tracing SIGTRAP events

This section explains how to use the SIGTRAP handlers -qflttrap and -qsigtrap. These FPE event handlers are easiest to use, are sufficient for most applications, and produce the smallest performance penalty for most codes.

Two stages of tracing SIGTRAP events are available: one that identifies which exceptions to trap (-qflttrap), and one that identifies a piece of code that will be called to handle the trapped exceptions (-qsigtrap). If -qsigtrap isn't used, the default behavior for trapped exceptions identified by -qflttrap is to dump core and exit.

The -qflttrap option for compile and load statements (SIGFPE)

This compiler parameter sets the up to seven options defined earlier to generate SIGFPE events. The following example sets all seven plus the enable for SIGTRAP. The options are shown here in their abbreviated form. The -qflttrap option should be included on both the compile and the load statements to ensure that the traps are enabled.

-qflttrap=OV:UND:ZERO:INV:INEX:IMP:EN

The -qsigtrap option for compile and load statements (SIGTRAP)

The sigtrap exception handler by default uses the IBM xl__trcedump handler. It selects handlers other than the default handlers by naming the trap handler, for example: -qsigtrap=xl__trcedump. The set of SIGTRAP handlers provided by IBM include:

A detailed introduction to and specific procedures for trapping and handling FPEs is provided in SCD's IBM SP-cluster systems reference manual in the section Trapping floating-point exceptions (FPEs) with IBM's subroutine interface.

There are other specialized handlers documented in the XL Fortran User's Guide in the "XL Fortran Floating-Point Processing" chapter section on "Detecting and Trapping Floating-Point Exceptions," but they are for specialized uses and are not the subject of this primer.

The fp_trap library routine for trapping SIGFPE events at run time

You can directly trap SIGFPE events at run time, but you will have to use the fp__trap library routine, and your code usually runs significantly slower.

If you want to use the fp__trap library, see the "XL Fortran Floating-Point Processing" chapter in the IBM document XL Fortran for AIX User's Guide. The trap handler will write the trapped condition to your standard output. It tells you what line in the program/subprogram was trapped as well as the call stack trace.

The easy way to view this information is to call the TotalView debugger with the executable and the core file. This gives you all the trap information in a graphical presentation.

A detailed introduction to and specific procedures for trapping and handling FPEs is provided in SCD's IBM SP-cluster systems reference manual in the section Trapping floating-point exceptions (FPEs) with IBM's subroutine interface.


Next page | Table of contents - TotalView primer

If you have questions about this document, please contact SCD Customer Support. You can also reach us by telephone 24 hours a day, seven days a week at 303-497-1278. Additional contact methods: consult1@ucar.edu and during business hours in NCAR Mesa Lab Suite 39.

© Copyright 2003. University Corporation for Atmospheric Research (UCAR). All Rights Reserved.

Address of this page: http://www.scd.ucar.edu/docs/trap.error/sigtrap.html