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

nasa / trick / 15620799604

12 Jun 2025 09:06PM UTC coverage: 55.947% (-0.001%) from 55.948%
15620799604

Pull #1915

github

web-flow
Merge 65da18835 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%)

5 existing lines in 3 files now uncovered.

12333 of 22044 relevant lines covered (55.95%)

267102.25 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
#include "trick/Executive.hh"
13
#include "trick/exec_proto.h"
14
#include "trick/message_proto.h"
15

16
/**
17
@design
18
-# This signal handler processes SIGFPE
19
-# Write a message to stderr that a signal has been caught.
20
-# In Linux print out the type of floating point error that occured.
21
-# If attach_debugger == true, attempt to attach a debugger to the current process.
22
-# Else if stack_trace == true, attempt to attach a debugger to print a stack trace.
23
-# Exit the process with a -2 return.
24
*/
25

26
void Trick::Executive::fpe_handler(siginfo_t * sip __attribute__((unused)) ) {
×
27

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

59
    /*
60
     Attempt to attach with debugger or print stack trace.  Not a requirement.
61
     snprintf and system are not async signal safe, but we don't have anything to lose.
62
     */
63
#if __linux__
64
    char command[1024];
65
    if (attach_debugger == true) {
×
66
        snprintf(command, sizeof(command), "%s -silent /proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());
×
67
        system(command);
×
68
    } else if (stack_trace == true ) {
×
69
            snprintf(command, sizeof(command), "%s -silent -batch -x ${TRICK_HOME}/share/trick/gdb_commands "
×
70
                    "/proc/%d/exe %d", debugger_command.c_str(), getpid(), getpid());
71
            system(command);
×
72
    }
73
#endif
74

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

78
}
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