OpenASIP  2.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Watch Class Reference

#include <Watch.hh>

Inheritance diagram for Watch:
Inheritance graph
Collaboration diagram for Watch:
Collaboration graph

Public Member Functions

 Watch (const SimulatorFrontend &frontend, const ExpressionScript &expression)
 
virtual ~Watch ()
 
virtual bool isTriggered () const
 
virtual std::string description () const
 
virtual StopPointcopy () const
 
virtual const ExpressionScriptexpression () const
 
virtual void setExpression (const ExpressionScript &expression)
 
- Public Member Functions inherited from StopPoint
 StopPoint ()
 
virtual ~StopPoint ()
 
virtual void setEnabled (bool flag)
 
virtual bool isEnabled () const
 
virtual void setDisabledAfterTriggered (bool flag)
 
virtual bool isDisabledAfterTriggered () const
 
virtual void setDeletedAfterTriggered (bool flag)
 
virtual bool isDeletedAfterTriggered () const
 
virtual void setCondition (const ConditionScript &condition)
 
virtual void removeCondition ()
 
virtual const ConditionScriptcondition () const
 
virtual bool isConditional () const
 
virtual void setIgnoreCount (unsigned int count)
 
virtual unsigned int ignoreCount () const
 
virtual bool isConditionOK ()
 
virtual void decreaseIgnoreCount ()
 

Private Member Functions

 Watch (const Watch &source)
 Static copying not allowed (should use copy()). More...
 

Private Attributes

ExpressionScript expression_
 The expression that is watched. More...
 
const SimulatorFrontendfrontend_
 The simulator frontend which is used to fetch the current PC. More...
 
bool isTriggered_
 Flag which tells whether the watch was triggered in current simulation cycle. More...
 
ClockCycleCount lastCheckedCycle_
 The simulation clock cycle in which the expression was checked the last time. More...
 

Additional Inherited Members

- Protected Attributes inherited from StopPoint
bool enabled_
 Tells whether the breakpoint is enabled or disabled. More...
 
bool disabledAfterTriggered_
 Tells if the breakpoint is disabled after it is triggered the next time. More...
 
bool deletedAfterTriggered_
 Tells if the breakpoint is deleted after it is triggered the next time. More...
 
bool conditional_
 Tells whether the breakpoint is conditional or not. More...
 
ConditionScriptcondition_
 The condition which is used to determine whether the breakpoint should be fired or not. More...
 
unsigned int ignoreCount_
 The number of times the condition is to be ignored before enabling the breakpoint. More...
 

Detailed Description

Represents a simulation watch point.

Watch stops simulation when user-given expression changes its value.

Definition at line 48 of file Watch.hh.

Constructor & Destructor Documentation

◆ Watch() [1/2]

Watch::Watch ( const SimulatorFrontend frontend,
const ExpressionScript expression 
)

Constructor.

Parameters
frontendUsed to fetch the simulation clock.
expressionThe expression watched.

Definition at line 48 of file Watch.cc.

50  :
52  isTriggered_(false), lastCheckedCycle_(0) {
53 }

Referenced by copy().

◆ ~Watch()

Watch::~Watch ( )
virtual

Destructor.

Definition at line 58 of file Watch.cc.

58  {
59 }

◆ Watch() [2/2]

Watch::Watch ( const Watch source)
private

Static copying not allowed (should use copy()).

Member Function Documentation

◆ copy()

StopPoint * Watch::copy ( ) const
virtual

Copy method for dynamically bound copies.

Implements StopPoint.

Definition at line 65 of file Watch.cc.

65  {
66  StopPoint* aCopy = new Watch(frontend_, expression_);
67  if (conditional_) {
68  assert(condition_ != NULL);
69  ConditionScript* conditionCopy = condition_->copy();
70  assert(conditionCopy != NULL);
71  aCopy->setCondition(*conditionCopy);
72  } else {
73  aCopy->removeCondition();
74  }
75  aCopy->setEnabled(enabled_);
79  return aCopy;
80 }

References assert, StopPoint::condition_, StopPoint::conditional_, ConditionScript::copy(), StopPoint::deletedAfterTriggered_, StopPoint::disabledAfterTriggered_, StopPoint::enabled_, expression_, frontend_, StopPoint::ignoreCount_, StopPoint::removeCondition(), StopPoint::setCondition(), StopPoint::setDeletedAfterTriggered(), StopPoint::setDisabledAfterTriggered(), StopPoint::setEnabled(), StopPoint::setIgnoreCount(), and Watch().

Here is the call graph for this function:

◆ description()

std::string Watch::description ( ) const
virtual

Prints the description string of the stop point.

Each subclass overrides this method to construct a descripting string of itself.

Implements StopPoint.

Definition at line 134 of file Watch.cc.

134  {
135  return std::string("watch for expression '") + expression_.script().at(0) +
136  "' " + StopPoint::description();
137 }

References StopPoint::description(), expression_, and Script::script().

Here is the call graph for this function:

◆ expression()

const ExpressionScript & Watch::expression ( ) const
virtual

Returns the expression.

Returns
The expression.

Definition at line 88 of file Watch.cc.

88  {
89  return expression_;
90 }

References expression_.

Referenced by ProximBreakpointWindow::refreshStopPoints(), setExpression(), and WatchPropertiesDialog::TransferDataToWindow().

◆ isTriggered()

bool Watch::isTriggered ( ) const
virtual

Returns true in case this watch is triggered.

Returns true in case the expression has changed in current simulation cycle.

Returns
The status of the watch.

Implements StopPoint.

Definition at line 110 of file Watch.cc.

110  {
112  // simulation clock has changed since the last expression check,
113  // let's see if the watch expression value has changed
114  try {
116  } catch (const Exception&) {
117  // for example simulation might not be initialized in every
118  // check so the script throws, we'll assume that no triggering
119  // should happen at that case
120  isTriggered_ = false;
121  }
123  }
124  return isTriggered_;
125 }

References SimulatorFrontend::cycleCount(), expression_, frontend_, isTriggered_, lastCheckedCycle_, and ExpressionScript::resultChanged().

Here is the call graph for this function:

◆ setExpression()

void Watch::setExpression ( const ExpressionScript expression)
virtual

Sets the expression the watch is watching.

Parameters
expressionThe new expression.

Definition at line 98 of file Watch.cc.

98  {
100 }

References expression(), and expression_.

Here is the call graph for this function:

Member Data Documentation

◆ expression_

ExpressionScript Watch::expression_
mutableprivate

The expression that is watched.

Definition at line 66 of file Watch.hh.

Referenced by copy(), description(), expression(), isTriggered(), and setExpression().

◆ frontend_

const SimulatorFrontend& Watch::frontend_
private

The simulator frontend which is used to fetch the current PC.

Definition at line 68 of file Watch.hh.

Referenced by copy(), and isTriggered().

◆ isTriggered_

bool Watch::isTriggered_
mutableprivate

Flag which tells whether the watch was triggered in current simulation cycle.

Definition at line 71 of file Watch.hh.

Referenced by isTriggered().

◆ lastCheckedCycle_

ClockCycleCount Watch::lastCheckedCycle_
mutableprivate

The simulation clock cycle in which the expression was checked the last time.

Definition at line 74 of file Watch.hh.

Referenced by isTriggered().


The documentation for this class was generated from the following files:
StopPoint::conditional_
bool conditional_
Tells whether the breakpoint is conditional or not.
Definition: StopPoint.hh:91
Script::script
virtual std::vector< std::string > script() const
Definition: Script.cc:106
StopPoint::setEnabled
virtual void setEnabled(bool flag)
Definition: StopPoint.cc:63
StopPoint::setIgnoreCount
virtual void setIgnoreCount(unsigned int count)
Definition: StopPoint.cc:182
StopPoint::setDisabledAfterTriggered
virtual void setDisabledAfterTriggered(bool flag)
Definition: StopPoint.cc:85
Watch::frontend_
const SimulatorFrontend & frontend_
The simulator frontend which is used to fetch the current PC.
Definition: Watch.hh:68
ConditionScript::copy
virtual ConditionScript * copy() const
Definition: ConditionScript.cc:99
StopPoint::enabled_
bool enabled_
Tells whether the breakpoint is enabled or disabled.
Definition: StopPoint.hh:84
StopPoint::condition_
ConditionScript * condition_
The condition which is used to determine whether the breakpoint should be fired or not.
Definition: StopPoint.hh:94
Watch::expression
virtual const ExpressionScript & expression() const
Definition: Watch.cc:88
ConditionScript
Definition: ConditionScript.hh:45
StopPoint::StopPoint
StopPoint()
Definition: StopPoint.cc:43
assert
#define assert(condition)
Definition: Application.hh:86
StopPoint
Definition: StopPoint.hh:53
Watch::expression_
ExpressionScript expression_
The expression that is watched.
Definition: Watch.hh:66
Exception
Definition: Exception.hh:54
Watch::Watch
Watch(const SimulatorFrontend &frontend, const ExpressionScript &expression)
Definition: Watch.cc:48
StopPoint::deletedAfterTriggered_
bool deletedAfterTriggered_
Tells if the breakpoint is deleted after it is triggered the next time.
Definition: StopPoint.hh:89
Watch::isTriggered_
bool isTriggered_
Flag which tells whether the watch was triggered in current simulation cycle.
Definition: Watch.hh:71
SimulatorFrontend::cycleCount
ClockCycleCount cycleCount() const
Definition: SimulatorFrontend.cc:1194
StopPoint::disabledAfterTriggered_
bool disabledAfterTriggered_
Tells if the breakpoint is disabled after it is triggered the next time.
Definition: StopPoint.hh:87
Watch::lastCheckedCycle_
ClockCycleCount lastCheckedCycle_
The simulation clock cycle in which the expression was checked the last time.
Definition: Watch.hh:74
StopPoint::removeCondition
virtual void removeCondition()
Definition: StopPoint.cc:142
StopPoint::ignoreCount_
unsigned int ignoreCount_
The number of times the condition is to be ignored before enabling the breakpoint.
Definition: StopPoint.hh:97
StopPoint::description
virtual std::string description() const =0
Definition: StopPoint.cc:239
StopPoint::setDeletedAfterTriggered
virtual void setDeletedAfterTriggered(bool flag)
Definition: StopPoint.cc:107
ExpressionScript::resultChanged
bool resultChanged()
Definition: ExpressionScript.cc:75
StopPoint::setCondition
virtual void setCondition(const ConditionScript &condition)
Definition: StopPoint.cc:131