27class WatchPoint :
public Clock::HandlerBase::AttachPoint,
public Event::HandlerBase::AttachPoint
30 static const uint32_t VMASK = 0x10;
39 virtual bool check() = 0;
40 virtual ~Logic() =
default;
50 virtual ~WPAction() =
default;
51 virtual std::string actionToString() = 0;
52 virtual void invokeAction(WatchPoint* wp) = 0;
53 inline void setVerbosity(uint32_t v) { verbosity = v; }
56 uint32_t verbosity = 0;
57 inline void msg(
const std::string& msg)
59 if ( WatchPoint::VMASK & verbosity ) std::cout << msg << std::endl;
63 class InteractiveWPAction :
public WPAction
66 InteractiveWPAction() {}
67 virtual ~InteractiveWPAction() =
default;
68 inline std::string actionToString()
override {
return "interactive"; }
69 void invokeAction(WatchPoint* wp)
override;
72 class PrintTraceWPAction :
public WPAction
75 PrintTraceWPAction() {}
76 virtual ~PrintTraceWPAction() =
default;
77 inline std::string actionToString()
override {
return "printTrace"; }
78 void invokeAction(WatchPoint* wp)
override;
81 class CheckpointWPAction :
public WPAction
84 CheckpointWPAction() {}
85 virtual ~CheckpointWPAction() =
default;
86 inline std::string actionToString()
override {
return "checkpoint"; }
87 void invokeAction(WatchPoint* wp)
override;
90 class PrintStatusWPAction :
public WPAction
93 PrintStatusWPAction() {}
94 virtual ~PrintStatusWPAction() =
default;
95 inline std::string actionToString()
override {
return "printStatus"; }
96 void invokeAction(WatchPoint* wp)
override;
99 class SetVarWPAction :
public WPAction
107 virtual ~SetVarWPAction() =
default;
108 inline std::string actionToString()
override {
return "set " + name_ +
" " + valStr_; }
109 void invokeAction(WatchPoint* wp)
override;
112 std::string name_ =
"";
114 std::string valStr_ =
"";
117 class ShutdownWPAction :
public WPAction
120 ShutdownWPAction() {}
121 virtual ~ShutdownWPAction() =
default;
122 inline std::string actionToString()
override {
return "shutdown"; }
123 void invokeAction(WatchPoint* wp)
override;
128 ~WatchPoint() =
default;
135 void beforeHandler(uintptr_t UNUSED(key),
const Event* UNUSED(ev))
override;
136 void afterHandler(uintptr_t UNUSED(key))
override;
139 void beforeHandler(uintptr_t UNUSED(key),
const Cycle_t& UNUSED(cycle))
override;
140 void afterHandler(uintptr_t UNUSED(key),
const bool& UNUSED(ret))
override;
143 inline std::string getName() {
return name_; }
144 size_t getBufferSize();
145 void printTriggerRecord();
148 enum HANDLER :
unsigned {
159 inline void setVerbosity(uint32_t v)
162 wpAction->setVerbosity(v);
164 inline void msg(
const std::string& msg)
166 if ( VMASK & verbosity ) std::cout << msg << std::endl;
168 void setHandler(
unsigned handlerType);
169 std::string handlerToString(HANDLER h);
170 void printHandler(std::stringstream& ss);
171 void genericHandler(HANDLER h);
172 void printWatchpoint(std::stringstream& ss);
173 void resetTraceBuffer();
174 inline bool checkReset() {
return reset_; }
175 void printAction(std::stringstream& ss);
176 void addTraceBuffer(Core::Serialization::TraceBuffer* tb);
177 void addObjectBuffer(Core::Serialization::ObjectBuffer* ob);
178 void addComparison(Core::Serialization::ObjectMapComparison* cmp);
180 enum LogicOp :
unsigned {
185 inline void addLogicOp(LogicOp op) { logicOps_.push_back(op); }
186 inline void setAction(
WPAction* action) { wpAction = action; }
189 bool getInteractive();
190 void setEnterInteractive();
191 void setInteractiveMsg(
const std::string& msg);
192 SimTime_t getCurrentSimCycle();
193 void setCheckpoint();
196 void simulationShutdown();
199 size_t numCmpObj_ = 0;
200 std::vector<Core::Serialization::ObjectMapComparison*> cmpObjects_;
201 std::vector<LogicOp> logicOps_;
203 Core::Serialization::TraceBuffer* tb_ =
nullptr;
205 HANDLER handler = ALL;
206 bool trigger =
false;
207 HANDLER triggerHandler = HANDLER::NONE;
208 size_t triggerCount = 0;
212 void setBufferReset();
214 uint32_t verbosity = 0;