DebugSession.h
Go to the documentation of this file.
1 
20 #ifndef DEBUGSESSION_H_M8YHEGV6
21 #define DEBUGSESSION_H_M8YHEGV6
22 
24 #include "uscxml/Interpreter.h"
26 
27 #include <time.h>
28 #include <set>
29 #include <thread>
30 #include <condition_variable>
31 
32 namespace uscxml {
33 
34 class Debugger;
35 
36 class USCXML_API DebugSession : public LoggerImpl ,public std::enable_shared_from_this<DebugSession> {
37 public:
38  DebugSession() {
39  _isRunning = false;
40  _isStepping = false;
41  _isAttached = false;
42  _breakpointsEnabled = true;
43  _markedForDeletion = false;
44  _debugger = NULL;
45  }
46 
47  void stepping(bool enable) {
48  _isStepping = enable;
49  }
50 
51  void checkBreakpoints(const std::list<Breakpoint> qualifiedBreakpoints);
52 
53  Data debugPrepare(const Data& data);
54  Data debugAttach(const Data& data);
55  Data debugDetach(const Data& data);
56  Data debugStart(const Data& data);
57  Data debugStop(const Data& data);
58  Data debugStep(const Data& data);
59  Data debugResume(const Data& data);
60  Data debugPause(const Data& data);
61  Data skipToBreakPoint(const Data& data);
62  Data addBreakPoint(const Data& data);
63  Data removeBreakPoint(const Data& data);
64  Data enableBreakPoint(const Data& data);
65  Data disableBreakPoint(const Data& data);
66  Data enableAllBreakPoints();
67  Data disableAllBreakPoints();
68  Data debugEval(const Data& data);
69 
70  void setDebugger(Debugger* debugger) {
71  _debugger = debugger;
72  }
73 
74  Interpreter getInterpreter() {
75  return _interpreter;
76  }
77 
78  void markForDeletion(bool mark) {
79  _markedForDeletion = mark;
80  }
81 
82  // Logger
83  virtual std::shared_ptr<LoggerImpl> create();
84 
85  virtual void log(LogSeverity severity, const Event& event);
86  virtual void log(LogSeverity severity, const Data& data);
87  virtual void log(LogSeverity severity, const std::string& message);
88 
89 protected:
90  void breakExecution(Data replyData);
91 
92  bool _isStepping;
93  bool _isAttached;
94  bool _breakpointsEnabled;
95 
96  std::condition_variable_any _resumeCond;
97  std::recursive_mutex _runMutex;
98  std::recursive_mutex _mutex;
99 
100  std::thread* _interpreterThread = NULL;
101  bool _isRunning;
102  static void run(void* instance);
103 
104  bool _markedForDeletion;
105  Debugger* _debugger;
106  Interpreter _interpreter;
107  std::set<Breakpoint> _breakPoints;
108  Breakpoint _skipTo;
109 
110  friend class Debugger;
111 };
112 
113 
114 }
115 
116 
117 #endif /* end of include guard: DEBUGSESSION_H_M8YHEGV6 */
Definition: Breakpoint.cpp:26
Definition: LoggingImpl.h:36
Central class to interpret and process SCXML documents.
Definition: Interpreter.h:79
Definition: Event.h:84
Definition: Breakpoint.h:36
Definition: Debugger.h:32
Definition: Data.h:43
Definition: DebugSession.h:36