void CmdEval::onClientImpl(DebuggerClient &client) { m_body = client.getCode(); m_frame = client.getFrame(); m_bypassAccessCheck = client.getDebuggerBypassCheck(); DebuggerCommandPtr res = client.xendWithNestedExecution<DebuggerCommand>(this); if (!res->is(m_type)) { assert(client.isApiMode()); m_incomplete = true; res->setClientOutput(client); } else { res->handleReply(client); } }
void CmdEval::onClientImpl(DebuggerClient &client) { m_body = client.getCode(); m_frame = client.getFrame(); m_bypassAccessCheck = client.getDebuggerBypassCheck(); client.sendToServer(this); DebuggerCommandPtr res = client.recvFromServer(m_type); if (!res->is(m_type)) { assert(client.isApiMode()); m_incomplete = true; res->setClientOutput(client); } else { res->handleReply(client); } }
bool CmdEval::onClient(DebuggerClient *client) { m_body = client->getCode(); m_frame = client->getFrame(); m_bypassAccessCheck = client->getDebuggerBypassCheck(); client->send(this); DebuggerCommandPtr res = client->recv(m_type); if (!res->is(m_type)) { assert(client->isApiMode()); m_incomplete = true; res->setClientOutput(client); } else { res->handleReply(client); } return true; }
Variant c_DebuggerClient::t_processcmd(CVarRef cmdName, CVarRef args) { INSTANCE_METHOD_INJECTION_BUILTIN(DebuggerClient, DebuggerClient::processcmd); if (!m_client || m_client->getClientState() < DebuggerClient::StateReadyForCommand) { raise_warning("client is not initialized"); return null; } if (m_client->getClientState() != DebuggerClient::StateReadyForCommand) { raise_warning("client is not ready to take command"); return null; } if (!cmdName.isString()) { raise_warning("cmdName must be string"); return null; } if (!args.isNull() && !args.isArray()) { raise_warning("args must be null or array"); return null; } static const char *s_allowedCmds[] = { "break", "continue", "down", "exception", "frame", "global", "help", "info", "konstant", "next", "out", "print", "quit", "step", "up", "variable", "where", "bt", "set", "inst", "=", "@", NULL }; bool allowed = false; for (int i = 0; ; i++) { const char *cmd = s_allowedCmds[i]; if (cmd == NULL) { break; } if (cmdName.same(cmd)) { allowed = true; break; } } if (!allowed) { raise_warning("unsupported command %s", cmdName.toString().data()); return null; } m_client->setCommand(cmdName.toString().data()); StringVec *clientArgs = m_client->args(); clientArgs->clear(); if (!args.isNull()) { for (ArrayIter iter(args.toArray()); iter; ++iter) { CStrRef arg = iter.second().toString(); clientArgs->push_back(std::string(arg.data(), arg.size())); } } try { if (!m_client->process()) { raise_warning("command \"%s\" not found", cmdName.toString().data()); } } catch (DebuggerConsoleExitException &e) { // Flow-control command goes here Logger::Info("wait for debugger client to stop"); m_client->setTakingInterrupt(); m_client->setClientState(DebuggerClient::StateBusy); DebuggerCommandPtr cmd = m_client->waitForNextInterrupt(); if (!cmd) { raise_warning("not getting a command"); } else if (cmd->is(DebuggerCommand::KindOfInterrupt)) { CmdInterruptPtr cmdInterrupt = dynamic_pointer_cast<CmdInterrupt>(cmd); cmdInterrupt->onClientD(m_client); } else { // Previous pending commands cmd->handleReply(m_client); cmd->setClientOutput(m_client); } Logger::Info("debugger client ready for command"); } catch (DebuggerClientExitException &e) { const std::string& nameStr = m_client->getNameApi(); Logger::Info("client %s disconnected", nameStr.c_str()); s_dbgCltMap.erase(nameStr); delete m_client; m_client = NULL; return true; } catch (DebuggerProtocolException &e) { raise_warning("DebuggerProtocolException"); return null; } return m_client->getOutputArray(); }