summaryrefslogtreecommitdiffstats
path: root/src/uscxml/debug
diff options
context:
space:
mode:
authorStefan Radomski <github@mintwerk.de>2016-06-23 11:06:59 (GMT)
committerStefan Radomski <github@mintwerk.de>2016-06-23 11:06:59 (GMT)
commit64298f234d4751d094ef91833830337417404e82 (patch)
tree93a2ec8a1674353a6125787267699d326967bc4f /src/uscxml/debug
parent0e0be07906a720ae54e4572d6ac0cb657424550d (diff)
downloaduscxml-64298f234d4751d094ef91833830337417404e82.zip
uscxml-64298f234d4751d094ef91833830337417404e82.tar.gz
uscxml-64298f234d4751d094ef91833830337417404e82.tar.bz2
Smaller bug-fixes and refactorings
Diffstat (limited to 'src/uscxml/debug')
-rw-r--r--src/uscxml/debug/DebugSession.cpp48
-rw-r--r--src/uscxml/debug/DebugSession.h1
-rw-r--r--src/uscxml/debug/DebuggerServlet.cpp5
-rw-r--r--src/uscxml/debug/DebuggerServlet.h6
4 files changed, 48 insertions, 12 deletions
diff --git a/src/uscxml/debug/DebugSession.cpp b/src/uscxml/debug/DebugSession.cpp
index ef4d469..042235e 100644
--- a/src/uscxml/debug/DebugSession.cpp
+++ b/src/uscxml/debug/DebugSession.cpp
@@ -21,6 +21,8 @@
#include "uscxml/debug/Debugger.h"
#include "uscxml/util/Predicates.h"
+#include <easylogging++.h>
+
namespace uscxml {
void DebugSession::checkBreakpoints(const std::list<Breakpoint> qualifiedBreakpoints) {
@@ -177,15 +179,39 @@ Data DebugSession::debugStart(const Data& data) {
replyData.compound["reason"] = Data("No interpreter attached or loaded", Data::VERBATIM);
replyData.compound["status"] = Data("failure", Data::VERBATIM);
} else {
- //_interpreter.start();
- assert(false);
-
+ _isRunning = true;
+ _interpreterThread = new std::thread(DebugSession::run, this);
replyData.compound["status"] = Data("success", Data::VERBATIM);
}
return replyData;
}
+void DebugSession::run(void* instance) {
+ DebugSession* INSTANCE = (DebugSession*)instance;
+
+#ifdef APPLE
+ std::string threadName;
+ threadName += "uscxml::";
+ threadName += (INSTANCE->_interpreter.getImpl()->_name.size() > 0 ? INSTANCE->_interpreter.getImpl()->_name : "anon");
+ threadName += ".debug";
+
+ pthread_setname_np(threadName.c_str());
+#endif
+
+ InterpreterState state = USCXML_UNDEF;
+ while(state != USCXML_FINISHED && INSTANCE->_isRunning) {
+ state = INSTANCE->_interpreter.step(100);
+
+ // if (!INSTANCE->_isStarted) {
+ // // we have been cancelled
+ // INSTANCE->_isActive = false;
+ // return;
+ // }
+ }
+ LOG(DEBUG) << "done";
+}
+
Data DebugSession::debugStop(const Data& data) {
Data replyData;
@@ -194,9 +220,11 @@ Data DebugSession::debugStop(const Data& data) {
_debugger->detachSession(_interpreter.getImpl().get());
}
- if (_interpreter && !_isAttached)
- assert(false);
- //_interpreter.stop();
+ if (_isRunning && _interpreterThread != NULL) {
+ _isRunning = false;
+ _interpreterThread->join();
+ delete(_interpreterThread);
+ }
// unblock
_resumeCond.notify_all();
@@ -218,9 +246,11 @@ Data DebugSession::debugStep(const Data& data) {
Data replyData;
if (_interpreter) {
// register ourself as a monitor
- if (!_isRunning)
- //_interpreter.start();
- assert(false);
+ if (!_isRunning) {
+ _isRunning = true;
+ _interpreterThread = new std::thread(DebugSession::run, this);
+
+ }
replyData.compound["status"] = Data("success", Data::VERBATIM);
} else {
diff --git a/src/uscxml/debug/DebugSession.h b/src/uscxml/debug/DebugSession.h
index a1ecaa0..c4f2564 100644
--- a/src/uscxml/debug/DebugSession.h
+++ b/src/uscxml/debug/DebugSession.h
@@ -90,6 +90,7 @@ protected:
std::thread* _interpreterThread = NULL;
bool _isRunning;
+ static void run(void* instance);
bool _markedForDeletion;
Debugger* _debugger;
diff --git a/src/uscxml/debug/DebuggerServlet.cpp b/src/uscxml/debug/DebuggerServlet.cpp
index 2b035a6..25df9dd 100644
--- a/src/uscxml/debug/DebuggerServlet.cpp
+++ b/src/uscxml/debug/DebuggerServlet.cpp
@@ -87,7 +87,7 @@ void DebuggerServlet::handleCORS(const HTTPServer::Request& request) {
HTTPServer::reply(corsReply);
}
-bool DebuggerServlet::httpRecvRequest(const HTTPServer::Request& request) {
+bool DebuggerServlet::requestFromHTTP(const HTTPServer::Request& request) {
if (!request.data.hasKey("path"))
return false; // returnError(request);
@@ -238,6 +238,9 @@ void DebuggerServlet::processListSessions(const HTTPServer::Request& request) {
returnData(request, replyData);
}
+void DebuggerServlet::handle(const el::LogDispatchData* data) {
+}
+
/*
void DebuggerServlet::send(google::LogSeverity severity, const char* full_filename,
const char* base_filename, int line,
diff --git a/src/uscxml/debug/DebuggerServlet.h b/src/uscxml/debug/DebuggerServlet.h
index dc6b0ee..2ed1879 100644
--- a/src/uscxml/debug/DebuggerServlet.h
+++ b/src/uscxml/debug/DebuggerServlet.h
@@ -29,7 +29,7 @@
namespace uscxml {
-class USCXML_API DebuggerServlet : public Debugger, public HTTPServlet {
+class USCXML_API DebuggerServlet : public Debugger, public HTTPServlet, public el::LogDispatchCallback {
public:
class LogMessage : public Data {
public:
@@ -58,7 +58,7 @@ public:
bool isCORS(const HTTPServer::Request& request);
void handleCORS(const HTTPServer::Request& request);
- bool httpRecvRequest(const HTTPServer::Request& request);
+ bool requestFromHTTP(const HTTPServer::Request& request);
void setURL(const std::string& url) {
_url = url;
}
@@ -92,6 +92,8 @@ public:
const struct ::tm* tm_time,
const char* message, size_t message_len);
*/
+ void handle(const el::LogDispatchData* data);
+
protected:
void serverPushData(std::shared_ptr<DebugSession>);