OpenASIP  2.0
Public Member Functions | Private Attributes | List of all members
SigFPEHandler Class Reference
Inheritance diagram for SigFPEHandler:
Inheritance graph
Collaboration diagram for SigFPEHandler:
Collaboration graph

Public Member Functions

 SigFPEHandler (SimulatorFrontend &target)
 
virtual void execute (int, siginfo_t *info)
 
- Public Member Functions inherited from Application::UnixSignalHandler
virtual ~UnixSignalHandler ()
 

Private Attributes

SimulatorFrontendtarget_
 Simulator frontend to use when stopping the simulation. More...
 

Detailed Description

A handler class for SIGFPE signal

Stops the simulation (if it's running). Used for catching errors from the simulated program in the compiled simulation engine.

Definition at line 79 of file TTASim.cc.

Constructor & Destructor Documentation

◆ SigFPEHandler()

SigFPEHandler::SigFPEHandler ( SimulatorFrontend target)
inline

Constructor.

Parameters
targetThe target SimulatorFrontend instance.

Definition at line 86 of file TTASim.cc.

86  : target_(target) {
87  }

Member Function Documentation

◆ execute()

virtual void SigFPEHandler::execute ( int  ,
siginfo_t *  info 
)
inlinevirtual

Terminates the simulation.

Exceptions
SimulationExecutionErrorthrown always

Implements Application::UnixSignalHandler.

Definition at line 94 of file TTASim.cc.

94  {
95  std::string msg("Unknown floating point exception");
96 
97  if (info->si_code == FPE_INTDIV) {
98  msg = "integer division by zero";
99  } else if (info->si_code == FPE_FLTDIV) {
100  msg = "floating-point division by zero";
101  } else if (info->si_code == FPE_INTOVF) {
102  msg = "integer overflow";
103  } else if (info->si_code == FPE_FLTOVF) {
104  msg = "floating-point overflow";
105  } else if (info->si_code == FPE_FLTUND) {
106  msg = "floating-point underflow";
107  } else if (info->si_code == FPE_FLTRES) {
108  msg = "floating-point inexact result";
109  } else if (info->si_code == FPE_FLTINV) {
110  msg = "invalid floating-point operation";
111  } else if (info->si_code == FPE_FLTSUB) {
112  msg = " Subscript out of range";
113  }
114 
118 
119  throw SimulationExecutionError(__FILE__, __LINE__, __FUNCTION__, msg);
120  }

References SimulatorFrontend::prepareToStop(), SimulatorFrontend::reportSimulatedProgramError(), SimulatorFrontend::RES_FATAL, SRE_RUNTIME_ERROR, and target_.

Here is the call graph for this function:

Member Data Documentation

◆ target_

SimulatorFrontend& SigFPEHandler::target_
private

Simulator frontend to use when stopping the simulation.

Definition at line 123 of file TTASim.cc.

Referenced by execute().


The documentation for this class was generated from the following file:
SimulationExecutionError
Definition: Exception.hh:951
SRE_RUNTIME_ERROR
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
Definition: SimulatorConstants.hh:68
SimulatorFrontend::RES_FATAL
@ RES_FATAL
Fatal runtime error, there is a serious error in the simulated program, thus it makes no sense to go ...
Definition: SimulatorFrontend.hh:95
SigFPEHandler::target_
SimulatorFrontend & target_
Simulator frontend to use when stopping the simulation.
Definition: TTASim.cc:123
SimulatorFrontend::reportSimulatedProgramError
void reportSimulatedProgramError(RuntimeErrorSeverity severity, const std::string &description)
Definition: SimulatorFrontend.cc:2304
SimulatorFrontend::prepareToStop
void prepareToStop(StopReason reason)
Definition: SimulatorFrontend.cc:1331