bool ksmc_getContextForSignal(void* signalUserContext, KSMachineContext* destinationContext) { KSLOG_DEBUG("Get context from signal user context and put into %p.", destinationContext); _STRUCT_MCONTEXT* sourceContext = ((SignalUserContext*)signalUserContext)->UC_MCONTEXT; memcpy(&destinationContext->machineContext, sourceContext, sizeof(destinationContext->machineContext)); destinationContext->thisThread = (thread_t)ksthread_self(); destinationContext->isCrashedContext = true; destinationContext->isSignalContext = true; destinationContext->isStackOverflow = isStackOverflow(destinationContext); getThreadList(destinationContext); KSLOG_TRACE("Context retrieved."); return true; }
bool ksmc_getContextForThread(KSThread thread, KSMachineContext* destinationContext, bool isCrashedContext) { KSLOG_DEBUG("Fill thread 0x%x context into %p. is crashed = %d", thread, destinationContext, isCrashedContext); memset(destinationContext, 0, sizeof(*destinationContext)); destinationContext->thisThread = (thread_t)thread; destinationContext->isCurrentThread = thread == ksthread_self(); destinationContext->isCrashedContext = isCrashedContext; destinationContext->isSignalContext = false; if(ksmc_canHaveCPUState(destinationContext)) { kscpu_getState(destinationContext); } if(ksmc_isCrashedContext(destinationContext)) { destinationContext->isStackOverflow = isStackOverflow(destinationContext); getThreadList(destinationContext); } KSLOG_TRACE("Context retrieved."); return true; }
int CAPerfCfg::initialize() { // construct the CAPerfEvent objects from // CAProfileConfig::m_ctrEventList // CAProfileConfig::m_samplingEventList uint64_t sampleType = 0; bool sampleIdAll = false; bool firstEvent = true; // initialze the m_cpuVec; int ret = getCpuInfo(&m_cpuVec); CA_DBG_PRINTF(3, "Number of CPUs : %d\n.", m_cpuVec.size()); // For per-process get the target pid's thread list; // TODO: Not sure whether we need to maintain per process CAThreadVec. // It may be a problem during PERF fd redirect ?? size_t numPids; pid_t *pids; if (! m_pmuTgt.isSWP()) { m_pmuTgt.getPids(&numPids, &pids); for (int i = 0; i < numPids; i++) { ret = getThreadList(pids[i], &m_threadVec); } } // TODO: check whether the cpu-list in the pmutarget is valid or not ? // iterate over the counting event list... if (m_ctrEventList.size() != 0) { CAEventList::iterator iter = m_ctrEventList.begin(); for (; iter != m_ctrEventList.end(); iter++) { CAPerfEvent evt(*iter, this); m_ctrPerfEventList.push_back(evt); } } m_nbrCtrPerfEvents = m_ctrPerfEventList.size(); if (m_samplingEventList.size() != 0) { CAEventList::iterator iter = m_samplingEventList.begin(); for (; iter != m_samplingEventList.end(); iter++) { CAPerfEvent evt(*iter, this); if (! firstEvent) { evt.setPerfAttrMmap(false); #ifdef LINUX_PERF_MMAP_DATA_SUPPORT evt.setPerfAttrMmapData(false); #endif evt.setPerfAttrComm(false); } firstEvent = false; m_samplingPerfEventList.push_back(evt); sampleType = evt.getSampleType(); #ifdef LINUX_PERF_SAMPLE_ID_ALL_SUPPORT sampleIdAll = evt.getSampleIdAll(); #endif } } m_nbrSamplingPerfEvents = m_samplingPerfEventList.size(); // FIXME; if (sampleType) { m_sampleRecSize = getSampleRecSize(sampleType, sampleIdAll); } // FIXME: just for testing ret = m_dataWriter.init((char *)(getOutputFile().c_str()), isOverwrite()); if (S_OK != ret) { CA_DBG_PRINTF(3, "initializing datafile failed... ret(%d)\n", ret); return E_FAIL; } CA_DBG_PRINTF(3, "initializing datafile succeedded...\n"); return S_OK; }
void processMessage(CMessageBuffer &mb) { ICoven &coven=queryCoven(); MemoryBuffer params; params.swapWith(mb); int fn; params.read(fn); switch (fn) { case MDR_GET_VALUE: { StringAttr id; StringBuffer buf; params.read(id); if (0 == stricmp(id,"threads")) { mb.append(getThreadList(buf).str()); } else if (0 == stricmp(id, "mpqueue")) { mb.append(getReceiveQueueDetails(buf).str()); } else if (0 == stricmp(id, "locks")) { mb.append(querySDS().getLocks(buf).str()); } else if (0 == stricmp(id, "sdsstats")) { mb.append(querySDS().getUsageStats(buf).str()); } else if (0 == stricmp(id, "connections")) { mb.append(querySDS().getConnections(buf).str()); } else if (0 == stricmp(id, "sdssubscribers")) { mb.append(querySDS().getSubscribers(buf).str()); } else if (0 == stricmp(id, "clients")) { mb.append(querySessionManager().getClientProcessList(buf).str()); } else if (0 == stricmp(id, "subscriptions")) { mb.append(getSubscriptionList(buf).str()); } else if (0 == stricmp(id, "mpverify")) { queryWorldCommunicator().verifyAll(buf); mb.append(buf.str()); } else if (0 == stricmp(id, "extconsistency")) { mb.append(querySDS().getExternalReport(buf).str()); } else if (0 == stricmp(id, "build")) { mb.append("$Id: dadiags.cpp 62376 2011-02-04 21:59:58Z sort $"); } else if (0 == stricmp(id, "sdsfetch")) { StringAttr branchpath; params.read(branchpath); Linked<IPropertyTree> sroot = querySDSServer().lockStoreRead(); try { sroot->queryPropTree(branchpath)->serialize(mb); } catch (...) { querySDSServer().unlockStoreRead(); throw; } querySDSServer().unlockStoreRead(); } else if (0 == stricmp(id, "perf")) { getSystemTraceInfo(buf,PerfMonStandard); mb.append(buf.str()); } else if (0 == stricmp(id, "sdssize")) { StringAttr branchpath; params.read(branchpath); Linked<IPropertyTree> sroot = querySDSServer().lockStoreRead(); StringBuffer sbuf; try { toXML(sroot->queryPropTree(branchpath),sbuf); DBGLOG("sdssize '%s' = %d",branchpath.get(),sbuf.length()); } catch (...) { querySDSServer().unlockStoreRead(); throw; } querySDSServer().unlockStoreRead(); mb.append(sbuf.length()); } else if (0 == stricmp(id, "disconnect")) { StringAttr client; params.read(client); SocketEndpoint ep(client); PROGLOG("Dalidiag request to close client connection: %s", client.get()); Owned<INode> node = createINode(ep); queryCoven().disconnect(node); } else if (0 == stricmp(id, "unlock")) { __int64 connectionId; bool disconnect; params.read(connectionId); params.read(disconnect); PROGLOG("Dalidiag request to unlock connection id: %" I64F "x", connectionId); StringBuffer connectionInfo; bool success = querySDSServer().unlock(connectionId, disconnect, connectionInfo); mb.append(success); if (success) mb.append(connectionInfo); } else if (0 == stricmp(id, "save")) { PROGLOG("Dalidiag requests SDS save"); querySDSServer().saveRequest(); } else if (0 == stricmp(id, "settracetransactions")) { PROGLOG("Dalidiag requests Trace Transactions"); if(traceAllTransactions(true)) mb.append("OK - no change"); else mb.append("OK - transaction tracing enabled"); } else if (0 == stricmp(id, "cleartracetransactions")) { PROGLOG("Dalidiag requests Trace Transactions stopped"); if(traceAllTransactions(false)) mb.append("OK - transaction tracing disabled"); else mb.append("OK - no change"); } else if (0 == stricmp(id, "setldapflags")) { unsigned f; params.read(f); PROGLOG("Dalidiag requests setldapflags %d",f); querySessionManager().setLDAPflags(f); } else if (0 == stricmp(id, "getldapflags")) { unsigned f=querySessionManager().getLDAPflags();; mb.append(f); } else if (0 == stricmp(id, "setsdsdebug")) { PROGLOG("Dalidiag setsdsdebug"); unsigned p; params.read(p); StringArray arr; while (p--) { StringAttr s; params.read(s); arr.append(s); } StringBuffer reply; bool success = querySDSServer().setSDSDebug(arr, reply); mb.append(success).append(reply); } else mb.append(StringBuffer("UNKNOWN OPTION: ").append(id).str()); } break; } coven.reply(mb); }