void CmdMachine::onClientImpl(DebuggerClient &client) { if (DebuggerCommand::displayedHelp(client)) return; if (client.argCount() == 0) { help(client); return; } bool rpc = client.arg(1, "rpc"); if (rpc || client.arg(1, "connect")) { if (client.argCount() != 2) { help(client); return; } string host = client.argValue(2); int port = 0; size_t pos = host.find(":"); if (pos != string::npos) { if (!DebuggerClient::IsValidNumber(host.substr(pos + 1))) { client.error("Port needs to be a number"); help(client); return; } port = atoi(host.substr(pos + 1).c_str()); host = host.substr(0, pos); } if (rpc) { if (client.connectRPC(host, port)) { throw DebuggerConsoleExitException(); } } else { if (client.connect(host, port)) { throw DebuggerConsoleExitException(); } } if (!client.initializeMachine()) { throw DebuggerConsoleExitException(); } return; } if (client.arg(1, "disconnect")) { if (client.disconnect()) { throw DebuggerConsoleExitException(); } if (!client.initializeMachine()) { throw DebuggerConsoleExitException(); } return; } if (client.arg(1, "list")) { processList(client); return; } if (client.arg(1, "attach")) { DSandboxInfoPtr sandbox; string snum = client.argValue(2); if (DebuggerClient::IsValidNumber(snum)) { int num = atoi(snum.c_str()); sandbox = client.getSandbox(num); if (!sandbox) { processList(client, false); sandbox = client.getSandbox(num); if (!sandbox) { client.error("\"%s\" is not a valid sandbox index. Choose one from " "this list:", snum.c_str()); processList(client); return; } } } else { int argBase = 2; if (client.argCount() >= 2 && client.arg(2, "force")) { m_force = true; argBase++; } sandbox = DSandboxInfoPtr(new DSandboxInfo()); if (client.argCount() < argBase) { sandbox->m_user = client.getCurrentUser(); sandbox->m_name = "default"; } else if (client.argCount() == argBase) { sandbox->m_user = client.getCurrentUser(); sandbox->m_name = client.argValue(argBase); } else if (client.argCount() == argBase + 1) { sandbox->m_user = client.argValue(argBase); sandbox->m_name = client.argValue(argBase + 1); } else { help(client); return; } } if (AttachSandbox(client, sandbox, m_force)) { // Attach succeed, wait for next interrupt throw DebuggerConsoleExitException(); } return; } help(client); }