void CmdInstrument::listInst(DebuggerClient &client) { m_type = ActionRead; m_instPoints = client.getInstPoints(); CmdInstrumentPtr instCmdPtr = client.xend<CmdInstrument>(this); client.setInstPoints(instCmdPtr->m_ips); PrintInstPoints(client); }
void CmdInstrument::clearInst(DebuggerClient &client) { m_type = ActionWrite; m_instPoints = client.getInstPoints(); m_instPoints->clear(); CmdInstrumentPtr instCmdPtr = client.xend<CmdInstrument>(this); client.setInstPoints(instCmdPtr->m_ips); PrintInstPoints(client); }
void CmdInstrument::onClientImpl(DebuggerClient &client) { if (DebuggerCommand::displayedHelp(client)) return; if (client.argCount() == 1) { if (client.argValue(1) == "list" || client.argValue(1) == "l") { listInst(client); return; } if (client.argValue(1) == "clear" || client.argValue(1) == "c") { clearInst(client); return; } } if (client.argCount() < 2 || client.argValue(1) == "help") { help(client); return; } std::string loc = client.argValue(1); std::string file = client.argValue(2); std::string desc; if (client.argCount() >= 3) { desc = client.argValue(3); } Variant code = f_file_get_contents(file.c_str()); if (code.isNull()) { client.error("Unable to read from file %s", file.c_str()); return; } m_instPoints = client.getInstPoints(); if (loc == "here") { InstPointInfoPtr ipi(new InstPointInfo()); ipi->setLocHere(); ipi->m_code = (std::string) code.toString(); ipi->m_desc = desc; m_instPoints->push_back(ipi); } else if (loc.rfind("()") == loc.size() - 2){ InstPointInfoPtr ipi(new InstPointInfo()); ipi->setLocFuncEntry(loc.substr(0, loc.size() - 2)); ipi->m_code = (std::string) code.toString(); ipi->m_desc = desc; m_instPoints->push_back(ipi); } else { client.error("Not implemented\n"); return; } m_type = ActionWrite; CmdInstrumentPtr instCmdPtr = client.xend<CmdInstrument>(this); if (!instCmdPtr->m_enabled) { client.error("Instrumentation is not enabled on the server"); } client.setInstPoints(instCmdPtr->m_ips); CmdInstrument::PrintInstPoints(client); }
void CmdInstrument::PrintInstPoints(DebuggerClient &client) { InstPointInfoPtrVec* ips = client.getInstPoints(); int size = ips->size(); client.print("%d instrumentation points", size); for (int i = 0; i < size; i++) { InstPointInfoPtr ipi = (*ips)[i]; if (ipi->m_locType == InstPointInfo::LocFileLine) { client.print(" %d\t%s\t%s\tfile:\t%s:%d", i, ipi->m_valid ? "valid" : "invalid", ipi->m_desc.c_str(), ipi->m_file.c_str(), ipi->m_line); } else if (ipi->m_locType == InstPointInfo::LocFuncEntry) { client.print(" %d\t%s\t%s\tfunc entry:\t%s", i, ipi->m_valid ? "valid" : "invalid", ipi->m_desc.c_str(), ipi->m_func.c_str()); } } }
void CmdInstrument::setClientOutput(DebuggerClient &client) { // Output all instrumentation point info client.setOutputType(DebuggerClient::OTValues); Array values; InstPointInfoPtrVec* ips = client.getInstPoints(); for (unsigned int i = 0; i < ips->size(); i++) { InstPointInfoPtr ipi = (*ips)[i]; Array instpoint; instpoint.set(s_valid, ipi->m_valid); instpoint.set(s_desc, ipi->m_desc); if (ipi->m_locType == InstPointInfo::LocFileLine) { instpoint.set(s_type, s_file_line); instpoint.set(s_file, ipi->m_file); instpoint.set(s_line, ipi->m_line); } else if (ipi->m_locType == InstPointInfo::LocFuncEntry) { instpoint.set(s_type, s_func_entry); instpoint.set(s_func, ipi->m_func); } values.append(instpoint); } client.setOTValues(values); }