Debugger.h
Go to the documentation of this file.
1 
20 #ifndef DEBUGGERMONITOR_H_Z050WPFH
21 #define DEBUGGERMONITOR_H_Z050WPFH
22 
23 #include "uscxml/messages/Data.h" // for Data
24 #include "uscxml/messages/Event.h" // for Event
27 
28 namespace uscxml {
29 
30 class DebugSession;
31 
32 class USCXML_API Debugger : public InterpreterMonitor {
33 public:
34  Debugger() {
35  }
36  virtual ~Debugger() {}
37 
38  virtual void attachSession(InterpreterImpl* impl, std::shared_ptr<DebugSession> session) {
39  std::lock_guard<std::recursive_mutex> lock(_sessionMutex);
40  _sessionForInterpreter[impl] = session;
41  }
42 
43  virtual void detachSession(InterpreterImpl* impl) {
44  std::lock_guard<std::recursive_mutex> lock(_sessionMutex);
45  _sessionForInterpreter.erase(impl);
46  }
47 
48  virtual std::shared_ptr<DebugSession> getSession(InterpreterImpl* impl) {
49  std::lock_guard<std::recursive_mutex> lock(_sessionMutex);
50  if (_sessionForInterpreter.find(impl) != _sessionForInterpreter.end())
51  return _sessionForInterpreter[impl];
52  return std::shared_ptr<DebugSession>();
53  }
54 
55  virtual void pushData(std::shared_ptr<DebugSession> session, Data pushData) = 0;
56 
57  // InterpreterMonitor
58  virtual void beforeProcessingEvent(Interpreter& interpreter, const Event& event);
59  virtual void beforeMicroStep(Interpreter& interpreter);
60  virtual void beforeExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
61  virtual void afterExitingState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
62  virtual void beforeExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* execContent);
63  virtual void afterExecutingContent(Interpreter& interpreter, const XERCESC_NS::DOMElement* execContent);
64  virtual void beforeUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid);
65  virtual void afterUninvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid);
66  virtual void beforeTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition);
67  virtual void afterTakingTransition(Interpreter& interpreter, const XERCESC_NS::DOMElement* transition);
68  virtual void beforeEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
69  virtual void afterEnteringState(Interpreter& interpreter, const XERCESC_NS::DOMElement* state);
70  virtual void beforeInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid);
71  virtual void afterInvoking(Interpreter& interpreter, const XERCESC_NS::DOMElement* invokeElem, const std::string& invokeid);
72  virtual void afterMicroStep(Interpreter& interpreter);
73  virtual void onStableConfiguration(Interpreter& interpreter);
74  virtual void beforeCompletion(Interpreter& interpreter);
75  virtual void afterCompletion(Interpreter& interpreter);
76 
77 protected:
78 
79  void handleTransition(Interpreter& interpreter,
80  const XERCESC_NS::DOMElement* transition,
81  Breakpoint::When when);
82  void handleState(Interpreter& interpreter,
83  const XERCESC_NS::DOMElement* state,
84  Breakpoint::When when,
85  Breakpoint::Action action);
86  void handleInvoke(Interpreter& interpreter,
87  const XERCESC_NS::DOMElement* invokeElem,
88  const std::string& invokeId,
89  Breakpoint::When when,
90  Breakpoint::Action action);
91  void handleExecutable(Interpreter& interpreter,
92  const XERCESC_NS::DOMElement* execContentElem,
93  Breakpoint::When when);
94  void handleStable(Interpreter& interpreter, Breakpoint::When when);
95  void handleMicrostep(Interpreter& interpreter, Breakpoint::When when);
96  void handleEvent(Interpreter& interpreter, const Event& event, Breakpoint::When when);
97 
98  std::list<Breakpoint> getQualifiedTransBreakpoints(InterpreterImpl* impl,
99  const XERCESC_NS::DOMElement* transition,
100  Breakpoint breakpointTemplate);
101  std::list<Breakpoint> getQualifiedStateBreakpoints(InterpreterImpl* impl,
102  const XERCESC_NS::DOMElement* state,
103  Breakpoint breakpointTemplate);
104  std::list<Breakpoint> getQualifiedInvokeBreakpoints(InterpreterImpl* impl,
105  const XERCESC_NS::DOMElement* invokeElem,
106  const std::string invokeId,
107  Breakpoint breakpointTemplate);
108 
109  std::recursive_mutex _sessionMutex;
111  std::map<InterpreterImpl*, std::shared_ptr<DebugSession> > _sessionForInterpreter;
112 };
113 
114 }
115 
116 
117 #endif /* end of include guard: DEBUGGERMONITOR_H_Z050WPFH */
Definition: Breakpoint.cpp:26
Definition: InterpreterMonitor.h:57
Central class to interpret and process SCXML documents.
Definition: Interpreter.h:79
std::map< InterpreterImpl *, std::shared_ptr< DebugSession > > _sessionForInterpreter
Definition: Debugger.h:111
Definition: InterpreterImpl.h:51
Definition: Event.h:94
Definition: Breakpoint.h:36
Definition: Debugger.h:32
Definition: Data.h:44