//++ ------------------------------------------------------------------------------------ // Details: Form MI partial response by appending more MI value type objects to the // tuple type object past in. // Type: Method. // Args: vPc - (R) Address number. // vFnName - (R) Function name. // vFileName - (R) File name text. // vPath - (R) Full file name and path text. // vnLine - (R) File line number. // vwrMIValueTuple - (W) MI value tuple object. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- bool CMICmnLLDBDebugSessionInfo::MIResponseFormBrkPtFrameInfo( const lldb::addr_t vPc, const CMIUtilString & vFnName, const CMIUtilString & vFileName, const CMIUtilString & vPath, const MIuint vnLine, CMICmnMIValueTuple & vwrMiValueTuple ) { const CMIUtilString strAddr( CMIUtilString::Format( "0x%08llx", vPc ) ); const CMICmnMIValueConst miValueConst2( strAddr ); const CMICmnMIValueResult miValueResult2( "addr", miValueConst2 ); if( !vwrMiValueTuple.Add( miValueResult2 ) ) return MIstatus::failure; const CMICmnMIValueConst miValueConst3( vFnName ); const CMICmnMIValueResult miValueResult3( "func", miValueConst3 ); if( !vwrMiValueTuple.Add( miValueResult3 ) ) return MIstatus::failure; const CMICmnMIValueConst miValueConst5( vFileName ); const CMICmnMIValueResult miValueResult5( "file", miValueConst5 ); if( !vwrMiValueTuple.Add( miValueResult5 ) ) return MIstatus::failure; const CMIUtilString strN5 = CMIUtilString::Format( "%s/%s", vPath.c_str(), vFileName.c_str() ); const CMICmnMIValueConst miValueConst6( strN5 ); const CMICmnMIValueResult miValueResult6( "fullname", miValueConst6 ); if( !vwrMiValueTuple.Add( miValueResult6 ) ) return MIstatus::failure; const CMIUtilString strLine( CMIUtilString::Format( "%d", vnLine ) ); const CMICmnMIValueConst miValueConst7( strLine ); const CMICmnMIValueResult miValueResult7( "line", miValueConst7 ); if( !vwrMiValueTuple.Add( miValueResult7 ) ) return MIstatus::failure; return MIstatus::success; }
bool CMICmnLLDBUtilSBValue::GetCompositeValue(const bool vbPrintFieldNames, CMICmnMIValueTuple &vwrMiValueTuple, const MIuint vnDepth /* = 1 */) const { const MIuint nMaxDepth = 10; const MIuint nChildren = m_rValue.GetNumChildren(); for (MIuint i = 0; i < nChildren; ++i) { const lldb::SBValue member = m_rValue.GetChildAtIndex(i); const CMICmnLLDBUtilSBValue utilMember(member, m_bHandleCharType, m_bHandleArrayType); const bool bHandleArrayTypeAsSimple = false; CMIUtilString value; const bool bIsSimpleValue = utilMember.GetSimpleValue(bHandleArrayTypeAsSimple, value); if (bIsSimpleValue) { // OK. Value is simple (not composite) and was successfully got } else if (vnDepth < nMaxDepth) { // Need to get value from composite type CMICmnMIValueTuple miValueTuple; const bool bOk = utilMember.GetCompositeValue(vbPrintFieldNames, miValueTuple, vnDepth + 1); if (!bOk) // Can't obtain composite type value = m_pUnkwn; else // OK. Value is composite and was successfully got value = miValueTuple.GetString(); } else { // Need to get value from composite type, but vnMaxDepth is reached value = m_pComposite; } const bool bNoQuotes = true; const CMICmnMIValueConst miValueConst(value, bNoQuotes); if (vbPrintFieldNames) { const bool bUseSpacing = true; const CMICmnMIValueResult miValueResult(utilMember.GetName(), miValueConst, bUseSpacing); const bool bOk = vwrMiValueTuple.Add(miValueResult, bUseSpacing); if (!bOk) return MIstatus::failure; } else { const bool bUseSpacing = false; const bool bOk = vwrMiValueTuple.Add(miValueConst, bUseSpacing); if (!bOk) return MIstatus::failure; } } return MIstatus::success; }
//++ ------------------------------------------------------------------------------------ // Details: Form MI partial response by appending more MI value type objects to the // tuple type object past in. // Type: Method. // Args: vCmdData - (R) A command's information. // vrThread - (R) LLDB thread object. // vwrMIValueTuple - (W) MI value tuple object. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- bool CMICmnLLDBDebugSessionInfo::MIResponseFormThreadInfo(const SMICmdData &vCmdData, const lldb::SBThread &vrThread, const ThreadInfoFormat_e veThreadInfoFormat, CMICmnMIValueTuple &vwrMIValueTuple) { lldb::SBThread &rThread = const_cast<lldb::SBThread &>(vrThread); const bool bSuspended = rThread.IsSuspended(); const lldb::StopReason eReason = rThread.GetStopReason(); const bool bValidReason = !((eReason == lldb::eStopReasonNone) || (eReason == lldb::eStopReasonInvalid)); const CMIUtilString strState((bSuspended || bValidReason) ? "stopped" : "running"); // Add "id" const CMIUtilString strId(CMIUtilString::Format("%d", rThread.GetIndexID())); const CMICmnMIValueConst miValueConst1(strId); const CMICmnMIValueResult miValueResult1("id", miValueConst1); vwrMIValueTuple.Add(miValueResult1); // Add "target-id" const char *pThreadName = rThread.GetName(); const MIuint len = (pThreadName != nullptr) ? CMIUtilString(pThreadName).length() : 0; const bool bHaveName = ((pThreadName != nullptr) && (len > 0) && (len < 32) && CMIUtilString::IsAllValidAlphaAndNumeric(pThreadName)); // 32 is arbitrary number const char *pThrdFmt = bHaveName ? "%s" : "Thread %d"; CMIUtilString strThread; if (bHaveName) strThread = CMIUtilString::Format(pThrdFmt, pThreadName); else strThread = CMIUtilString::Format(pThrdFmt, rThread.GetIndexID()); const CMICmnMIValueConst miValueConst2(strThread); const CMICmnMIValueResult miValueResult2("target-id", miValueConst2); vwrMIValueTuple.Add(miValueResult2); // Add "frame" if (veThreadInfoFormat != eThreadInfoFormat_NoFrames) { CMIUtilString strFrames; if (!GetThreadFrames(vCmdData, rThread.GetIndexID(), eFrameInfoFormat_AllArgumentsInSimpleForm, strFrames)) return MIstatus::failure; const CMICmnMIValueConst miValueConst3(strFrames, true); vwrMIValueTuple.Add(miValueConst3, false); } // Add "state" const CMICmnMIValueConst miValueConst4(strState); const CMICmnMIValueResult miValueResult4("state", miValueConst4); vwrMIValueTuple.Add(miValueResult4); return MIstatus::success; }
//++ ------------------------------------------------------------------------------------ // Details: Form MI partial response by appending more MI value type objects to the // tuple type object past in. // Type: Method. // Args: vrThread - (R) LLDB thread object. // vwrMIValueTuple - (W) MI value tuple object. // vArgInfo - (R) Args information in MI response form. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- bool CMICmnLLDBDebugSessionInfo::MIResponseFormFrameInfo(const lldb::SBThread &vrThread, const MIuint vnLevel, const FrameInfoFormat_e veFrameInfoFormat, CMICmnMIValueTuple &vwrMiValueTuple) { lldb::SBThread &rThread = const_cast<lldb::SBThread &>(vrThread); lldb::SBFrame frame = rThread.GetFrameAtIndex(vnLevel); lldb::addr_t pc = 0; CMIUtilString fnName; CMIUtilString fileName; CMIUtilString path; MIuint nLine = 0; if (!GetFrameInfo(frame, pc, fnName, fileName, path, nLine)) return MIstatus::failure; // MI print "{level=\"0\",addr=\"0x%016" PRIx64 "\",func=\"%s\",file=\"%s\",fullname=\"%s\",line=\"%d\"}" const CMIUtilString strLevel(CMIUtilString::Format("%d", vnLevel)); const CMICmnMIValueConst miValueConst(strLevel); const CMICmnMIValueResult miValueResult("level", miValueConst); vwrMiValueTuple.Add(miValueResult); const CMIUtilString strAddr(CMIUtilString::Format("0x%016" PRIx64, pc)); const CMICmnMIValueConst miValueConst2(strAddr); const CMICmnMIValueResult miValueResult2("addr", miValueConst2); vwrMiValueTuple.Add(miValueResult2); const CMICmnMIValueConst miValueConst3(fnName); const CMICmnMIValueResult miValueResult3("func", miValueConst3); vwrMiValueTuple.Add(miValueResult3); if (veFrameInfoFormat != eFrameInfoFormat_NoArguments) { CMICmnMIValueList miValueList(true); const MIuint maskVarTypes = eVariableType_Arguments; if (veFrameInfoFormat == eFrameInfoFormat_AllArgumentsInSimpleForm) { if (!MIResponseFormVariableInfo(frame, maskVarTypes, eVariableInfoFormat_AllValues, miValueList, 0)) return MIstatus::failure; } else if (!MIResponseFormVariableInfo(frame, maskVarTypes, eVariableInfoFormat_AllValues, miValueList)) return MIstatus::failure; const CMICmnMIValueResult miValueResult4("args", miValueList); vwrMiValueTuple.Add(miValueResult4); } const CMICmnMIValueConst miValueConst5(fileName); const CMICmnMIValueResult miValueResult5("file", miValueConst5); vwrMiValueTuple.Add(miValueResult5); const CMICmnMIValueConst miValueConst6(path); const CMICmnMIValueResult miValueResult6("fullname", miValueConst6); vwrMiValueTuple.Add(miValueResult6); const CMIUtilString strLine(CMIUtilString::Format("%d", nLine)); const CMICmnMIValueConst miValueConst7(strLine); const CMICmnMIValueResult miValueResult7("line", miValueConst7); vwrMiValueTuple.Add(miValueResult7); return MIstatus::success; }
//++ ------------------------------------------------------------------------------------ // Details: Form MI partial response by appending more MI value type objects to the // tuple type object past in. // Type: Method. // Args: vrBrkPtInfo - (R) Break point information object. // vwrMIValueTuple - (W) MI value tuple object. // Return: None. // Throws: None. //-- void CMICmnLLDBDebugSessionInfo::MIResponseFormBrkPtFrameInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple) { const CMIUtilString strAddr(CMIUtilString::Format("0x%016" PRIx64, vrBrkPtInfo.m_pc)); const CMICmnMIValueConst miValueConst2(strAddr); const CMICmnMIValueResult miValueResult2("addr", miValueConst2); vwrMiValueTuple.Add(miValueResult2); const CMICmnMIValueConst miValueConst3(vrBrkPtInfo.m_fnName); const CMICmnMIValueResult miValueResult3("func", miValueConst3); vwrMiValueTuple.Add(miValueResult3); const CMICmnMIValueConst miValueConst5(vrBrkPtInfo.m_fileName); const CMICmnMIValueResult miValueResult5("file", miValueConst5); vwrMiValueTuple.Add(miValueResult5); const CMIUtilString strN5 = CMIUtilString::Format("%s/%s", vrBrkPtInfo.m_path.c_str(), vrBrkPtInfo.m_fileName.c_str()); const CMICmnMIValueConst miValueConst6(strN5); const CMICmnMIValueResult miValueResult6("fullname", miValueConst6); vwrMiValueTuple.Add(miValueResult6); const CMIUtilString strLine(CMIUtilString::Format("%d", vrBrkPtInfo.m_nLine)); const CMICmnMIValueConst miValueConst7(strLine); const CMICmnMIValueResult miValueResult7("line", miValueConst7); vwrMiValueTuple.Add(miValueResult7); }
//++ ------------------------------------------------------------------------------------ // Details: Retrieve the specified thread's frame information. // Type: Method. // Args: vCmdData - (R) A command's information. // vThreadIdx - (R) Thread index. // vwrThreadFrames - (W) Frame data. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- bool CMICmnLLDBDebugSessionInfo::GetThreadFrames( const SMICmdData & vCmdData, const MIuint vThreadIdx, CMICmnMIValueTuple & vwrThreadFrames ) { lldb::SBThread thread = m_lldbProcess.GetThreadByIndexID( vThreadIdx ); const uint32_t nFrames = thread.GetNumFrames(); if( nFrames == 0 ) { vwrThreadFrames = CMICmnMIValueTuple(); return MIstatus::success; } CMICmnMIValueTuple miValueTupleAll; for( MIuint nLevel = 0; nLevel < nFrames; nLevel++ ) { lldb::SBFrame frame = thread.GetFrameAtIndex( nLevel ); lldb::addr_t pc = 0; CMIUtilString fnName; CMIUtilString fileName; CMIUtilString path; MIuint nLine = 0; if( !GetFrameInfo( frame, pc, fnName, fileName, path, nLine ) ) return MIstatus::failure; // Function args CMICmnMIValueList miValueList( true ); const MIuint vMaskVarTypes = 0x1000; if( !MIResponseFormVariableInfo( frame, vMaskVarTypes, miValueList ) ) return MIstatus::failure; const MIchar * pUnknown = "??"; if( fnName != pUnknown ) { std::replace( fnName.begin(), fnName.end(), ')', ' ' ); std::replace( fnName.begin(), fnName.end(), '(', ' ' ); std::replace( fnName.begin(), fnName.end(), '\'', ' ' ); } const CMIUtilString strLevel( CMIUtilString::Format( "%d", nLevel ) ); const CMICmnMIValueConst miValueConst( strLevel ); const CMICmnMIValueResult miValueResult( "level", miValueConst ); miValueTupleAll.Add( miValueResult ); CMICmnMIValueTuple miValueTuple( miValueResult ); if( !MIResponseFormFrameInfo( pc, fnName, miValueList.GetString(), fileName, path, nLine, miValueTuple ) ) return MIstatus::failure; } vwrThreadFrames = miValueTupleAll; return MIstatus::success; }
bool CMICmnLLDBDebugSessionInfo::MIResponseForVariableInfoInternal(const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList, const lldb::SBValueList &vwrSBValueList, const MIuint vnMaxDepth, const bool vbIsArgs, const bool vbMarkArgs) { const MIuint nArgs = vwrSBValueList.GetSize(); for (MIuint i = 0; i < nArgs; i++) { CMICmnMIValueTuple miValueTuple; lldb::SBValue value = vwrSBValueList.GetValueAtIndex(i); const CMICmnMIValueConst miValueConst(value.GetName()); const CMICmnMIValueResult miValueResultName("name", miValueConst); if (vbMarkArgs && vbIsArgs) { const CMICmnMIValueConst miValueConstArg("1"); const CMICmnMIValueResult miValueResultArg("arg", miValueConstArg); miValueTuple.Add(miValueResultArg); } if (veVarInfoFormat != eVariableInfoFormat_NoValues) { miValueTuple.Add(miValueResultName); // name if (veVarInfoFormat == eVariableInfoFormat_SimpleValues) { const CMICmnMIValueConst miValueConst3(value.GetTypeName()); const CMICmnMIValueResult miValueResult3("type", miValueConst3); miValueTuple.Add(miValueResult3); } const MIuint nChildren = value.GetNumChildren(); const bool bIsPointerType = value.GetType().IsPointerType(); if (nChildren == 0 || // no children (bIsPointerType && nChildren == 1) || // pointers veVarInfoFormat == eVariableInfoFormat_AllValues) // show all values { CMIUtilString strValue; if (GetVariableInfo(value, vnMaxDepth == 0, strValue)) { const CMICmnMIValueConst miValueConst2(strValue.Escape().AddSlashes()); const CMICmnMIValueResult miValueResult2("value", miValueConst2); miValueTuple.Add(miValueResult2); } } vwrMiValueList.Add(miValueTuple); continue; } if (vbMarkArgs) { // If we are printing names only with vbMarkArgs, we still need to add the name to the value tuple miValueTuple.Add(miValueResultName); // name vwrMiValueList.Add(miValueTuple); } else { // If we are printing name only then no need to put it in the tuple. vwrMiValueList.Add(miValueResultName); } } return MIstatus::success; }