bool CmdMachine::AttachSandbox(DebuggerClient &client, DSandboxInfoPtr sandbox, bool force /* = false */) { if (client.isLocal()) { client.error("Local script doesn't have sandbox to attach to."); return false; } CmdMachine cmd; cmd.m_body = "attach"; cmd.m_sandboxes.push_back(sandbox); cmd.m_force = force; client.info("Attaching to %s and pre-loading, please wait...", sandbox->desc().c_str()); CmdMachinePtr cmdMachine = client.xend<CmdMachine>(&cmd); if (cmdMachine->m_succeed) { client.playMacro("startup"); } else { // Note: it would be nice to give them more info about the process we think // is debugging this sandbox: what machine it's on, what it's pid is, etc. // Unfortunately, we don't have any of that data. We'd need a protocol // change to have the client give us more info when it attaches. client.error( "Failed to attach to the sandbox. Maybe another client is debugging, \n" "or a client failed to detach cleanly.\n" "You can attach to another sandbox, or exit the other attached client, \n" "or force this client to take over the sandbox with: \n" "\n" "\t[m]achine [a]ttach [f]orce %s %s" "\n", sandbox->m_user.c_str(), sandbox->m_name.c_str()); } return cmdMachine->m_succeed; }
bool CmdMachine::AttachSandbox(DebuggerClient &client, DSandboxInfoPtr sandbox, bool force /* = false */) { if (client.isLocal()) { client.error("Local script doesn't have sandbox to attach to."); return false; } CmdMachine cmd; cmd.m_body = "attach"; cmd.m_sandboxes.push_back(sandbox); cmd.m_force = force; client.info("Attaching to %s and pre-loading, please wait...", sandbox->desc().c_str()); CmdMachinePtr cmdMachine = client.xend<CmdMachine>(&cmd); if (cmdMachine->m_succeed) { client.playMacro("startup"); } else { client.error("failed to attach to sandbox, maybe another client is " "debugging, \nattach to another sandbox, exit the " "attached hphpd client, or try \n" "[m]achine [a]ttach [f]orce [%s] [%s]", sandbox->m_user.c_str(), sandbox->m_name.c_str()); } return cmdMachine->m_succeed; }