diff options
Diffstat (limited to 'src/uscxml/debug')
-rw-r--r-- | src/uscxml/debug/Breakpoint.cpp | 24 | ||||
-rw-r--r-- | src/uscxml/debug/DebugSession.cpp | 40 |
2 files changed, 40 insertions, 24 deletions
diff --git a/src/uscxml/debug/Breakpoint.cpp b/src/uscxml/debug/Breakpoint.cpp index 1e40ee3..3287075 100644 --- a/src/uscxml/debug/Breakpoint.cpp +++ b/src/uscxml/debug/Breakpoint.cpp @@ -86,20 +86,20 @@ Breakpoint::Breakpoint(const Data& data) { if (data.hasKey("eventName")) eventName = data.at("eventName").atom; - if (data.hasKey("executableName")) - executableName = data.at("executableName").atom; + if (data.hasKey("execName")) + executableName = data.at("execName").atom; - if (data.hasKey("executableXPath")) - executableXPath = data.at("executableXPath").atom; + if (data.hasKey("execXPath")) + executableXPath = data.at("execXPath").atom; if (data.hasKey("stateId")) stateId = data.at("stateId").atom; - if (data.hasKey("transSourceId")) - transSourceId = data.at("transSourceId").atom; + if (data.hasKey("source")) + transSourceId = data.at("source").atom; - if (data.hasKey("transTargetId")) - transTargetId = data.at("transTargetId").atom; + if (data.hasKey("target")) + transTargetId = data.at("target").atom; } @@ -173,10 +173,10 @@ Data Breakpoint::toData() const { data.compound["eventName"] = Data(eventName, Data::VERBATIM); if (executableName.length() > 0) - data.compound["executableName"] = Data(executableName, Data::VERBATIM); + data.compound["execName"] = Data(executableName, Data::VERBATIM); if (executableXPath.length() > 0) { - data.compound["executableXPath"] = Data(executableXPath, Data::VERBATIM); + data.compound["execXPath"] = Data(executableXPath, Data::VERBATIM); } if (element) @@ -186,10 +186,10 @@ Data Breakpoint::toData() const { data.compound["stateId"] = Data(stateId, Data::VERBATIM); if (transSourceId.length() > 0) - data.compound["transSourceId"] = Data(transSourceId, Data::VERBATIM); + data.compound["source"] = Data(transSourceId, Data::VERBATIM); if (transTargetId.length() > 0) - data.compound["transTargetId"] = Data(transTargetId, Data::VERBATIM); + data.compound["target"] = Data(transTargetId, Data::VERBATIM); if (condition.length() > 0) data.compound["condition"] = Data(condition, Data::VERBATIM); diff --git a/src/uscxml/debug/DebugSession.cpp b/src/uscxml/debug/DebugSession.cpp index 042235e..60dcdfb 100644 --- a/src/uscxml/debug/DebugSession.cpp +++ b/src/uscxml/debug/DebugSession.cpp @@ -86,7 +86,9 @@ void DebugSession::breakExecution(Data replyData) { replyData.compound["replyType"] = Data("breakpoint", Data::VERBATIM); _debugger->pushData(shared_from_this(), replyData); - _resumeCond.wait(_mutex); + + // wait for resume from the client + _resumeCond.wait(_mutex); } Data DebugSession::debugPrepare(const Data& data) { @@ -102,14 +104,18 @@ Data DebugSession::debugPrepare(const Data& data) { _isAttached = false; - if (data.hasKey("xml")) { - _interpreter = Interpreter::fromXML(data.at("xml").atom, (data.hasKey("url") ? data.at("url").atom : "")); - } else if (data.hasKey("url")) { - _interpreter = Interpreter::fromURL(data.at("url").atom); - } else { - _interpreter = Interpreter(); - } - + try { + if (data.hasKey("xml")) { + _interpreter = Interpreter::fromXML(data.at("xml").atom, (data.hasKey("url") ? data.at("url").atom : "")); + } else if (data.hasKey("url")) { + _interpreter = Interpreter::fromURL(data.at("url").atom); + } else { + _interpreter = Interpreter(); + } + } catch(ErrorEvent e) { + std::cerr << e; + } catch(...) {} + if (_interpreter) { // register ourself as a monitor _interpreter.addMonitor(_debugger); @@ -201,7 +207,7 @@ void DebugSession::run(void* instance) { InterpreterState state = USCXML_UNDEF; while(state != USCXML_FINISHED && INSTANCE->_isRunning) { - state = INSTANCE->_interpreter.step(100); + state = INSTANCE->_interpreter.step(); // if (!INSTANCE->_isStarted) { // // we have been cancelled @@ -288,9 +294,19 @@ Data DebugSession::skipToBreakPoint(const Data& data) { std::lock_guard<std::recursive_mutex> lock(_mutex); _skipTo = Breakpoint(data); + Data replyData; - Data replyData; - replyData.compound["status"] = Data("success", Data::VERBATIM); + if (_interpreter) { + // register ourself as a monitor + if (!_isRunning) { + _isRunning = true; + _interpreterThread = new std::thread(DebugSession::run, this); + } + + replyData.compound["status"] = Data("success", Data::VERBATIM); + } else { + replyData.compound["status"] = Data("failure", Data::VERBATIM); + } _resumeCond.notify_one(); return replyData; |