//! //! Run given commands synchronously. Treat each command-line argument as //! one command to be run in the debuggee's context. Invoke echoReq() when //! a command has just been sent successfully. Invoke onRsp() when some //! response is received. Invoke onTimeout() when timeout occurs waiting //! for a response. If rspCopies is non-zero, save responses there upon return. //! If Return true if successful. Return false if timed out. //! bool CmdAgent::runCmds(const CmdLine& cmdLine, StringVec* rspCopies) { if (rspCopies != 0) { rspCopies->reset(); } bool ok = true; unsigned int numArgs = cmdLine.numArgs(); if (numArgs > 1) { String s; String* rspCopy = (rspCopies == 0)? (0): (&s); for (unsigned int i = 1; (i < numArgs) && ok; ++i) { flush(); const String* req = cmdLine.arg(i); unsigned int timeoutInMsecs = UdpClient::ETERNITY; ok = io_->snd(req->raw(), req->byteSize(), dbuggee_, timeoutInMsecs); if (ok) { rspTail_ = 0; echoReq(*req); ok = showRsp(rspCopy); if (rspCopy != 0) { rspCopies->add(*rspCopy); } } } } return ok; }
// // Populate given address range with given command-line arguments. // Assume command-line arguments, if any, are address ranges. Return // true if successful. // bool MiscDbugCmd::getAddrRange(const CmdLine& req, IpAddrSet& addrRange) { addrRange.reset(); size_t numArgs = req.numArgs(); for (size_t i = 1; i < numArgs; ++i) { const String* arg = req.arg(i); char delim = ','; if (!IpAddrSet::isValid(arg->ascii(), delim)) { addrRange.reset(); break; } addrRange.add(arg->ascii(), delim); } bool ok = (addrRange.numAddrs() > 0); return ok; }