• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nasa / trick / 15560595695

10 Jun 2025 01:17PM UTC coverage: 55.929% (-0.02%) from 55.948%
15560595695

Pull #1915

github

web-flow
Merge 7e26ab1f0 into b34afa649
Pull Request #1915: FPEs don't work on Macs #1914

0 of 2 new or added lines in 2 files covered. (0.0%)

8 existing lines in 5 files now uncovered.

12329 of 22044 relevant lines covered (55.93%)

255947.41 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/trick_source/sim_services/Executive/Executive_fpe_handler.cpp
1
/*
2
   PURPOSE: (Floating point exception handler)
3

4
   PROGRAMMERS: (((Robert W. Bailey) (LinCom) (April 1992) (--) (Realtime)))
5
 */
6

7
#include <stdio.h>
8
#include <string.h>
9
#include <stdlib.h>
10
#include <unistd.h>
11

12
#ifdef __APPLE__
13
#include <mach-o/dyld.h>
14
#endif
15

16
/*
17
 * FPE specific headers
18
 */
19
#ifdef __linux__
20
#include <fenv.h>
21
#endif
22

23
#include "trick/Executive.hh"
24
#include "trick/exec_proto.h"
25
#include "trick/message_proto.h"
26

27
/**
28
@design
29
-# This signal handler processes SIGFPE
30
-# Write a message to stderr that a signal has been caught.
31
-# In Linux print out the type of floating point error that occured.
32
-# If attach_debugger == true, attempt to attach a debugger to the current process.
33
-# Else if stack_trace == true, attempt to attach a debugger to print a stack trace.
34
-# Exit the process with a -2 return.
35
*/
36

37
void Trick::Executive::fpe_handler(siginfo_t * sip __attribute__((unused)) ) {
×
38

NEW
39
    write( 2 , "\033[31mProcess terminated by signal FPE" , 37 ) ;
×
40
    /* Determine what floating point error occurred */
41
    if (sip != (siginfo_t *) NULL) {
×
42
        switch (sip->si_code) {
×
43
            case FPE_FLTRES:          /* inexact */
×
44
                write( 2, " (inexact)", 10 );
×
45
                return ;
×
46
            case FPE_FLTUND:          /* underflow */
×
47
                write( 2, " (floating point underflow)", 27 );
×
48
                break;
×
49
            case FPE_FLTINV:          /* invalid operand */
×
50
                write( 2, " (invalid operand)", 18 );
×
51
                break;
×
52
            case FPE_FLTDIV:          /* division-by-zero */
×
53
                write( 2, " (floating point division-by-zero)", 34);
×
54
                break;
×
55
            case FPE_FLTOVF:          /* overflow */
×
56
                write( 2, " (floating point overflow)", 26);
×
57
                break;
×
58
            case FPE_INTOVF:          /* integer overflow */
×
59
                write( 2, " (integer overflow)", 19);
×
60
                break;
×
61
            case FPE_INTDIV:          /* integer division-by-zero */
×
62
                write( 2, " (integer division-by-zero)", 27);
×
63
                break;
×
64
            default:
×
65
                break;
×
66
        }
67
    }
UNCOV
68
    write( 2 , "\033[0m\n" , 5 ) ;
×
69

70
    /*
71
     Attempt to attach with debugger or print stack trace.  Not a requirement.
72
     snprintf and system are not async signal safe, but we don't have anything to lose.
73
     */
74
#if __linux__
75
    char command[1024];
76
    if (attach_debugger == true) {
×
77
        snprintf(command, sizeof(command), "%s -silent /proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());
×
78
        system(command);
×
79
    } else if (stack_trace == true ) {
×
80
            snprintf(command, sizeof(command), "%s -silent -batch -x ${TRICK_HOME}/share/trick/gdb_commands "
×
81
                    "/proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());
82
            system(command);
×
83
    }
84
#endif
85

86
    // The user has chosen for Trick to intervene on their behalf.  Exit if handler called.
87
    _exit(-2) ;
×
88

89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc