OpenASIP 2.2
Loading...
Searching...
No Matches
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.
 

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 }
virtual bool registerListener(int event, Listener *listener)
Definition Informer.cc:87
SimulatorFrontend & target_
Simulator frontend to use.
@ SE_RUNTIME_ERROR
Sent when a runtime error is detected in the simulated program.
SimulationEventHandler & eventHandler()

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

Here is the call graph for this function:

◆ ~RuntimeErrorReporter()

virtual RuntimeErrorReporter::~RuntimeErrorReporter ( )
inlinevirtual

Definition at line 69 of file SimulatorCLI.cc.

69 {
72 }
virtual bool unregisterListener(int event, Listener *listener)
Definition Informer.cc:104

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

Here is the call graph for this function:

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 }
UInt32 InstructionAddress
Definition BaseType.hh:175
CycleCount ClockCycleCount
Alias for ClockCycleCount.
@ SRE_RUNTIME_ERROR
A fatal runtime error occured in the simulated program.
ClockCycleCount cycleCount() const
virtual InstructionAddress lastExecutedInstruction(int coreId=-1) const
std::size_t programErrorReportCount(RuntimeErrorSeverity severity)
@ RES_FATAL
Fatal runtime error, there is a serious error in the simulated program, thus it makes no sense to go ...
@ RES_MINOR
Minor runtime error, no abort necessary.
InstructionAddress programCounter() const
std::string programErrorReport(RuntimeErrorSeverity severity, std::size_t index)
void prepareToStop(StopReason reason)

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: