Index: lldb/trunk/test/tools/lldb-mi/TestMiStack.py =================================================================== --- lldb/trunk/test/tools/lldb-mi/TestMiStack.py +++ lldb/trunk/test/tools/lldb-mi/TestMiStack.py @@ -10,7 +10,6 @@ @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") - @unittest2.skip("-stack-list-locals doesn't work properly") def test_lldbmi_stackargs(self): """Test that 'lldb-mi --interpreter' can shows arguments.""" @@ -27,15 +26,26 @@ self.expect("\^running") self.expect("\*stopped,reason=\"breakpoint-hit\"") - # Test arguments - self.runCmd("-stack-list-arguments 0") #FIXME: --no-values doesn't work + # Test -stack-list-arguments: use 0 or --no-values + self.runCmd("-stack-list-arguments 0") self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}") + self.runCmd("-stack-list-arguments --no-values") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[name=\"argc\",name=\"argv\"\]}") + + # Test -stack-list-arguments: use 1 or --all-values self.runCmd("-stack-list-arguments 1") self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") + self.runCmd("-stack-list-arguments --all-values") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") + + # Test -stack-list-arguments: use 2 or --simple-values + self.runCmd("-stack-list-arguments 2") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") + self.runCmd("-stack-list-arguments --simple-values") + self.expect("\^done,stack-args=\[frame={level=\"0\",args=\[{name=\"argc\",value=\"1\"},{name=\"argv\",value=\".*\"}\]}") @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") - @unittest2.skip("-stack-list-locals doesn't work properly") def test_lldbmi_locals(self): """Test that 'lldb-mi --interpreter' can shows local variables.""" @@ -53,11 +63,23 @@ self.expect("\^running") self.expect("\*stopped,reason=\"breakpoint-hit\"") - # Test locals - self.runCmd("-stack-list-locals 0") #FIXME: --no-values doesn't work + # Test -stack-list-locals: use 0 or --no-values + self.runCmd("-stack-list-locals 0") self.expect("\^done,locals=\[name=\"a\",name=\"b\"\]") + self.runCmd("-stack-list-locals --no-values") + self.expect("\^done,locals=\[name=\"a\",name=\"b\"\]") + + # Test -stack-list-locals: use 1 or --all-values self.runCmd("-stack-list-locals 1") self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") + self.runCmd("-stack-list-locals --all-values") + self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") + + # Test -stack-list-locals: use 2 or --simple-values + self.runCmd("-stack-list-locals 2") + self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") + self.runCmd("-stack-list-locals --simple-values") + self.expect("\^done,locals=\[{name=\"a\",value=\"10\"},{name=\"b\",value=\"20\"}\]") @lldbmi_test @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows") Index: lldb/trunk/tools/lldb-mi/MICmdCmdStack.h =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdCmdStack.h +++ lldb/trunk/tools/lldb-mi/MICmdCmdStack.h @@ -143,7 +143,10 @@ bool m_bThreadInvalid; // True = yes invalid thread, false = thread object valid CMICmnMIValueList m_miValueList; const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option - const CMIUtilString m_constStrArgPrintValues; // Not handled by *this command + const CMIUtilString m_constStrArgPrintValues; + const CMIUtilString m_constStrArgNoValues; + const CMIUtilString m_constStrArgAllValues; + const CMIUtilString m_constStrArgSimpleValues; }; //++ ============================================================================ @@ -179,5 +182,8 @@ CMICmnMIValueList m_miValueList; const CMIUtilString m_constStrArgThread; // Not specified in MI spec but Eclipse gives this option const CMIUtilString m_constStrArgFrame; // Not specified in MI spec but Eclipse gives this option - const CMIUtilString m_constStrArgPrintValues; // Not handled by *this command + const CMIUtilString m_constStrArgPrintValues; + const CMIUtilString m_constStrArgNoValues; + const CMIUtilString m_constStrArgAllValues; + const CMIUtilString m_constStrArgSimpleValues; }; Index: lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp +++ lldb/trunk/tools/lldb-mi/MICmdCmdStack.cpp @@ -350,6 +350,9 @@ , m_miValueList(true) , m_constStrArgThread("thread") , m_constStrArgPrintValues("print-values") + , m_constStrArgNoValues("no-values") + , m_constStrArgAllValues("all-values") + , m_constStrArgSimpleValues("simple-values") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "stack-list-arguments"; @@ -383,7 +386,10 @@ { bool bOk = m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, true, false))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, false, true))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true))); return (bOk && ParseValidateCmdOptions()); } @@ -401,6 +407,9 @@ { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues); + CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues); + CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues); + CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues); // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; @@ -413,6 +422,29 @@ } } + CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat; + if (pArgPrintValues->GetFound()) + { + const MIuint nPrintValues = pArgPrintValues->GetValue(); + if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats) + { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; + } + eVarInfoFormat = static_cast(nPrintValues); + } + else if (pArgNoValues->GetFound()) + eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; + else if (pArgAllValues->GetFound()) + eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues; + else if (pArgSimpleValues->GetFound()) + eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues; + else + { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; + } + CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBProcess sbProcess = rSessionInfo.GetProcess(); lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread(); @@ -433,7 +465,7 @@ lldb::SBFrame frame = thread.GetFrameAtIndex(i); CMICmnMIValueList miValueList(true); const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Arguments; - if (!rSessionInfo.MIResponseFormVariableInfo3(frame, maskVarTypes, miValueList)) + if (!rSessionInfo.MIResponseFormVariableInfo3(frame, maskVarTypes, eVarInfoFormat, miValueList)) return MIstatus::failure; const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%d", i)); const CMICmnMIValueResult miValueResult("level", miValueConst); @@ -508,6 +540,9 @@ , m_constStrArgThread("thread") , m_constStrArgFrame("frame") , m_constStrArgPrintValues("print-values") + , m_constStrArgNoValues("no-values") + , m_constStrArgAllValues("all-values") + , m_constStrArgSimpleValues("simple-values") { // Command factory matches this name with that received from the stdin stream m_strMiCmd = "stack-list-locals"; @@ -543,7 +578,10 @@ m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgThread, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgFrame, false, true, CMICmdArgValListBase::eArgValType_Number, 1))); - bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, true, false))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgPrintValues, false, true))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgNoValues, false, true))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true))); + bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true))); return (bOk && ParseValidateCmdOptions()); } @@ -561,6 +599,10 @@ { CMICMDBASE_GETOPTION(pArgThread, OptionLong, m_constStrArgThread); CMICMDBASE_GETOPTION(pArgFrame, OptionLong, m_constStrArgFrame); + CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues); + CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues); + CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues); + CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues); // Retrieve the --thread option's thread ID (only 1) MIuint64 nThreadId = UINT64_MAX; @@ -572,6 +614,7 @@ return MIstatus::failure; } } + MIuint64 nFrame = UINT64_MAX; if (pArgFrame->GetFound()) { @@ -582,6 +625,29 @@ } } + CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e eVarInfoFormat; + if (pArgPrintValues->GetFound()) + { + const MIuint nPrintValues = pArgPrintValues->GetValue(); + if (nPrintValues >= CMICmnLLDBDebugSessionInfo::kNumVariableInfoFormats) + { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; + } + eVarInfoFormat = static_cast(nPrintValues); + } + else if (pArgNoValues->GetFound()) + eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues; + else if (pArgAllValues->GetFound()) + eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues; + else if (pArgSimpleValues->GetFound()) + eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues; + else + { + SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_INVALID_PRINT_VALUES), m_cmdData.strMiCmd.c_str())); + return MIstatus::failure; + } + CMICmnLLDBDebugSessionInfo &rSessionInfo(CMICmnLLDBDebugSessionInfo::Instance()); lldb::SBProcess sbProcess = rSessionInfo.GetProcess(); lldb::SBThread thread = (nThreadId != UINT64_MAX) ? sbProcess.GetThreadByIndexID(nThreadId) : sbProcess.GetSelectedThread(); @@ -596,12 +662,11 @@ return MIstatus::success; } - const MIuint nFrames = thread.GetNumFrames(); - MIunused(nFrames); lldb::SBFrame frame = (nFrame != UINT64_MAX) ? thread.GetFrameAtIndex(nFrame) : thread.GetSelectedFrame(); + CMICmnMIValueList miValueList(true); const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Locals; - if (!rSessionInfo.MIResponseFormVariableInfo(frame, maskVarTypes, miValueList)) + if (!rSessionInfo.MIResponseFormVariableInfo(frame, maskVarTypes, eVarInfoFormat, miValueList)) return MIstatus::failure; m_miValueList = miValueList; Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h =================================================================== --- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h +++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.h @@ -117,6 +117,17 @@ eVariableType_Arguments = (1u << 3) // Arguments. }; + //++ =================================================================== + // Details: Determine the information that should be shown by using MIResponseFormVariableInfo family functions. + //-- + enum VariableInfoFormat_e + { + eVariableInfoFormat_NoValues, + eVariableInfoFormat_AllValues, + eVariableInfoFormat_SimpleValues, + kNumVariableInfoFormats + }; + // Typedefs: public: typedef std::vector VecActiveThreadId_t; @@ -148,9 +159,12 @@ bool MIResponseFormThreadInfo(const SMICmdData &vCmdData, const lldb::SBThread &vrThread, CMICmnMIValueTuple &vwrMIValueTuple); bool MIResponseFormThreadInfo2(const SMICmdData &vCmdData, const lldb::SBThread &vrThread, CMICmnMIValueTuple &vwrMIValueTuple); bool MIResponseFormThreadInfo3(const SMICmdData &vCmdData, const lldb::SBThread &vrThread, CMICmnMIValueTuple &vwrMIValueTuple); - bool MIResponseFormVariableInfo(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList &vwrMiValueList); - bool MIResponseFormVariableInfo2(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList &vwrMiValueList); - bool MIResponseFormVariableInfo3(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, CMICmnMIValueList &vwrMiValueList); + bool MIResponseFormVariableInfo(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList); + bool MIResponseFormVariableInfo2(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList); + bool MIResponseFormVariableInfo3(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList); bool MIResponseFormBrkPtFrameInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple); bool MIResponseFormBrkPtInfo(const SBrkPtInfo &vrBrkPtInfo, CMICmnMIValueTuple &vwrMiValueTuple); bool GetBrkPtInfo(const lldb::SBBreakpoint &vBrkPt, SBrkPtInfo &vrwBrkPtInfo) const; @@ -188,9 +202,9 @@ void operator=(const CMICmnLLDBDebugSessionInfo &); // bool GetVariableInfo(const MIuint vnMaxDepth, const lldb::SBValue &vrValue, const bool vbIsChildValue, - CMICmnMIValueList &vwrMiValueList, MIuint &vrwnDepth); + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList, MIuint &vrwnDepth); bool GetVariableInfo2(const MIuint vnMaxDepth, const lldb::SBValue &vrValue, const bool vbIsChildValue, - CMICmnMIValueList &vwrMiValueList, MIuint &vrwnDepth); + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList, MIuint &vrwnDepth); // Overridden: private: Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp +++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebugSessionInfo.cpp @@ -253,7 +253,7 @@ // Function args CMICmnMIValueList miValueList(true); const MIuint maskVarTypes = eVariableType_Arguments; - if (!MIResponseFormVariableInfo(frame, maskVarTypes, miValueList)) + if (!MIResponseFormVariableInfo(frame, maskVarTypes, eVariableInfoFormat_AllValues, miValueList)) return MIstatus::failure; const MIchar *pUnknown = "??"; @@ -326,7 +326,7 @@ // Function args CMICmnMIValueList miValueList(true); const MIuint maskVarTypes = eVariableType_Arguments; - if (!MIResponseFormVariableInfo2(frame, maskVarTypes, miValueList)) + if (!MIResponseFormVariableInfo2(frame, maskVarTypes, eVariableInfoFormat_AllValues, miValueList)) return MIstatus::failure; const MIchar *pUnknown = "??"; @@ -646,6 +646,7 @@ // Type: Method. // Args: vrFrame - (R) LLDB thread object. // vMaskVarTypes - (R) Construed according to VariableType_e. +// veVarInfoFormat - (R) The type of variable info that should be shown. // vwrMIValueList - (W) MI value list object. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. @@ -653,7 +654,7 @@ //-- bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo2(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, - CMICmnMIValueList &vwrMiValueList) + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList) { bool bOk = MIstatus::success; lldb::SBFrame &rFrame = const_cast(vrFrame); @@ -686,6 +687,7 @@ // Type: Method. // Args: vrFrame - (R) LLDB thread object. // vMaskVarTypes - (R) Construed according to VariableType_e. +// veVarInfoFormat - (R) The type of variable info that should be shown. // vwrMIValueList - (W) MI value list object. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. @@ -693,7 +695,7 @@ //-- bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, - CMICmnMIValueList &vwrMiValueList) + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList) { bool bOk = MIstatus::success; lldb::SBFrame &rFrame = const_cast(vrFrame); @@ -709,7 +711,7 @@ for (MIuint i = 0; bOk && (i < nArgs); i++) { lldb::SBValue value = listArg.GetValueAtIndex(i); - bOk = GetVariableInfo(nMaxRecusiveDepth, value, false, vwrMiValueList, nCurrentRecursiveDepth); + bOk = GetVariableInfo(nMaxRecusiveDepth, value, false, veVarInfoFormat, vwrMiValueList, nCurrentRecursiveDepth); } return bOk; @@ -723,6 +725,7 @@ // Type: Method. // Args: vrFrame - (R) LLDB thread object. // vMaskVarTypes - (R) Construed according to VariableType_e. +// veVarInfoFormat - (R) The type of variable info that should be shown. // vwrMIValueList - (W) MI value list object. // Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. @@ -730,7 +733,7 @@ //-- bool CMICmnLLDBDebugSessionInfo::MIResponseFormVariableInfo3(const lldb::SBFrame &vrFrame, const MIuint vMaskVarTypes, - CMICmnMIValueList &vwrMiValueList) + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList) { bool bOk = MIstatus::success; lldb::SBFrame &rFrame = const_cast(vrFrame); @@ -746,7 +749,7 @@ for (MIuint i = 0; bOk && (i < nArgs); i++) { lldb::SBValue value = listArg.GetValueAtIndex(i); - bOk = GetVariableInfo2(nMaxRecusiveDepth, value, false, vwrMiValueList, nCurrentRecursiveDepth); + bOk = GetVariableInfo2(nMaxRecusiveDepth, value, false, veVarInfoFormat, vwrMiValueList, nCurrentRecursiveDepth); } return bOk; @@ -761,15 +764,17 @@ // vrValue - (R) LLDB value object. // vbIsChildValue - (R) True = Value object is a child of a higher Value object, // - False = Value object not a child. +// veVarInfoFormat - (R) The type of variable info that should be shown. // vwrMIValueList - (W) MI value list object. // vnDepth - (RW) The current recursive depth of this function. -// // Return: MIstatus::success - Functional succeeded. +// Return: MIstatus::success - Functional succeeded. // MIstatus::failure - Functional failed. // Throws: None. //-- bool CMICmnLLDBDebugSessionInfo::GetVariableInfo(const MIuint vnMaxDepth, const lldb::SBValue &vrValue, const bool vbIsChildValue, - CMICmnMIValueList &vwrMiValueList, MIuint &vrwnDepth) + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList, + MIuint &vrwnDepth) { // *** Update GetVariableInfo2() with any code changes here *** @@ -807,46 +812,78 @@ else { // Basic types - const CMICmnMIValueConst miValueConst(utilValue.GetName()); - const CMICmnMIValueResult miValueResult("name", miValueConst); - miValueTuple.Add(miValueResult); - const CMICmnMIValueConst miValueConst2(utilValue.GetValue()); - const CMICmnMIValueResult miValueResult2("value", miValueConst2); - miValueTuple.Add(miValueResult2); + switch (veVarInfoFormat) + { + case eVariableInfoFormat_NoValues: + { + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + return vwrMiValueList.Add(miValueResult); + } + case eVariableInfoFormat_AllValues: + case eVariableInfoFormat_SimpleValues: + { + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + miValueTuple.Add(miValueResult); + const CMICmnMIValueConst miValueConst2(utilValue.GetValue()); + const CMICmnMIValueResult miValueResult2("value", miValueConst2); + miValueTuple.Add(miValueResult2); + break; + } + default: + break; + } return vwrMiValueList.Add(miValueTuple); } } else if (bIsPointerType && utilValue.IsChildCharType()) { - // Append string text to the parent value information - const CMICmnMIValueConst miValueConst(utilValue.GetName()); - const CMICmnMIValueResult miValueResult("name", miValueConst); - miValueTuple.Add(miValueResult); - - const CMIUtilString &rText(utilValue.GetChildValueCString()); - if (rText.empty()) - { - const CMICmnMIValueConst miValueConst(utilValue.GetValue()); - const CMICmnMIValueResult miValueResult("value", miValueConst); - miValueTuple.Add(miValueResult); - } - else + switch (veVarInfoFormat) { - if (utilValue.IsValueUnknown()) + case eVariableInfoFormat_NoValues: { - const CMICmnMIValueConst miValueConst(rText); - const CMICmnMIValueResult miValueResult("value", miValueConst); - miValueTuple.Add(miValueResult); + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + return vwrMiValueList.Add(miValueResult); } - else + case eVariableInfoFormat_AllValues: + case eVariableInfoFormat_SimpleValues: { - // Note code that has const in will not show the text suffix to the string pointer - // i.e. const char * pMyStr = "blah"; ==> "0x00007000"" <-- Eclipse shows this - // but char * pMyStr = "blah"; ==> "0x00007000" "blah"" <-- Eclipse shows this - const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%s %s", utilValue.GetValue().c_str(), rText.c_str())); - const CMICmnMIValueResult miValueResult("value", miValueConst); + // Append string text to the parent value information + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); miValueTuple.Add(miValueResult); + + const CMIUtilString &rText(utilValue.GetChildValueCString()); + if (rText.empty()) + { + const CMICmnMIValueConst miValueConst(utilValue.GetValue()); + const CMICmnMIValueResult miValueResult("value", miValueConst); + miValueTuple.Add(miValueResult); + } + else + { + if (utilValue.IsValueUnknown()) + { + const CMICmnMIValueConst miValueConst(rText); + const CMICmnMIValueResult miValueResult("value", miValueConst); + miValueTuple.Add(miValueResult); + } + else + { + // Note code that has const in will not show the text suffix to the string pointer + // i.e. const char * pMyStr = "blah"; ==> "0x00007000"" <-- Eclipse shows this + // but char * pMyStr = "blah"; ==> "0x00007000" "blah"" <-- Eclipse shows this + const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%s %s", utilValue.GetValue().c_str(), rText.c_str())); + const CMICmnMIValueResult miValueResult("value", miValueConst); + miValueTuple.Add(miValueResult); + } + } + break; } + default: + break; } return vwrMiValueList.Add(miValueTuple); } @@ -863,30 +900,62 @@ else { // Basic types - const CMICmnMIValueConst miValueConst(utilValue.GetName()); - const CMICmnMIValueResult miValueResult("name", miValueConst); - miValueTuple.Add(miValueResult); - const CMICmnMIValueConst miValueConst2(utilValue.GetValue()); - const CMICmnMIValueResult miValueResult2("value", miValueConst2); - miValueTuple.Add(miValueResult2); + switch (veVarInfoFormat) + { + case eVariableInfoFormat_NoValues: + { + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + return vwrMiValueList.Add(miValueResult); + } + case eVariableInfoFormat_AllValues: + case eVariableInfoFormat_SimpleValues: + { + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + miValueTuple.Add(miValueResult); + const CMICmnMIValueConst miValueConst2(utilValue.GetValue()); + const CMICmnMIValueResult miValueResult2("value", miValueConst2); + miValueTuple.Add(miValueResult2); + break; + } + default: + break; + } return vwrMiValueList.Add(miValueTuple); } } else { - // Build parent child composite types - CMICmnMIValueList miValueList(true); - for (MIuint i = 0; bOk && (i < nChildren); i++) + switch (veVarInfoFormat) { - lldb::SBValue member = rValue.GetChildAtIndex(i); - bOk = GetVariableInfo(vnMaxDepth, member, true, miValueList, ++vrwnDepth); + case eVariableInfoFormat_NoValues: + { + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + return vwrMiValueList.Add(miValueResult); + } + case eVariableInfoFormat_AllValues: + case eVariableInfoFormat_SimpleValues: + { + // Build parent child composite types + CMICmnMIValueList miValueList(true); + for (MIuint i = 0; bOk && (i < nChildren); i++) + { + lldb::SBValue member = rValue.GetChildAtIndex(i); + bOk = GetVariableInfo(vnMaxDepth, member, true, veVarInfoFormat, miValueList, ++vrwnDepth); + } + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + miValueTuple.Add(miValueResult); + const CMICmnMIValueConst miValueConst2(CMIUtilString::Format("{%s}", miValueList.ExtractContentNoBrackets().c_str())); + const CMICmnMIValueResult miValueResult2("value", miValueConst2); + miValueTuple.Add(miValueResult2); + break; + } + default: + break; } - const CMICmnMIValueConst miValueConst(utilValue.GetName()); - const CMICmnMIValueResult miValueResult("name", miValueConst); - miValueTuple.Add(miValueResult); - const CMICmnMIValueConst miValueConst2(CMIUtilString::Format("{%s}", miValueList.ExtractContentNoBrackets().c_str())); - const CMICmnMIValueResult miValueResult2("value", miValueConst2); - miValueTuple.Add(miValueResult2); return vwrMiValueList.Add(miValueTuple); } } @@ -900,6 +969,7 @@ // vrValue - (R) LLDB value object. // vbIsChildValue - (R) True = Value object is a child of a higher Value object, // - False = Value object not a child. +// veVarInfoFormat - (R) The type of variable info that should be shown. // vwrMIValueList - (W) MI value list object. // vnDepth - (RW) The current recursive depth of this function. // // Return: MIstatus::success - Functional succeeded. @@ -908,7 +978,8 @@ //-- bool CMICmnLLDBDebugSessionInfo::GetVariableInfo2(const MIuint vnMaxDepth, const lldb::SBValue &vrValue, const bool vbIsChildValue, - CMICmnMIValueList &vwrMiValueList, MIuint &vrwnDepth) + const VariableInfoFormat_e veVarInfoFormat, CMICmnMIValueList &vwrMiValueList, + MIuint &vrwnDepth) { // *** Update GetVariableInfo() with any code changes here *** @@ -935,64 +1006,112 @@ else { // Basic types - const CMICmnMIValueConst miValueConst(utilValue.GetName()); - const CMICmnMIValueResult miValueResult("name", miValueConst); - miValueTuple.Add(miValueResult); - const CMICmnMIValueConst miValueConst2(utilValue.GetValue()); - const CMICmnMIValueResult miValueResult2("value", miValueConst2); - miValueTuple.Add(miValueResult2); + switch (veVarInfoFormat) + { + case eVariableInfoFormat_NoValues: + { + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + return vwrMiValueList.Add(miValueResult); + } + case eVariableInfoFormat_AllValues: + case eVariableInfoFormat_SimpleValues: + { + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + miValueTuple.Add(miValueResult); + const CMICmnMIValueConst miValueConst2(utilValue.GetValue()); + const CMICmnMIValueResult miValueResult2("value", miValueConst2); + miValueTuple.Add(miValueResult2); + break; + } + default: + break; + } return vwrMiValueList.Add(miValueTuple); } } else if (utilValue.IsChildCharType()) { - // Append string text to the parent value information - const CMICmnMIValueConst miValueConst(utilValue.GetName()); - const CMICmnMIValueResult miValueResult("name", miValueConst); - miValueTuple.Add(miValueResult); - - const CMIUtilString &rText(utilValue.GetChildValueCString()); - if (rText.empty()) - { - const CMICmnMIValueConst miValueConst(utilValue.GetValue()); - const CMICmnMIValueResult miValueResult("value", miValueConst); - miValueTuple.Add(miValueResult); - } - else + switch (veVarInfoFormat) { - if (utilValue.IsValueUnknown()) + case eVariableInfoFormat_NoValues: { - const CMICmnMIValueConst miValueConst(rText); - const CMICmnMIValueResult miValueResult("value", miValueConst); - miValueTuple.Add(miValueResult); + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + return vwrMiValueList.Add(miValueResult); } - else + case eVariableInfoFormat_AllValues: + case eVariableInfoFormat_SimpleValues: { - // Note code that has const in will not show the text suffix to the string pointer - // i.e. const char * pMyStr = "blah"; ==> "0x00007000"" <-- Eclipse shows this - // but char * pMyStr = "blah"; ==> "0x00007000" "blah"" <-- Eclipse shows this - const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%s %s", utilValue.GetValue().c_str(), rText.c_str())); - const CMICmnMIValueResult miValueResult("value", miValueConst); + // Append string text to the parent value information + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); miValueTuple.Add(miValueResult); + + const CMIUtilString &rText(utilValue.GetChildValueCString()); + if (rText.empty()) + { + const CMICmnMIValueConst miValueConst(utilValue.GetValue()); + const CMICmnMIValueResult miValueResult("value", miValueConst); + miValueTuple.Add(miValueResult); + } + else + { + if (utilValue.IsValueUnknown()) + { + const CMICmnMIValueConst miValueConst(rText); + const CMICmnMIValueResult miValueResult("value", miValueConst); + miValueTuple.Add(miValueResult); + } + else + { + // Note code that has const in will not show the text suffix to the string pointer + // i.e. const char * pMyStr = "blah"; ==> "0x00007000"" <-- Eclipse shows this + // but char * pMyStr = "blah"; ==> "0x00007000" "blah"" <-- Eclipse shows this + const CMICmnMIValueConst miValueConst(CMIUtilString::Format("%s %s", utilValue.GetValue().c_str(), rText.c_str())); + const CMICmnMIValueResult miValueResult("value", miValueConst); + miValueTuple.Add(miValueResult); + } + } + break; } + default: + break; } return vwrMiValueList.Add(miValueTuple); } else { - // Build parent child composite types - CMICmnMIValueList miValueList(true); - for (MIuint i = 0; bOk && (i < nChildren); i++) + switch (veVarInfoFormat) { - lldb::SBValue member = rValue.GetChildAtIndex(i); - bOk = GetVariableInfo(vnMaxDepth, member, true, miValueList, ++vrwnDepth); + case eVariableInfoFormat_NoValues: + { + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + return vwrMiValueList.Add(miValueResult); + } + case eVariableInfoFormat_AllValues: + case eVariableInfoFormat_SimpleValues: + { + // Build parent child composite types + CMICmnMIValueList miValueList(true); + for (MIuint i = 0; bOk && (i < nChildren); i++) + { + lldb::SBValue member = rValue.GetChildAtIndex(i); + bOk = GetVariableInfo(vnMaxDepth, member, true, veVarInfoFormat, miValueList, ++vrwnDepth); + } + const CMICmnMIValueConst miValueConst(utilValue.GetName()); + const CMICmnMIValueResult miValueResult("name", miValueConst); + miValueTuple.Add(miValueResult); + const CMICmnMIValueConst miValueConst2(CMIUtilString::Format("{%s}", miValueList.ExtractContentNoBrackets().c_str())); + const CMICmnMIValueResult miValueResult2("value", miValueConst2); + miValueTuple.Add(miValueResult2); + break; + } + default: + break; } - const CMICmnMIValueConst miValueConst(utilValue.GetName()); - const CMICmnMIValueResult miValueResult("name", miValueConst); - miValueTuple.Add(miValueResult); - const CMICmnMIValueConst miValueConst2(CMIUtilString::Format("{%s}", miValueList.ExtractContentNoBrackets().c_str())); - const CMICmnMIValueResult miValueResult2("value", miValueConst2); - miValueTuple.Add(miValueResult2); return vwrMiValueList.Add(miValueTuple); } } Index: lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp +++ lldb/trunk/tools/lldb-mi/MICmnLLDBDebuggerHandleEvents.cpp @@ -1081,7 +1081,7 @@ { CMICmnMIValueList miValueList(true); const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Arguments; - bOk = rSession.MIResponseFormVariableInfo2(frame, maskVarTypes, miValueList); + bOk = rSession.MIResponseFormVariableInfo2(frame, maskVarTypes, CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues, miValueList); CMICmnMIValueTuple miValueTuple; bOk = bOk && rSession.MIResponseFormFrameInfo2(pc, miValueList.GetString(), fnName, fileName, path, nLine, miValueTuple); @@ -1157,7 +1157,7 @@ // Function args CMICmnMIValueList miValueList(true); const MIuint maskVarTypes = CMICmnLLDBDebugSessionInfo::eVariableType_Arguments; - if (!rSession.MIResponseFormVariableInfo2(frame, maskVarTypes, miValueList)) + if (!rSession.MIResponseFormVariableInfo2(frame, maskVarTypes, CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues, miValueList)) return MIstatus::failure; CMICmnMIValueTuple miValueTuple; if (!rSession.MIResponseFormFrameInfo2(pc, miValueList.GetString(), fnName, fileName, path, nLine, miValueTuple)) Index: lldb/trunk/tools/lldb-mi/MICmnResources.h =================================================================== --- lldb/trunk/tools/lldb-mi/MICmnResources.h +++ lldb/trunk/tools/lldb-mi/MICmnResources.h @@ -270,6 +270,7 @@ IDS_CMD_ERR_LLDB_ERR_NOT_READ_WHOLE_BLK, IDS_CMD_ERR_LLDB_ERR_READ_MEM_BYTES, IDS_CMD_ERR_INVALID_PROCESS, + IDS_CMD_ERR_INVALID_PRINT_VALUES, IDS_CMD_ERR_INVALID_FORMAT_TYPE, IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND, IDS_CMD_ERR_LLDB_ERR_WRITE_MEM_BYTES, Index: lldb/trunk/tools/lldb-mi/MICmnResources.cpp =================================================================== --- lldb/trunk/tools/lldb-mi/MICmnResources.cpp +++ lldb/trunk/tools/lldb-mi/MICmnResources.cpp @@ -254,6 +254,7 @@ {IDS_CMD_ERR_LLDB_ERR_NOT_READ_WHOLE_BLK, "Command '%s'. LLDB unable to read entire memory block of %u bytes at address 0x%08x"}, {IDS_CMD_ERR_LLDB_ERR_READ_MEM_BYTES, "Command '%s'. Unable to read memory block of %u bytes at address 0x%08x: %s "}, {IDS_CMD_ERR_INVALID_PROCESS, "Command '%s'. Invalid process during debug session"}, + {IDS_CMD_ERR_INVALID_PRINT_VALUES, "Command '%s'. Unknown value for PRINT_VALUES: must be: 0 or \"--no-values\", 1 or \"all-values\", 2 or \"simple-values\""}, {IDS_CMD_ERR_INVALID_FORMAT_TYPE, "Command '%s'. Invalid var format type '%s'"}, {IDS_CMD_ERR_BRKPT_INFO_OBJ_NOT_FOUND, "Command '%s'. Breakpoint information for breakpoint ID %d not found"}, {IDS_CMD_ERR_LLDB_ERR_READ_MEM_BYTES, "Command '%s'. Unable to write memory block of %u bytes at address 0x%08x: %s "},