Results 1 to 3 of 3
  1. #1
    How to trap fpu exceptions on macbook pro?

    Member Since
    Aug 03, 2004
    Posts
    39
    How to trap fpu exceptions on macbook pro?
    I can't get even a simple C++ code to trap fpu errors, no matter what combination of compile options or signal handling I attempt. Can anyone point me to some definitive documation on this? Thanks.

    #include <iostream>
    #include <cmath>
    #include <signal.h>


    int main()
    {
    signal(SIGFPE, exit);

    for (int i=0; i<10; i++) {
    double arg = -5 + i;
    double recip = 1. / arg;

    std::cerr << arg << " " << recip << std::endl;
    }
    }



    And here is the compile command with every possible non-optimization and fpu-related option that I could find, set to its pickiest setting:


    % cc junk.C -g -O0 -lc -lstdc++ -Wl,-m -Wl,-w -lm -fsignaling-nans -ftrapping-math -fno-unsafe-math-optimizations
    % ./a.out
    -5 -0.2
    -4 -0.25
    -3 -0.333333
    -2 -0.5
    -1 -1
    0 inf
    1 1
    2 0.5
    3 0.333333
    4 0.25


    The code should exit/crash prior to outputting the 6th line.

    Thanks.

  2. #2
    How to trap fpu exceptions on macbook pro?

    Member Since
    Aug 03, 2004
    Posts
    39
    Furthermore, I can't get this to work on PowerPC macs either. So any help even getting this to go for non-intel mac would be much appreciated. Thanks.

  3. #3
    How to trap fpu exceptions on macbook pro?

    Member Since
    Aug 03, 2004
    Posts
    39
    Okay, I found a code snippet at:

    http://developer.apple.com/technotes/tn2002/tn2053.html

    which shows how to enable trapping on powerpc architectures. It involves an asm command, so a corresponding version for intel is bound to be different.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Black Screen with Backtrace Exceptions
    By WebX in forum Apple Desktops
    Replies: 8
    Last Post: 03-21-2011, 12:20 PM
  2. Panic (system crashes) - Kernel trap - MacBook Pro
    By Matthias.obergr in forum OS X - Operating System
    Replies: 4
    Last Post: 11-17-2009, 02:20 PM
  3. Firmware password exceptions?
    By Giantegg in forum OS X - Operating System
    Replies: 6
    Last Post: 10-09-2009, 05:38 PM
  4. How to back up everything without exceptions?
    By tenp in forum OS X - Apps and Games
    Replies: 7
    Last Post: 03-24-2008, 05:25 PM
  5. Question about exceptions in C++ via Xcode
    By cipher in forum OS X - Development and Darwin
    Replies: 2
    Last Post: 06-25-2004, 10:02 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •