OpenASIP 2.2
Loading...
Searching...
No Matches
Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
StopPointManager Class Reference

#include <StopPointManager.hh>

Inheritance diagram for StopPointManager:
Inheritance graph
Collaboration diagram for StopPointManager:
Collaboration graph

Public Member Functions

 StopPointManager (TTASimulationController &controller, SimulationEventHandler &eventHandler)
 
virtual ~StopPointManager ()
 
unsigned int add (const StopPoint &stopPoint)
 
void deleteStopPoint (unsigned int handle)
 
void deleteAll ()
 
void enable (unsigned int handle)
 
void enableAll ()
 
void enableOnceAndDelete (unsigned int handle)
 
void enableOnceAndDisable (unsigned int handle)
 
void disable (unsigned int handle)
 
void disableAll ()
 
const StopPointstopPointWithHandleConst (unsigned int handle) const
 
unsigned int stopPointHandle (unsigned int index)
 
unsigned int stopPointCount ()
 
void setIgnore (unsigned int handle, unsigned int count)
 
void setCondition (unsigned int handle, const ConditionScript &condition)
 
void removeCondition (unsigned int handle)
 
unsigned int stopCausingStopPoint (unsigned int index) const
 
unsigned int stopCausingStopPointCount () const
 
void handleEvent ()
 
- Public Member Functions inherited from Listener
 Listener ()
 
virtual ~Listener ()
 
virtual void handleEvent (int event)
 

Private Types

typedef std::map< unsigned int, StopPoint * > StopPointIndex
 The breakpoint storage.
 
typedef std::vector< unsigned int > HandleContainer
 The handle storage.
 

Private Member Functions

StopPointfindStopPoint (unsigned int handle)
 

Private Attributes

StopPointIndex stopPoints_
 The stop points.
 
HandleContainer handles_
 The stop point handles.
 
unsigned int handleCount_
 Represents the next free handle.
 
ClockCycleCount lastStopCycle_
 The clock cycle in which simulation was stopped last.
 
TTASimulationControllercontroller_
 The simulation controller to use to stop the simulation.
 
SimulationEventHandlereventHandler_
 The event handler to use to register stop points to.
 

Detailed Description

Keeps book of user-set simulation stop points.

Definition at line 50 of file StopPointManager.hh.

Member Typedef Documentation

◆ HandleContainer

typedef std::vector<unsigned int> StopPointManager::HandleContainer
private

The handle storage.

Definition at line 88 of file StopPointManager.hh.

◆ StopPointIndex

typedef std::map<unsigned int, StopPoint*> StopPointManager::StopPointIndex
private

The breakpoint storage.

Definition at line 86 of file StopPointManager.hh.

Constructor & Destructor Documentation

◆ StopPointManager()

StopPointManager::StopPointManager ( TTASimulationController controller,
SimulationEventHandler eventHandler 
)

Constructor.

Parameters
controllerThe simulation controller the stop points should use to stop the simulation.

Definition at line 56 of file StopPointManager.cc.

58 :
59 handleCount_(0), lastStopCycle_(0), controller_(controller),
60 eventHandler_(eventHandler) {
61}
unsigned int handleCount_
Represents the next free handle.
TTASimulationController & controller_
The simulation controller to use to stop the simulation.
ClockCycleCount lastStopCycle_
The clock cycle in which simulation was stopped last.
SimulationEventHandler & eventHandler_
The event handler to use to register stop points to.

◆ ~StopPointManager()

StopPointManager::~StopPointManager ( )
virtual

Destructor.

Definition at line 67 of file StopPointManager.cc.

67 {
69}
static void deleteAllValues(MapType &aMap)
StopPointIndex stopPoints_
The stop points.

References MapTools::deleteAllValues(), and stopPoints_.

Here is the call graph for this function:

Member Function Documentation

◆ add()

unsigned int StopPointManager::add ( const StopPoint stopPoint)

Function that adds a new stop point.

Copies the given stop point.

Parameters
stopPointThe stop point to be added.
Returns
Handle for the added stop point.

Definition at line 81 of file StopPointManager.cc.

81 {
82
83 StopPoint* toAdd = stopPoint.copy();
84
86
87 stopPoints_.insert(make_pair(handleCount_, toAdd));
88 handles_.push_back(handleCount_);
89
90 toAdd->setEnabled(true);
91
92 if (stopPoints_.size() == 1) {
93 // this is the first added stop point, enable event
94 // listening
97 }
98 return handleCount_;
99}
virtual bool registerListener(int event, Listener *listener)
Definition Informer.cc:87
@ SE_NEW_INSTRUCTION
Generated before executing a new instructon.
HandleContainer handles_
The stop point handles.
virtual StopPoint * copy() const =0
virtual void setEnabled(bool flag)
Definition StopPoint.cc:63

References StopPoint::copy(), eventHandler_, handleCount_, handles_, Informer::registerListener(), SimulationEventHandler::SE_NEW_INSTRUCTION, StopPoint::setEnabled(), and stopPoints_.

Referenced by BPCommand::execute(), TBPCommand::execute(), and WatchCommand::execute().

Here is the call graph for this function:

◆ deleteAll()

void StopPointManager::deleteAll ( )

Removes all stop points.

Definition at line 136 of file StopPointManager.cc.

136 {
137 while (handles_.size() > 0) {
139 }
140}
void deleteStopPoint(unsigned int handle)

References deleteStopPoint(), and handles_.

Referenced by DeleteBPCommand::execute().

Here is the call graph for this function:

◆ deleteStopPoint()

void StopPointManager::deleteStopPoint ( unsigned int  handle)

Remove a stop point by the given handle.

Parameters
handleThe handle of the stop point to be removed.

Definition at line 108 of file StopPointManager.cc.

108 {
109 StopPoint* stopPoint = findStopPoint(handle);
110
111 StopPointIndex::iterator findResult = stopPoints_.find(handle);
112 stopPoints_.erase(findResult);
113
114 for (HandleContainer::iterator i = handles_.begin(); i != handles_.end();
115 i++) {
116 if ((*i) == handle) {
117 handles_.erase(i);
118 break;
119 }
120 }
121
122 delete stopPoint;
123 stopPoint = NULL;
124
125 if (stopPoints_.size() == 0) {
126 // this was the last stop point, disable event listening
129 }
130}
virtual bool unregisterListener(int event, Listener *listener)
Definition Informer.cc:104
StopPoint * findStopPoint(unsigned int handle)

References eventHandler_, findStopPoint(), handles_, SimulationEventHandler::SE_NEW_INSTRUCTION, stopPoints_, and Informer::unregisterListener().

Referenced by deleteAll(), DeleteBPCommand::execute(), handleEvent(), ProximBreakpointWindow::onDeleteBreakpoint(), and ProximBreakpointWindow::onDeleteWatch().

Here is the call graph for this function:

◆ disable()

void StopPointManager::disable ( unsigned int  handle)

Disables the stop point by the given handle.

Parameters
handleThe handle for the stop point.

Definition at line 200 of file StopPointManager.cc.

200 {
201 findStopPoint(handle)->setEnabled(false);
202}

References findStopPoint(), and StopPoint::setEnabled().

Referenced by disableAll(), and DisableBPCommand::execute().

Here is the call graph for this function:

◆ disableAll()

void StopPointManager::disableAll ( )

Disables all stop oints.

Definition at line 208 of file StopPointManager.cc.

208 {
209 for (unsigned int i = 0; i < handles_.size(); i++) {
210 disable(handles_.at(i));
211 }
212}
void disable(unsigned int handle)

References disable(), and handles_.

Here is the call graph for this function:

◆ enable()

void StopPointManager::enable ( unsigned int  handle)

Enables the stop point by the given handle.

Parameters
handleThe handle to identify the stop point.

Definition at line 149 of file StopPointManager.cc.

149 {
150 findStopPoint(handle)->setEnabled(true);
151}

References findStopPoint(), and StopPoint::setEnabled().

Referenced by enableAll(), and EnableBPCommand::execute().

Here is the call graph for this function:

◆ enableAll()

void StopPointManager::enableAll ( )

Enables all stop points.

Definition at line 157 of file StopPointManager.cc.

157 {
158 for (unsigned int i = 0; i < handles_.size(); i++) {
159 enable(handles_.at(i));
160 }
161}
void enable(unsigned int handle)

References enable(), and handles_.

Here is the call graph for this function:

◆ enableOnceAndDelete()

void StopPointManager::enableOnceAndDelete ( unsigned int  handle)

Enables the stop point by the given handle and sets it to be deleted after being triggered.

Parameters
handleThe handle for the stop point.
Exceptions
InstanceNotFoundif the given handle cannot be found.

Definition at line 172 of file StopPointManager.cc.

172 {
173 StopPoint* stopPoint = findStopPoint(handle);
174
175 stopPoint->setEnabled(true);
176 stopPoint->setDeletedAfterTriggered(true);
177}
virtual void setDeletedAfterTriggered(bool flag)
Definition StopPoint.cc:107

References findStopPoint(), StopPoint::setDeletedAfterTriggered(), and StopPoint::setEnabled().

Referenced by EnableBPCommand::execute().

Here is the call graph for this function:

◆ enableOnceAndDisable()

void StopPointManager::enableOnceAndDisable ( unsigned int  handle)

Enables the stop point by the given handle and sets it to be disabled after being triggered.

Parameters
handleThe handle for the stop point.
Exceptions
InstanceNotFoundif the given handle cannot be found.

Definition at line 187 of file StopPointManager.cc.

187 {
188 StopPoint* stopPoint = findStopPoint(handle);
189
190 stopPoint->setEnabled(true);
191 stopPoint->setDisabledAfterTriggered(true);
192}
virtual void setDisabledAfterTriggered(bool flag)
Definition StopPoint.cc:85

References findStopPoint(), StopPoint::setDisabledAfterTriggered(), and StopPoint::setEnabled().

Referenced by EnableBPCommand::execute().

Here is the call graph for this function:

◆ findStopPoint()

StopPoint * StopPointManager::findStopPoint ( unsigned int  handle)
private

Tries to find a stop point by the given handle. If no such stop point is found, throws an exception.

Parameters
handleThe handle for the stop point.
Exceptions
InstanceNotFoundIf no stop point with given handle is found.
Todo:
textgenerator, to be displayed in the UI.

Definition at line 320 of file StopPointManager.cc.

320 {
321 StopPointIndex::iterator containerEnd = stopPoints_.end();
322 StopPointIndex::iterator findResult = stopPoints_.find(handle);
323
324 if (findResult == containerEnd) {
325 /// @todo textgenerator, to be displayed in the UI.
326 string msg = "No stop point found by the given handle.";
327 throw InstanceNotFound(__FILE__, __LINE__, __func__, msg);
328 } else {
329 return findResult->second;
330 }
331}
#define __func__

References __func__, and stopPoints_.

Referenced by deleteStopPoint(), disable(), enable(), enableOnceAndDelete(), enableOnceAndDisable(), removeCondition(), setCondition(), and setIgnore().

◆ handleEvent()

void StopPointManager::handleEvent ( )
virtual

Stops simulation if there is at least one stop point requesting it.

Receives SE_NEW_INSTRUCTION events.

Reimplemented from Listener.

Definition at line 388 of file StopPointManager.cc.

388 {
389
390 // find all the stop points watching the new instruction address
391 StopPointIndex::iterator i = stopPoints_.begin();
392 HandleContainer toBeDeletedStopPoints;
393 while (i != stopPoints_.end()) {
394
395 StopPoint& stopPoint = *(*i).second;
396 const int handle = (*i).first;
397 if (stopPoint.isEnabled() && stopPoint.isTriggered()) {
398 // we found a stop point that is triggered at this clock cycle
399
400 if (stopPoint.ignoreCount() == 0 && stopPoint.isConditionOK()) {
401
404 if (stopPoint.isDisabledAfterTriggered()) {
405 stopPoint.setEnabled(false);
406 }
407
408 if (stopPoint.isDeletedAfterTriggered()) {
409 toBeDeletedStopPoints.push_back(handle);
410 }
411
412 } else if (stopPoint.isConditionOK()) {
413 // decrease the ignore count only if the (possible) condition
414 // of the breakpoint is also true
415 stopPoint.decreaseIgnoreCount();
416 }
417 }
418 ++i;
419 }
420
421 // delete stop points that wanted to be deleted after triggered
422 for (size_t i = 0; i < toBeDeletedStopPoints.size(); ++i) {
423 deleteStopPoint(toBeDeletedStopPoints[i]);
424 }
425}
@ SRE_BREAKPOINT
Stopped because of at least one breakpoint.
std::vector< unsigned int > HandleContainer
The handle storage.
virtual bool isDisabledAfterTriggered() const
Definition StopPoint.cc:97
virtual bool isTriggered() const =0
virtual bool isEnabled() const
Definition StopPoint.cc:73
virtual bool isConditionOK()
Definition StopPoint.cc:215
virtual void decreaseIgnoreCount()
Definition StopPoint.cc:201
virtual bool isDeletedAfterTriggered() const
Definition StopPoint.cc:119
virtual unsigned int ignoreCount() const
Definition StopPoint.cc:193
virtual void prepareToStop(StopReason reason)
virtual ClockCycleCount clockCount() const

References TTASimulationController::clockCount(), controller_, StopPoint::decreaseIgnoreCount(), deleteStopPoint(), StopPoint::ignoreCount(), StopPoint::isConditionOK(), StopPoint::isDeletedAfterTriggered(), StopPoint::isDisabledAfterTriggered(), StopPoint::isEnabled(), StopPoint::isTriggered(), lastStopCycle_, TTASimulationController::prepareToStop(), StopPoint::setEnabled(), SRE_BREAKPOINT, and stopPoints_.

Here is the call graph for this function:

◆ removeCondition()

void StopPointManager::removeCondition ( unsigned int  handle)

Removes the condition of triggering of the stop point by the given handle.

Parameters
handleThe handle for the stop point.
Exceptions
InstanceNotFoundIf no stop point with given handle is found.

Definition at line 308 of file StopPointManager.cc.

308 {
310}
virtual void removeCondition()
Definition StopPoint.cc:142

References findStopPoint(), and StopPoint::removeCondition().

Referenced by ConditionCommand::execute().

Here is the call graph for this function:

◆ setCondition()

void StopPointManager::setCondition ( unsigned int  handle,
const ConditionScript condition 
)

Sets the condition of triggering for the stop point by the given handle.

Parameters
handleThe handle for the stop point.
conditionThe condition to be used to determine if the stop point should be fired.
Exceptions
InstanceNotFoundIf no stop point with given handle is found.

Definition at line 296 of file StopPointManager.cc.

297 {
298 findStopPoint(handle)->setCondition(condition);
299}
virtual void setCondition(const ConditionScript &condition)
Definition StopPoint.cc:131

References findStopPoint(), and StopPoint::setCondition().

Referenced by ConditionCommand::execute().

Here is the call graph for this function:

◆ setIgnore()

void StopPointManager::setIgnore ( unsigned int  handle,
unsigned int  count 
)

Sets the number of times the stop point by the given handle should not be triggered when the condition is met.

Parameters
handleThe handle for the stop point.
countThe number of times the stop point should be ignored.
Exceptions
InstanceNotFoundIf no stop point with given handle is found.

Definition at line 283 of file StopPointManager.cc.

283 {
284 findStopPoint(handle)->setIgnoreCount(count);
285}
virtual void setIgnoreCount(unsigned int count)
Definition StopPoint.cc:182

References findStopPoint(), and StopPoint::setIgnoreCount().

Referenced by IgnoreCommand::execute().

Here is the call graph for this function:

◆ stopCausingStopPoint()

unsigned int StopPointManager::stopCausingStopPoint ( unsigned int  index) const

Returns the handle of a stop causing stop point with given index in the container of stop causing stop points.

Stop causing stop point is a stop point that caused the latest stop of simulator.

Parameters
indexIndex of the stop point in the container.
Returns
the handle of the stop point.
Exceptions
OutOfRange

Definition at line 345 of file StopPointManager.cc.

345 {
346 unsigned int count = 0;
347 for (StopPointIndex::const_iterator i = stopPoints_.begin();
348 i != stopPoints_.end(); ++i) {
349 if ((*i).second->isTriggered()) {
350 if (count == index)
351 return (*i).first;
352 ++count;
353 }
354 }
355 throw OutOfRange(
356 __FILE__, __LINE__, __func__, "Stop point index out of range.");
357}

References __func__, and stopPoints_.

Referenced by SimControlLanguageCommand::printStopReasons().

◆ stopCausingStopPointCount()

unsigned int StopPointManager::stopCausingStopPointCount ( ) const

Returns the count of stop causing stop points.

Stop causing stop point is a stop point that caused the latest stop of simulator.

Returns
the count of stop points.

Definition at line 368 of file StopPointManager.cc.

368 {
370 return 0;
371 }
372 std::size_t count = 0;
373 for (StopPointIndex::const_iterator i = stopPoints_.begin();
374 i != stopPoints_.end(); ++i) {
375 if ((*i).second->isTriggered())
376 ++count;
377 }
378 return count;
379}

References TTASimulationController::clockCount(), controller_, lastStopCycle_, and stopPoints_.

Referenced by SimControlLanguageCommand::printStopReasons().

Here is the call graph for this function:

◆ stopPointCount()

unsigned int StopPointManager::stopPointCount ( )

Returns the current number of stop points in the manager.

Can be used to access all stop points in the manager.

Returns
The number of stop points in the manager.

Definition at line 269 of file StopPointManager.cc.

269 {
270 return handles_.size();
271}

References handles_.

Referenced by InfoBreakpointsCommand::execute(), ProximDisassemblyGridTable::GetValue(), ProximDisassemblyWindow::onRightClick(), ProximBreakpointWindow::refreshStopPoints(), and stopPointHandle().

◆ stopPointHandle()

unsigned int StopPointManager::stopPointHandle ( unsigned int  index)

Returns the handle of the stop point by the given index.

The index is not a direct index to the container used to store stop points, but more just a way to go through all of the stop points in the manager. A stop point may not have the same index every call.

All of the stop points can be accessed by going through the stop points with the indices between 0 and stopPointCount - 1, inclusive. The stop points are in no particular order.

Parameters
indexThe index.
Returns
A Copy of the stop point by the given index.
Exceptions
OutOfRangeIf there is no stop point by the given index.
Todo:
textgenerator, to be displayed in the UI.

Definition at line 231 of file StopPointManager.cc.

231 {
232 if (index < stopPointCount()) {
233 return handles_.at(index);
234 } else {
235 /// @todo textgenerator, to be displayed in the UI.
236 string msg = "No stop point found by the given index.";
237 throw OutOfRange(__FILE__, __LINE__, __func__, msg);
238 }
239}
unsigned int stopPointCount()

References __func__, handles_, and stopPointCount().

Referenced by InfoBreakpointsCommand::execute(), ProximDisassemblyGridTable::GetValue(), ProximDisassemblyWindow::onRightClick(), and ProximBreakpointWindow::refreshStopPoints().

Here is the call graph for this function:

◆ stopPointWithHandleConst()

const StopPoint & StopPointManager::stopPointWithHandleConst ( unsigned int  handle) const

Returns the stop point with the given handle.

Parameters
handleThe handle.
Returns
Stop point with the given handle,
Exceptions
InstanceNotFoundIf there is no stop point with the given handle.
Todo:
textgenerator, to be displayed in the UI.

Definition at line 248 of file StopPointManager.cc.

248 {
249 StopPointIndex::const_iterator containerEnd = stopPoints_.end();
250 StopPointIndex::const_iterator findResult = stopPoints_.find(handle);
251
252 if (findResult == containerEnd) {
253 /// @todo textgenerator, to be displayed in the UI.
254 std::string msg = "No stop point found by the given handle.";
255 throw InstanceNotFound(__FILE__, __LINE__, __func__, msg);
256 } else {
257 return *findResult->second;
258 }
259}

References __func__, and stopPoints_.

Referenced by ConditionCommand::execute(), IgnoreCommand::execute(), ProximDisassemblyGridTable::GetValue(), ProximBreakpointWindow::onBreakpointLookup(), ProximDisassemblyWindow::onRightClick(), SimControlLanguageCommand::printBreakpointInfo(), SimControlLanguageCommand::printStopReasons(), ProximBreakpointWindow::refreshStopPoints(), BreakpointPropertiesDialog::TransferDataToWindow(), WatchPropertiesDialog::TransferDataToWindow(), and SimControlLanguageCommand::verifyBreakpointHandles().

Member Data Documentation

◆ controller_

TTASimulationController& StopPointManager::controller_
private

The simulation controller to use to stop the simulation.

Definition at line 101 of file StopPointManager.hh.

Referenced by handleEvent(), and stopCausingStopPointCount().

◆ eventHandler_

SimulationEventHandler& StopPointManager::eventHandler_
private

The event handler to use to register stop points to.

Definition at line 103 of file StopPointManager.hh.

Referenced by add(), and deleteStopPoint().

◆ handleCount_

unsigned int StopPointManager::handleCount_
private

Represents the next free handle.

Definition at line 97 of file StopPointManager.hh.

Referenced by add().

◆ handles_

HandleContainer StopPointManager::handles_
private

The stop point handles.

Definition at line 95 of file StopPointManager.hh.

Referenced by add(), deleteAll(), deleteStopPoint(), disableAll(), enableAll(), stopPointCount(), and stopPointHandle().

◆ lastStopCycle_

ClockCycleCount StopPointManager::lastStopCycle_
private

The clock cycle in which simulation was stopped last.

Definition at line 99 of file StopPointManager.hh.

Referenced by handleEvent(), and stopCausingStopPointCount().

◆ stopPoints_

StopPointIndex StopPointManager::stopPoints_
private

The documentation for this class was generated from the following files: