OpenASIP 2.2
Loading...
Searching...
No Matches
Watch.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file Watch.cc
26 *
27 * Definition of Watch class.
28 *
29 * @author Pekka Jääskeläinen 2005 (pjaaskel-no.spam-cs.tut.fi)
30 * @note rating: red
31 */
32
33#include "Watch.hh"
34#include "ConditionScript.hh"
35#include "ExpressionScript.hh"
36#include "SimulatorConstants.hh"
37#include "BaseType.hh"
38#include "Application.hh"
39#include "SimulatorFrontend.hh"
40#include "Conversion.hh"
41
42/**
43 * Constructor.
44 *
45 * @param frontend Used to fetch the simulation clock.
46 * @param expression The expression watched.
47 */
49 const SimulatorFrontend& frontend,
50 const ExpressionScript& expression) :
51 StopPoint(), expression_(expression), frontend_(frontend),
52 isTriggered_(false), lastCheckedCycle_(0) {
53}
54
55/**
56 * Destructor.
57 */
60
61/**
62 * Copy method for dynamically bound copies.
63 */
65Watch::copy() const {
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}
81
82/**
83 * Returns the expression.
84 *
85 * @return The expression.
86 */
89 return expression_;
90}
91
92/**
93 * Sets the expression the watch is watching.
94 *
95 * @param expression The new expression.
96 */
97void
101
102/**
103 * Returns true in case this watch is triggered.
104 *
105 * Returns true in case the expression has changed in current simulation cycle.
106 *
107 * @return The status of the watch.
108 */
109bool
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}
126
127/**
128 * Prints the description string of the stop point.
129 *
130 * Each subclass overrides this method to construct a descripting string of
131 * itself.
132 */
133std::string
135 return std::string("watch for expression '") + expression_.script().at(0) +
136 "' " + StopPoint::description();
137}
138
#define assert(condition)
find Finds info of the inner loops in the false
virtual ConditionScript * copy() const
virtual std::vector< std::string > script() const
Definition Script.cc:106
ClockCycleCount cycleCount() const
bool enabled_
Tells whether the breakpoint is enabled or disabled.
Definition StopPoint.hh:84
virtual void removeCondition()
Definition StopPoint.cc:142
virtual std::string description() const =0
Definition StopPoint.cc:239
bool conditional_
Tells whether the breakpoint is conditional or not.
Definition StopPoint.hh:91
virtual void setDeletedAfterTriggered(bool flag)
Definition StopPoint.cc:107
virtual void setEnabled(bool flag)
Definition StopPoint.cc:63
bool disabledAfterTriggered_
Tells if the breakpoint is disabled after it is triggered the next time.
Definition StopPoint.hh:87
bool deletedAfterTriggered_
Tells if the breakpoint is deleted after it is triggered the next time.
Definition StopPoint.hh:89
virtual void setCondition(const ConditionScript &condition)
Definition StopPoint.cc:131
ConditionScript * condition_
The condition which is used to determine whether the breakpoint should be fired or not.
Definition StopPoint.hh:94
unsigned int ignoreCount_
The number of times the condition is to be ignored before enabling the breakpoint.
Definition StopPoint.hh:97
virtual void setDisabledAfterTriggered(bool flag)
Definition StopPoint.cc:85
virtual void setIgnoreCount(unsigned int count)
Definition StopPoint.cc:182
Definition Watch.hh:48
bool isTriggered_
Flag which tells whether the watch was triggered in current simulation cycle.
Definition Watch.hh:71
ClockCycleCount lastCheckedCycle_
The simulation clock cycle in which the expression was checked the last time.
Definition Watch.hh:74
virtual bool isTriggered() const
Definition Watch.cc:110
virtual StopPoint * copy() const
Definition Watch.cc:65
virtual ~Watch()
Definition Watch.cc:58
const SimulatorFrontend & frontend_
The simulator frontend which is used to fetch the current PC.
Definition Watch.hh:68
virtual const ExpressionScript & expression() const
Definition Watch.cc:88
Watch(const SimulatorFrontend &frontend, const ExpressionScript &expression)
Definition Watch.cc:48
virtual void setExpression(const ExpressionScript &expression)
Definition Watch.cc:98
ExpressionScript expression_
The expression that is watched.
Definition Watch.hh:66
virtual std::string description() const
Definition Watch.cc:134