static ClRcT clMsgDebugCliQueueInfo(ClUint32T argc, ClCharT **argv, ClCharT **ret) { ClRcT rc = CL_OK; ClDebugPrintHandleT dbgHdl = 0; clDebugPrintInitialize(&dbgHdl); CL_OSAL_MUTEX_LOCK(&gClLocalQsLock); rc = clHandleWalk(gClMsgQDatabase, clMsgQueueInfoCb, (ClPtrT)dbgHdl); if (rc != CL_OK) { clLogError("MSG", "CLI", "Handle walk failed, error [%#x]", rc); CL_OSAL_MUTEX_UNLOCK(&gClLocalQsLock); goto out; } CL_OSAL_MUTEX_UNLOCK(&gClLocalQsLock); clDebugPrintFinalize(&dbgHdl, ret); return CL_OK; out: return rc; }
ClRcT clDebugDuplicateCommandDetect(ClDebugObjT *pDebugObj, ClDebugFuncEntryT *pFuncArray, ClUint32T numFunc) { ClUint32T i = 0; ClUint32T j = 0; ClDebugFuncGroupT funcGroup = {0}; ClRcT rc = CL_OK; /* * Detect duplicate entries are there in the passed * List of commands */ for( i = 0; i < numFunc; i++ ) { for( j = 0; j < numFunc; j++ ) { if( i != j ) { if( !(strcasecmp(pFuncArray[i].funcName, pFuncArray[j].funcName)) ) { CL_DEBUG_PRINT(CL_DEBUG_ERROR,("Duplicate command found : %s", pFuncArray[i].funcName)); return CL_DEBUG_RC(CL_ERR_DUPLICATE); } } } } funcGroup.pFuncDescList = pFuncArray; funcGroup.numFunc = numFunc; /* * This will check all the commands registered by this eoObj already * with passed funcGroup. */ rc = clHandleWalk(pDebugObj->hDebugFnDB, clDebugDuplicateDetectWalk, &funcGroup); if( CL_OK != rc ) { CL_DEBUG_PRINT(CL_DEBUG_ERROR, ("clHandleWalk(); rc[0x %x]", rc)); } return rc; }
ClRcT clLogHandlerHandleDataDisplay() { ClRcT rc = CL_OK; ClLogClntEoDataT *pClntEoEntry = NULL; CL_LOG_DEBUG_TRACE(("Enter")); rc = clLogClntEoEntryGet(&pClntEoEntry); if( CL_OK != rc ) { return rc; } rc = clHandleWalk(pClntEoEntry->hClntHandleDB, clLogHandlerDataDump, NULL); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clHandleWalk(): rc[0x %x]", rc)); return rc; } CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
ClRcT clLogStreamHandleDataDisplay(ClCharT **ppRet) { ClRcT rc = CL_OK; ClLogClntEoDataT *pClntEoEntry = NULL; CL_LOG_DEBUG_TRACE(("Enter")); rc = clLogClntEoEntryGet(&pClntEoEntry); if( CL_OK != rc ) { return rc; } rc = clHandleWalk(pClntEoEntry->hClntHandleDB, clLogStreamDataDump, (void *)ppRet); if( CL_OK != rc ) { CL_LOG_DEBUG_ERROR(("clHandleWalk(): rc[0x %x]", rc)); return rc; } CL_LOG_DEBUG_TRACE(("Exit")); return rc; }
ClRcT VDECL(clDebugGetContext)(ClEoDataT data, ClBufferHandleT inMsgHdl, ClBufferHandleT outMsgHdl) { ClRcT rc = CL_OK; ClDebugObjT *pDebugObj = (ClDebugObjT *) data; ClVersionT version = {0}; ClIocPhysicalAddressT srcAddr = {0}; if ((NULL == pDebugObj) || (0 == outMsgHdl) || (0 == inMsgHdl)) { clLogWrite(CL_LOG_HANDLE_APP,CL_LOG_WARNING,CL_DEBUG_LIB_CLIENT, CL_LOG_MESSAGE_1_INVALID_PARAMETER,"Invalid debugObj"); return CL_DEBUG_RC(CL_ERR_INVALID_PARAMETER); } /* * Enable the comp status for the debug client to avoid * response failures from node representative in case the bit isnt enabled for cases when * the comp arrival from peer noderep. reaches late. */ if(clRmdSourceAddressGet(&srcAddr) == CL_OK) clIocCompStatusEnable(srcAddr); rc = clXdrUnmarshallClVersionT(inMsgHdl,&version); if (CL_OK != rc) { return rc; } rc = clVersionVerify(&versionDatabase,&version); if (CL_OK != rc) { clXdrMarshallClVersionT(&version,outMsgHdl,0); return rc; } rc = clXdrMarshallArrayClCharT(pDebugObj->compName, CL_DEBUG_COMP_NAME_LEN, outMsgHdl,0); if (CL_OK != rc) { return rc; } rc = clXdrMarshallArrayClCharT(pDebugObj->compPrompt, CL_DEBUG_COMP_PROMPT_LEN, outMsgHdl,0); if (CL_OK != rc) { return rc; } rc = clXdrMarshallClUint32T((&pDebugObj->numFunc), outMsgHdl,0); if (CL_OK != rc) { return rc; } rc = clHandleWalk(pDebugObj->hDebugFnDB, clDebugContexDetailsPack, (ClPtrT) outMsgHdl); if( CL_OK != rc ) { return rc; } return rc; }
ClRcT VDECL(clDebugInvoke)(ClEoDataT data, ClBufferHandleT inMsgHdl, ClBufferHandleT outMsgHdl) { ClRcT rc = CL_OK; ClUint32T i = 0; ClUint32T argc = 0; ClCharT *argv[MAX_ARGS]; ClCharT argBuf[(MAX_ARG_BUF_LEN+1) * MAX_ARGS]; /* +1 for NULL termination */ ClDebugObjT *pDebugObj = (ClDebugObjT*) data; ClCharT *resp = NULL; ClVersionT version = {0}; ClDebugInvokeCookieT invokeCookie = {0}; ClDebugDeferContextT deferContext = {0}; ClRcT retCode = CL_OK; if ((NULL == pDebugObj) || (0 == outMsgHdl)) { clLogWrite( CL_LOG_HANDLE_APP,CL_LOG_CRITICAL,CL_DEBUG_LIB_CLIENT, CL_LOG_MESSAGE_0_MEMORY_ALLOCATION_FAILED); return CL_DEBUG_RC(CL_ERR_INVALID_PARAMETER); } rc = clXdrUnmarshallClVersionT(inMsgHdl,&version); if (CL_OK != rc) { return rc; } rc = clVersionVerify(&versionDatabase,&version); if (CL_OK != rc) { clXdrMarshallClVersionT(&version,outMsgHdl,0); return rc; } rc = clXdrUnmarshallClUint32T(inMsgHdl, &argc); if (CL_OK != rc) { return rc; } if (argc > MAX_ARGS) { DEBUG_CHECK("\r\n too many arguments"); goto L1; } for (i = 0; i < argc; i++) { ClUint32T stringLength = 0; argv[i] = &argBuf[i * (MAX_ARG_BUF_LEN+1)]; rc = clXdrUnmarshallClUint32T(inMsgHdl,&stringLength); if (CL_OK != rc) { return rc; } if (stringLength > MAX_ARG_BUF_LEN) { DEBUG_CHECK("\r\n argument too big"); goto L1; } rc = clXdrUnmarshallArrayClCharT(inMsgHdl,argv[i],stringLength); if (CL_OK != rc) { return rc; } argv[i][stringLength] = '\0'; } if (!strncasecmp(argv[0], "help", 4) && (argc > 1)) { argv[0] = argv[1]; argc = 0; } invokeCookie.pCommandName = argv[0]; invokeCookie.pFuncEntry = NULL; rc = clHandleWalk(pDebugObj->hDebugFnDB, clDebugFuncInvokeCallback, (void *) &invokeCookie); if( CL_DBG_INFO_CMD_FOUND == rc ) { /* this is the indication for command found */ rc = CL_OK; } if( CL_OK != rc ) { DEBUG_CHECK("\r\ncommand not found"); goto L1; } if (invokeCookie.pFuncEntry && invokeCookie.pFuncEntry->fpCallback) { deferContext.outMsgHdl = outMsgHdl; deferContext.defer = CL_FALSE; clOsalTaskDataSet(pDebugObj->debugTaskKey, (ClOsalTaskDataT)&deferContext); rc = invokeCookie.pFuncEntry->fpCallback(argc, argv, &resp); } else { DEBUG_CHECK("\r\ncommand not found"); } L1: retCode = rc; rc = CL_OK; if (!resp) { resp = clHeapAllocate(1); if (resp) resp[0]= '\0'; } if (NULL != resp) { /* * Marshall the response to the out buffer if we aren't deferred. */ if(!deferContext.defer) rc = clDebugResponseMarshall(resp, retCode, outMsgHdl); clHeapFree(resp); resp = NULL; } return rc; }