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

Public Member Functions

 RuntimeErrorReporter (SimulatorFrontend &target)
 
virtual ~RuntimeErrorReporter ()
 
virtual void handleEvent ()
 
- Public Member Functions inherited from Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void handleEvent (int event)
 

Private Attributes

SimulatorFrontendtarget_
 Simulator frontend to use. More...
 

Detailed Description

Class that catches simulated program runtime error events and prints the error reports to stderr.

Definition at line 53 of file SimulatorCLI.cc.

Constructor & Destructor Documentation

◆ RuntimeErrorReporter()

RuntimeErrorReporter::RuntimeErrorReporter ( SimulatorFrontend target)
inline

Constructor.

Registers itself to the SimulationEventHandler to listen to runtime error events.

Parameters
targetThe target SimulatorFrontend instance.

Definition at line 63 of file SimulatorCLI.cc.

63  :
64  Listener(), target_(target) {
67  }

References SimulatorFrontend::eventHandler(), Informer::registerListener(), and SimulationEventHandler::SE_RUNTIME_ERROR.

Here is the call graph for this function:

◆ ~RuntimeErrorReporter()

virtual RuntimeErrorReporter::~RuntimeErrorReporter ( )
inlinevirtual

Member Function Documentation

◆ handleEvent()

virtual void RuntimeErrorReporter::handleEvent ( )
inlinevirtual

Handles the runtime error event by printing and error report to stderr and stopping simulation in case it's a fatal error.

Reimplemented from Listener.

Definition at line 78 of file SimulatorCLI.cc.

78  {
79  size_t minorErrors = target_.programErrorReportCount(
81  size_t fatalErrors = target_.programErrorReportCount(
85  ClockCycleCount cycleCount = target_.cycleCount();
86 
87  if (minorErrors > 0) {
88  for (size_t i = 0; i < minorErrors; ++i) {
89  std::cerr << "warning: runtime error: "
92  << std::endl;
93  }
94  }
95 
96  if (fatalErrors > 0) {
97  for (size_t i = 0; i < fatalErrors; ++i) {
98  std::cerr << "error: runtime error: "
101  << std::endl;
102  }
104  }
105  std::cerr
106  << "Current PC: " << currentPC << " last PC: " << lastPC
107  << " cycle count: " << cycleCount << std::endl;
109  }

References SimulatorFrontend::clearProgramErrorReports(), SimulatorFrontend::cycleCount(), SimulatorFrontend::lastExecutedInstruction(), SimulatorFrontend::prepareToStop(), SimulatorFrontend::programCounter(), SimulatorFrontend::programErrorReport(), SimulatorFrontend::programErrorReportCount(), SimulatorFrontend::RES_FATAL, SimulatorFrontend::RES_MINOR, SRE_RUNTIME_ERROR, and target_.

Here is the call graph for this function:

Member Data Documentation

◆ target_

SimulatorFrontend& RuntimeErrorReporter::target_
private

Simulator frontend to use.

Definition at line 113 of file SimulatorCLI.cc.

Referenced by handleEvent(), and ~RuntimeErrorReporter().


The documentation for this class was generated from the following file:
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
SimulatorFrontend::programCounter
InstructionAddress programCounter() const
Definition: SimulatorFrontend.cc:1169
Informer::unregisterListener
virtual bool unregisterListener(int event, Listener *listener)
Definition: Informer.cc:104
SimulatorFrontend::programErrorReport
std::string programErrorReport(RuntimeErrorSeverity severity, std::size_t index)
Definition: SimulatorFrontend.cc:2321
Informer::registerListener
virtual bool registerListener(int event, Listener *listener)
Definition: Informer.cc:87
SRE_RUNTIME_ERROR
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
Definition: SimulatorConstants.hh:68
SimulatorFrontend::RES_MINOR
@ RES_MINOR
Minor runtime error, no abort necessary.
Definition: SimulatorFrontend.hh:94
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
SimulationEventHandler::SE_RUNTIME_ERROR
@ SE_RUNTIME_ERROR
Sent when a runtime error is detected in the simulated program.
Definition: SimulationEventHandler.hh:52
SimulatorFrontend::lastExecutedInstruction
virtual InstructionAddress lastExecutedInstruction(int coreId=-1) const
Definition: SimulatorFrontend.cc:1182
SimulatorFrontend::programErrorReportCount
std::size_t programErrorReportCount(RuntimeErrorSeverity severity)
Definition: SimulatorFrontend.cc:2344
SimulatorFrontend::clearProgramErrorReports
void clearProgramErrorReports()
Definition: SimulatorFrontend.cc:2360
SimulatorFrontend::cycleCount
ClockCycleCount cycleCount() const
Definition: SimulatorFrontend.cc:1194
SimulatorFrontend::eventHandler
SimulationEventHandler & eventHandler()
Definition: SimulatorFrontend.cc:2260
Listener::Listener
Listener()
Definition: Listener.cc:40
RuntimeErrorReporter::target_
SimulatorFrontend & target_
Simulator frontend to use.
Definition: SimulatorCLI.cc:113
ClockCycleCount
CycleCount ClockCycleCount
Alias for ClockCycleCount.
Definition: SimulatorConstants.hh:57
SimulatorFrontend::prepareToStop
void prepareToStop(StopReason reason)
Definition: SimulatorFrontend.cc:1331