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