OpenASIP  2.0
Breakpoint.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2010 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 Breakpoint.cc
26  *
27  * Definition of Breakpoint class.
28  *
29  * @author Atte Oksman 2005 (oksman-no.spam-cs.tut.fi)
30  * @author Pekka Jääskeläinen 2005,2010
31  * @note rating: red
32  */
33 
34 #include "Breakpoint.hh"
35 #include "ConditionScript.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 address The address.
46  */
48  SimulatorFrontend& frontend,
49  InstructionAddress address) :
50  StopPoint(), address_(address), frontend_(frontend) {
51 }
52 
53 /**
54  * Destructor.
55  */
57 }
58 
59 /**
60  * Copy method for dynamically bound copies.
61  */
62 StopPoint*
64  StopPoint* aCopy = new Breakpoint(frontend_, address_);
65  if (conditional_) {
66  assert(condition_ != NULL);
67  ConditionScript* conditionCopy = condition_->copy();
68  assert(conditionCopy != NULL);
69  aCopy->setCondition(*conditionCopy);
70  } else {
71  aCopy->removeCondition();
72  }
73  aCopy->setEnabled(enabled_);
77  return aCopy;
78 }
79 
80 /**
81  * Returns the address the breakpoint is watching.
82  *
83  * @return The address.
84  */
87  return address_;
88 }
89 
90 /**
91  * Sets the address the breakpoint is watching.
92  *
93  * @param newAddress The address.
94  */
95 void
97  address_ = newAddress;
98 }
99 
100 /**
101  * Returns true in case this break point is triggered.
102  *
103  * In case the current program counter is the address this break point is
104  * watching, and the general condition is ok, this method returns true.
105  *
106  * @return The status of the breakpoint.
107  */
108 bool
110  return frontend_.programCounter() == address_;
111 }
112 
113 /**
114  * Prints the description string of the stop point.
115  *
116  * Each subclass overrides this method to construct a descripting string of
117  * itself.
118  */
119 std::string
121  return std::string("at address ") + Conversion::toString(address_) +
122  std::string(" ") + StopPoint::description();
123 }
124 
Breakpoint::frontend_
SimulatorFrontend & frontend_
The simulator frontend which is used to fetch the current PC.
Definition: Breakpoint.hh:69
StopPoint::conditional_
bool conditional_
Tells whether the breakpoint is conditional or not.
Definition: StopPoint.hh:91
InstructionAddress
UInt32 InstructionAddress
Definition: BaseType.hh:175
Breakpoint::address
virtual InstructionAddress address() const
Definition: Breakpoint.cc:86
Breakpoint::setAddress
virtual void setAddress(InstructionAddress newAddress)
Definition: Breakpoint.cc:96
StopPoint::setEnabled
virtual void setEnabled(bool flag)
Definition: StopPoint.cc:63
BaseType.hh
StopPoint::setIgnoreCount
virtual void setIgnoreCount(unsigned int count)
Definition: StopPoint.cc:182
StopPoint::setDisabledAfterTriggered
virtual void setDisabledAfterTriggered(bool flag)
Definition: StopPoint.cc:85
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
Breakpoint::address_
InstructionAddress address_
The address of the breakpoint. A breakpoint is fired when PC equals this address.
Definition: Breakpoint.hh:67
StopPoint::condition_
ConditionScript * condition_
The condition which is used to determine whether the breakpoint should be fired or not.
Definition: StopPoint.hh:94
Breakpoint::copy
virtual StopPoint * copy() const
Definition: Breakpoint.cc:63
ConditionScript.hh
Conversion::toString
static std::string toString(const T &source)
SimulatorConstants.hh
ConditionScript
Definition: ConditionScript.hh:45
assert
#define assert(condition)
Definition: Application.hh:86
SimulatorFrontend::programCounter
InstructionAddress programCounter() const
Definition: SimulatorFrontend.cc:1169
Breakpoint::description
virtual std::string description() const
Definition: Breakpoint.cc:120
StopPoint
Definition: StopPoint.hh:53
Breakpoint::~Breakpoint
virtual ~Breakpoint()
Definition: Breakpoint.cc:56
Conversion.hh
Breakpoint::Breakpoint
Breakpoint(SimulatorFrontend &frontend, InstructionAddress address)
Definition: Breakpoint.cc:47
Application.hh
Breakpoint.hh
SimulatorFrontend.hh
StopPoint::deletedAfterTriggered_
bool deletedAfterTriggered_
Tells if the breakpoint is deleted after it is triggered the next time.
Definition: StopPoint.hh:89
StopPoint::disabledAfterTriggered_
bool disabledAfterTriggered_
Tells if the breakpoint is disabled after it is triggered the next time.
Definition: StopPoint.hh:87
Breakpoint::isTriggered
virtual bool isTriggered() const
Definition: Breakpoint.cc:109
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
SimulatorFrontend
Definition: SimulatorFrontend.hh:89
StopPoint::setCondition
virtual void setCondition(const ConditionScript &condition)
Definition: StopPoint.cc:131