//++ ------------------------------------------------------------------------------------
// 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, const FrameInfoFormat_e veFrameInfoFormat,
                                            CMIUtilString &vwrThreadFrames)
{
    lldb::SBThread thread = GetProcess().GetThreadByIndexID(vThreadIdx);
    const uint32_t nFrames = thread.GetNumFrames();
    if (nFrames == 0)
    {
        // MI print "frame={}"
        CMICmnMIValueTuple miValueTuple;
        CMICmnMIValueResult miValueResult("frame", miValueTuple);
        vwrThreadFrames = miValueResult.GetString();
        return MIstatus::success;
    }

    // MI print
    // "frame={level=\"%d\",addr=\"0x%016" PRIx64 "\",func=\"%s\",args=[%s],file=\"%s\",fullname=\"%s\",line=\"%d\"},frame={level=\"%d\",addr=\"0x%016" PRIx64 "\",func=\"%s\",args=[%s],file=\"%s\",fullname=\"%s\",line=\"%d\"},
    // ..."
    CMIUtilString strListCommaSeparated;
    for (MIuint nLevel = 0; nLevel < nFrames; nLevel++)
    {
        CMICmnMIValueTuple miValueTuple;
        if (!MIResponseFormFrameInfo(thread, nLevel, veFrameInfoFormat, miValueTuple))
            return MIstatus::failure;

        const CMICmnMIValueResult miValueResult2("frame", miValueTuple);
        if (nLevel != 0)
            strListCommaSeparated += ",";
        strListCommaSeparated += miValueResult2.GetString();
    }

    vwrThreadFrames = strListCommaSeparated;

    return MIstatus::success;
}
示例#2
0
//++
//------------------------------------------------------------------------------------
// Details: The invoker requires this function. The command prepares a MI Record
// Result
//          for the work carried out in the Execute().
// Type:    Overridden.
// Args:    None.
// Return:  MIstatus::success - Functional succeeded.
//          MIstatus::failure - Functional failed.
// Throws:  None.
//--
bool CMICmdCmdThreadInfo::Acknowledge() {
  if (m_bSingleThread) {
    if (m_bThreadInvalid) {
      const CMICmnMIValueConst miValueConst("invalid thread id");
      const CMICmnMIValueResult miValueResult("msg", miValueConst);
      const CMICmnMIResultRecord miRecordResult(
          m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error,
          miValueResult);
      m_miResultRecord = miRecordResult;
      return MIstatus::success;
    }

    // MI print
    // "%s^done,threads=[{id=\"%d\",target-id=\"%s\",frame={},state=\"%s\"}]
    const CMICmnMIValueList miValueList(m_miValueTupleThread);
    const CMICmnMIValueResult miValueResult("threads", miValueList);
    const CMICmnMIResultRecord miRecordResult(
        m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
        miValueResult);
    m_miResultRecord = miRecordResult;
    return MIstatus::success;
  }

  // Build up a list of thread information from tuples
  VecMIValueTuple_t::const_iterator it = m_vecMIValueTuple.begin();
  if (it == m_vecMIValueTuple.end()) {
    const CMICmnMIValueConst miValueConst("[]");
    const CMICmnMIValueResult miValueResult("threads", miValueConst);
    const CMICmnMIResultRecord miRecordResult(
        m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
        miValueResult);
    m_miResultRecord = miRecordResult;
    return MIstatus::success;
  }
  CMICmnMIValueList miValueList(*it);
  ++it;
  while (it != m_vecMIValueTuple.end()) {
    const CMICmnMIValueTuple &rTuple(*it);
    miValueList.Add(rTuple);

    // Next
    ++it;
  }

  CMICmnMIValueResult miValueResult("threads", miValueList);
  if (m_bHasCurrentThread) {
    CMIUtilString strCurrThreadId = "current-thread-id";
    miValueResult.Add(strCurrThreadId, m_miValueCurrThreadId);
  }
  const CMICmnMIResultRecord miRecordResult(
      m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done,
      miValueResult);
  m_miResultRecord = miRecordResult;

  return MIstatus::success;
}