summaryrefslogtreecommitdiffstats
path: root/src/uscxml/debug
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/debug')
-rw-r--r--src/uscxml/debug/DebugSession.cpp147
-rw-r--r--src/uscxml/debug/DebugSession.h13
-rw-r--r--src/uscxml/debug/DebuggerServlet.cpp2
-rw-r--r--src/uscxml/debug/DebuggerServlet.h2
-rw-r--r--src/uscxml/debug/InterpreterIssue.cpp4
5 files changed, 104 insertions, 64 deletions
diff --git a/src/uscxml/debug/DebugSession.cpp b/src/uscxml/debug/DebugSession.cpp
index 9fa09eb..f6b3ae1 100644
--- a/src/uscxml/debug/DebugSession.cpp
+++ b/src/uscxml/debug/DebugSession.cpp
@@ -228,11 +228,13 @@ Data DebugSession::debugStop(const Data& data) {
if (_isRunning && _interpreterThread != NULL) {
_isRunning = false;
+
+ // unblock
+ _resumeCond.notify_all();
+
_interpreterThread->join();
delete(_interpreterThread);
}
- // unblock
- _resumeCond.notify_all();
_skipTo = Breakpoint();
replyData.compound["status"] = Data("success", Data::VERBATIM);
@@ -377,6 +379,7 @@ Data DebugSession::enableAllBreakPoints() {
return replyData;
}
+
Data DebugSession::disableAllBreakPoints() {
Data replyData;
@@ -386,6 +389,38 @@ Data DebugSession::disableAllBreakPoints() {
return replyData;
}
+Data DebugSession::getIssues() {
+ Data replyData;
+
+ std::list<InterpreterIssue> issues = _interpreter.validate();
+ replyData.compound["status"] = Data("success", Data::VERBATIM);
+ for (auto issue : issues) {
+ Data issueData;
+
+ issueData.compound["message"] = Data(issue.message, Data::VERBATIM);
+ issueData.compound["xPath"] = Data(issue.xPath, Data::VERBATIM);
+ issueData.compound["specRef"] = Data(issue.specRef, Data::VERBATIM);
+
+ switch (issue.severity) {
+ case InterpreterIssue::USCXML_ISSUE_FATAL:
+ issueData.compound["severity"] = Data("FATAL", Data::VERBATIM);
+ break;
+ case InterpreterIssue::USCXML_ISSUE_WARNING:
+ issueData.compound["severity"] = Data("WARN", Data::VERBATIM);
+ break;
+ case InterpreterIssue::USCXML_ISSUE_INFO:
+ issueData.compound["severity"] = Data("INFO", Data::VERBATIM);
+ break;
+ default:
+ break;
+ }
+
+ replyData.compound["issues"].array.push_back(issueData);
+ }
+
+ return replyData;
+}
+
Data DebugSession::debugEval(const Data& data) {
Data replyData;
@@ -416,69 +451,69 @@ Data DebugSession::debugEval(const Data& data) {
}
std::shared_ptr<LoggerImpl> DebugSession::create() {
- return shared_from_this();
+ return shared_from_this();
}
void DebugSession::log(LogSeverity severity, const Event& event) {
- Data d;
- d.compound["data"] = event.data;
- d.compound["name"] = Data(event.name);
- d.compound["origin"] = Data(event.origin);
- d.compound["origintype"] = Data(event.origintype);
-
- switch (event.eventType) {
- case Event::Type::INTERNAL:
- d.compound["eventType"] = Data("INTERNAL");
- break;
- case Event::Type::EXTERNAL:
- d.compound["eventType"] = Data("EXTERNAL");
- break;
- case Event::Type::PLATFORM:
- d.compound["eventType"] = Data("PLATFORM");
- break;
- default:
- break;
- }
- if (!event.hideSendId)
- d.compound["sendid"] = Data(event.sendid);
- if (event.invokeid.size() > 0)
- d.compound["invokeid"] = Data(event.invokeid);
-
- // handle params
- Data& params = d.compound["params"];
- bool convertedToArray = false;
- for (auto param : event.params) {
- if (params.compound.find(param.first) != d.compound.end()) {
- // no such key, add as literal data
- d.compound[param.first] = param.second;
- } else if (params.compound[param.first].array.size() > 0 && convertedToArray) {
- // key is already an array
- params.compound[param.first].array.push_back(param.second);
- } else {
- // key already given as literal data, move to array
- Data& existingParam = params.compound[param.first];
- params.compound[param.first].array.push_back(existingParam);
- params.compound[param.first].array.push_back(param.second);
- params.compound[param.first].compound.clear();
- convertedToArray = true;
- }
- }
-
- // handle namelist
- Data& namelist = d.compound["namelist"];
- for (auto name : event.namelist) {
- namelist.compound[name.first] = name.second;
- }
-
- _debugger->pushData(shared_from_this(), d);
+ Data d;
+ d.compound["data"] = event.data;
+ d.compound["name"] = Data(event.name);
+ d.compound["origin"] = Data(event.origin);
+ d.compound["origintype"] = Data(event.origintype);
+
+ switch (event.eventType) {
+ case Event::Type::INTERNAL:
+ d.compound["eventType"] = Data("INTERNAL");
+ break;
+ case Event::Type::EXTERNAL:
+ d.compound["eventType"] = Data("EXTERNAL");
+ break;
+ case Event::Type::PLATFORM:
+ d.compound["eventType"] = Data("PLATFORM");
+ break;
+ default:
+ break;
+ }
+ if (!event.hideSendId)
+ d.compound["sendid"] = Data(event.sendid);
+ if (event.invokeid.size() > 0)
+ d.compound["invokeid"] = Data(event.invokeid);
+
+ // handle params
+ Data& params = d.compound["params"];
+ bool convertedToArray = false;
+ for (auto param : event.params) {
+ if (params.compound.find(param.first) != d.compound.end()) {
+ // no such key, add as literal data
+ d.compound[param.first] = param.second;
+ } else if (params.compound[param.first].array.size() > 0 && convertedToArray) {
+ // key is already an array
+ params.compound[param.first].array.push_back(param.second);
+ } else {
+ // key already given as literal data, move to array
+ Data& existingParam = params.compound[param.first];
+ params.compound[param.first].array.push_back(existingParam);
+ params.compound[param.first].array.push_back(param.second);
+ params.compound[param.first].compound.clear();
+ convertedToArray = true;
+ }
+ }
+
+ // handle namelist
+ Data& namelist = d.compound["namelist"];
+ for (auto name : event.namelist) {
+ namelist.compound[name.first] = name.second;
+ }
+
+ _debugger->pushData(shared_from_this(), d);
}
void DebugSession::log(LogSeverity severity, const Data& data) {
- _debugger->pushData(shared_from_this(), data);
+ _debugger->pushData(shared_from_this(), data);
}
void DebugSession::log(LogSeverity severity, const std::string& message) {
- _debugger->pushData(shared_from_this(), Data(message));
+ _debugger->pushData(shared_from_this(), Data(message));
}
}
diff --git a/src/uscxml/debug/DebugSession.h b/src/uscxml/debug/DebugSession.h
index 9224163..e258568 100644
--- a/src/uscxml/debug/DebugSession.h
+++ b/src/uscxml/debug/DebugSession.h
@@ -66,6 +66,7 @@ public:
Data disableBreakPoint(const Data& data);
Data enableAllBreakPoints();
Data disableAllBreakPoints();
+ Data getIssues();
Data debugEval(const Data& data);
void setDebugger(Debugger* debugger) {
@@ -80,12 +81,12 @@ public:
_markedForDeletion = mark;
}
- // Logger
- virtual std::shared_ptr<LoggerImpl> create();
-
- virtual void log(LogSeverity severity, const Event& event);
- virtual void log(LogSeverity severity, const Data& data);
- virtual void log(LogSeverity severity, const std::string& message);
+ // Logger
+ virtual std::shared_ptr<LoggerImpl> create();
+
+ virtual void log(LogSeverity severity, const Event& event);
+ virtual void log(LogSeverity severity, const Data& data);
+ virtual void log(LogSeverity severity, const std::string& message);
protected:
void breakExecution(Data replyData);
diff --git a/src/uscxml/debug/DebuggerServlet.cpp b/src/uscxml/debug/DebuggerServlet.cpp
index 016d67c..44255c0 100644
--- a/src/uscxml/debug/DebuggerServlet.cpp
+++ b/src/uscxml/debug/DebuggerServlet.cpp
@@ -134,6 +134,8 @@ bool DebuggerServlet::requestFromHTTP(const HTTPServer::Request& request) {
} else if (boost::starts_with(request.data.at("path").atom, "/debug/disconnect")) {
processDisconnect(request);
+ } else if (boost::starts_with(request.data.at("path").atom, "/debug/issues")) {
+ replyData = session->getIssues();
} else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/enable/all")) {
replyData = session->enableAllBreakPoints();
} else if (boost::starts_with(request.data.at("path").atom, "/debug/breakpoint/disable/all")) {
diff --git a/src/uscxml/debug/DebuggerServlet.h b/src/uscxml/debug/DebuggerServlet.h
index 3b117bf..4cd04bb 100644
--- a/src/uscxml/debug/DebuggerServlet.h
+++ b/src/uscxml/debug/DebuggerServlet.h
@@ -50,6 +50,8 @@ public:
void processConnect(const HTTPServer::Request& request);
void processListSessions(const HTTPServer::Request& request);
+ void processIssues(const HTTPServer::Request& request);
+
// void processDebugPrepare(const HTTPServer::Request& request);
// void processDebugAttach(const HTTPServer::Request& request);
// void processDebugStart(const HTTPServer::Request& request);
diff --git a/src/uscxml/debug/InterpreterIssue.cpp b/src/uscxml/debug/InterpreterIssue.cpp
index 90e06b4..4ee4442 100644
--- a/src/uscxml/debug/InterpreterIssue.cpp
+++ b/src/uscxml/debug/InterpreterIssue.cpp
@@ -385,7 +385,7 @@ std::list<InterpreterIssue> InterpreterIssue::forInterpreter(InterpreterImpl* in
// check whether state is reachable
if (!DOMUtils::isMember(state, reachable) && areFromSameMachine(state, interpreter->_scxml)) {
- issues.push_back(InterpreterIssue("State with id '" + stateId + "' is unreachable", state, InterpreterIssue::USCXML_ISSUE_FATAL));
+ issues.push_back(InterpreterIssue("State with id '" + stateId + "' is unreachable", state, InterpreterIssue::USCXML_ISSUE_WARNING));
}
// check for uniqueness of id attribute
@@ -1044,4 +1044,4 @@ std::ostream& operator<< (std::ostream& os, const InterpreterIssue& issue) {
}
-} \ No newline at end of file
+}