[Lldb-commits] [lldb] r236820 - Fix -var-list-children command (MI)

Ilia K ki.stfu at gmail.com
Fri May 8 03:10:15 PDT 2015


Author: ki.stfu
Date: Fri May  8 05:10:14 2015
New Revision: 236820

URL: http://llvm.org/viewvc/llvm-project?rev=236820&view=rev
Log:
Fix -var-list-children command (MI)

This patch incldues the following:
# Add from/to arguments in -var-list-children command (MI)
## Handle from and to args
## Don't print children=[] if numchild is 0
## A bit refactoring
## Add MiVarTestCase.test_lldbmi_var_list_children test
# Refactor -var-list-children (MI)
## Remove CMICmdCmdVarListChildren::VecMIValueResult_t
## Add CMICmdCmdVarListChildren::m_miValueList
## Remove CMICmdCmdVarListChildren::m_vecMiValueResult
   (use CMICmdCmdVarListChildren::m_miValueList instead)
## Print error message if value is invalid:
   ```
     ^error,msg="variable invalid"
   ```
## Refactor CMICmdCmdVarListChildren::Acknowledge and remove duplicated code
## Don't print children=[] if numchild is 0
## Add error checking
## Use CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e for print-values
## Add few more empty-range test cases in MiVarTestCase.test_lldbmi_var_list_children
#Improve MiVarTestCase.test_lldbmi_var_list_children test (MI)


Modified:
    lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py
    lldb/trunk/test/tools/lldb-mi/variable/main.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdVar.h
    lldb/trunk/tools/lldb-mi/MICmnResources.cpp
    lldb/trunk/tools/lldb-mi/MICmnResources.h

Modified: lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py?rev=236820&r1=236819&r2=236820&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py (original)
+++ lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py Fri May  8 05:10:14 2015
@@ -46,7 +46,7 @@ class MiVarTestCase(lldbmi_testcase.MiTe
         self.runCmd("-var-show-attributes var2")
         self.expect("\^done,status=\"editable\"")
         self.runCmd("-var-list-children var2")
-        self.expect("\^done,numchild=\"0\"")
+        self.expect("\^done,numchild=\"0\",has_more=\"0\"")
         self.runCmd("-data-evaluate-expression \"g_MyVar=30\"")
         self.expect("\^done,value=\"30\"")
         self.runCmd("-var-update --all-values var2")
@@ -66,7 +66,7 @@ class MiVarTestCase(lldbmi_testcase.MiTe
         self.runCmd("-var-show-attributes var3")
         self.expect("\^done,status=\"editable\"")
         self.runCmd("-var-list-children var3")
-        self.expect("\^done,numchild=\"0\"")
+        self.expect("\^done,numchild=\"0\",has_more=\"0\"")
         self.runCmd("-data-evaluate-expression \"s_MyVar=3\"")
         self.expect("\^done,value=\"3\"")
         self.runCmd("-var-update --all-values var3")
@@ -86,7 +86,7 @@ class MiVarTestCase(lldbmi_testcase.MiTe
         self.runCmd("-var-show-attributes var4")
         self.expect("\^done,status=\"editable\"")
         self.runCmd("-var-list-children var4")
-        self.expect("\^done,numchild=\"0\"")
+        self.expect("\^done,numchild=\"0\",has_more=\"0\"")
         self.runCmd("-data-evaluate-expression \"b=2\"")
         self.expect("\^done,value=\"2\"")
         self.runCmd("-var-update --all-values var4")
@@ -106,7 +106,7 @@ class MiVarTestCase(lldbmi_testcase.MiTe
         self.runCmd("-var-show-attributes var5")
         self.expect("\^done,status=\"editable\"") #FIXME editable or not?
         self.runCmd("-var-list-children var5")
-        self.expect("\^done,numchild=\"0\"")
+        self.expect("\^done,numchild=\"0\",has_more=\"0\"")
 
         # Print argument "argv[0]"
         self.runCmd("-data-evaluate-expression \"argv[0]\"")
@@ -119,7 +119,7 @@ class MiVarTestCase(lldbmi_testcase.MiTe
         self.expect("\^done,status=\"editable\"")
         self.runCmd("-var-list-children --all-values var6")
         # FIXME: The name below is not correct. It should be "var.*argv[0]".
-        self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var6\.\*\$[0-9]+\",exp=\"\*\$[0-9]+\",numchild=\"0\",type=\"const char\",thread-id=\"4294967295\",value=\"47 '/'\",has_more=\"0\"\}\]") #FIXME -var-list-children shows invalid thread-id
+        self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var6\.\*\$[0-9]+\",exp=\"\*\$[0-9]+\",numchild=\"0\",type=\"const char\",thread-id=\"4294967295\",value=\"47 '/'\",has_more=\"0\"\}\],has_more=\"0\"") #FIXME -var-list-children shows invalid thread-id
 
     @lldbmi_test
     @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
@@ -226,5 +226,87 @@ class MiVarTestCase(lldbmi_testcase.MiTe
         self.runCmd("-data-list-register-values d 0")
         self.expect("\^done,register-values=\[{number=\"0\",value=\"6\"")
 
+    @lldbmi_test
+    @expectedFailureWindows("llvm.org/pr22274: need a pexpect replacement for windows")
+    @skipIfFreeBSD # llvm.org/pr22411: Failure presumably due to known thread races
+    @skipIfLinux # llvm.org/pr22841: lldb-mi tests fail on all Linux buildbots
+    def test_lldbmi_var_list_children(self):
+        """Test that 'lldb-mi --interpreter' works for -var-list-children."""
+
+        self.spawnLldbMi(args = None)
+
+        # Load executable
+        self.runCmd("-file-exec-and-symbols %s" % self.myexe)
+        self.expect("\^done")
+
+        # Run to BP_var_list_children
+        line = line_number('main.cpp', '// BP_var_list_children')
+        self.runCmd("-break-insert main.cpp:%d" % line)
+        self.expect("\^done,bkpt={number=\"1\"")
+        self.runCmd("-exec-run")
+        self.expect("\^running")
+        self.expect("\*stopped,reason=\"breakpoint-hit\"")
+
+        # Create variable
+        self.runCmd("-var-create var_complx * complx")
+        self.expect("\^done,name=\"var_complx\",numchild=\"3\",value=\"\{\.\.\.\}\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"")
+        self.runCmd("-var-create var_complx_array * complx_array")
+        self.expect("\^done,name=\"var_complx_array\",numchild=\"2\",value=\"\[2\]\",type=\"complex_type \[2\]\",thread-id=\"1\",has_more=\"0\"")
+
+        # Test that -var-list-children lists empty children if range is empty
+        # FIXME (and that print-values is optional)
+        self.runCmd("-var-list-children 0 var_complx 0 0")
+        self.expect("\^done,numchild=\"0\",has_more=\"1\"")
+        self.runCmd("-var-list-children 0 var_complx 99 0")
+        self.expect("\^done,numchild=\"0\",has_more=\"1\"")
+        self.runCmd("-var-list-children 0 var_complx 99 3")
+        self.expect("\^done,numchild=\"0\",has_more=\"0\"")
+
+        # Test that -var-list-children lists all children with their values
+        # (and that from and to are optional)
+        self.runCmd("-var-list-children --all-values var_complx")
+        self.expect("\^done,numchild=\"3\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",value=\"3\",has_more=\"0\"\},child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\},child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",value=\"0x[0-9a-f]+\",has_more=\"0\"\}\],has_more=\"0\"")
+        self.runCmd("-var-list-children --simple-values var_complx_array")
+        self.expect("\^done,numchild=\"2\",children=\[child=\{name=\"var_complx_array\.\[0\]\",exp=\"\[0\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\},child=\{name=\"var_complx_array\.\[1\]\",exp=\"\[1\]\",numchild=\"3\",type=\"complex_type\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
+
+        # Test that -var-list-children lists children without values
+        self.runCmd("-var-list-children 0 var_complx 0 1")
+        self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
+        # FIXME: first 0 is treated as --no-values
+        self.runCmd("-var-list-children --no-values var_complx 0 1")
+        # self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.i\",exp=\"i\",numchild=\"0\",type=\"int\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"1\"")
+
+        # Test that -var-list-children lists children with all values
+        self.runCmd("-var-list-children 1 var_complx 1 2")
+        self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"")
+        # FIXME: first 1 is treated as --all-values
+        self.runCmd("-var-list-children --all-values var_complx 1 2")
+        # self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.inner\",exp=\"inner\",numchild=\"1\",type=\"complex_type::\(anonymous struct\)\",thread-id=\"1\",value=\"\{\.\.\.\}\",has_more=\"0\"\}\],has_more=\"1\"")
+
+        # Test that -var-list-children lists children with simple values
+        self.runCmd("-var-list-children 2 var_complx 2 4")
+        self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
+        # FIXME: first 2 is treated as --simple-values
+        self.runCmd("-var-list-children --simple-values var_complx 2 4")
+        # self.expect("\^done,numchild=\"1\",children=\[child=\{name=\"var_complx\.complex_ptr\",exp=\"complex_ptr\",numchild=\"3\",type=\"complex_type \*\",thread-id=\"1\",has_more=\"0\"\}\],has_more=\"0\"")
+
+        # Test that an invalid from is handled
+        # FIXME: first 0 is treated as --no-values
+        # FIXME: -1 is treated as unsigned int
+        self.runCmd("-var-list-children 0 var_complx -1 0")
+        #self.expect("\^error,msg=\"Command 'var-list-children'\. Variable children range invalid\"")
+
+        # Test that an invalid to is handled
+        # FIXME: first 0 is treated as --no-values
+        # FIXME: -1 is treated as unsigned int
+        self.runCmd("-var-list-children 0 var_complx 0 -1")
+        #self.expect("\^error,msg=\"Command 'var-list-children'\. Variable children range invalid\"")
+
+        # Test that a missing low-frame or high-frame is handled
+        # FIXME: first 0 is treated as --no-values
+        # FIXME: -1 is treated as unsigned int
+        self.runCmd("-var-list-children 0 var_complx 0")
+        self.expect("\^error,msg=\"Command 'var-list-children'. Variable children range invalid\"")
+
 if __name__ == '__main__':
     unittest2.main()

Modified: lldb/trunk/test/tools/lldb-mi/variable/main.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/variable/main.cpp?rev=236820&r1=236819&r2=236820&view=diff
==============================================================================
--- lldb/trunk/test/tools/lldb-mi/variable/main.cpp (original)
+++ lldb/trunk/test/tools/lldb-mi/variable/main.cpp Fri May  8 05:10:14 2015
@@ -35,6 +35,16 @@ var_update_test(void)
 }
 
 void
+var_list_children(void)
+{
+    complex_type complx = { 3, { 3L }, &complx };
+    complex_type complx_array[2] = { { 4, { 4L }, &complx_array[1] }, { 5, { 5 }, &complx_array[0] } };
+
+    // BP_var_list_children
+}
+
+
+void
 gdb_set_show_print_char_array_as_string_test(void)
 {
     const char *string_ptr = "string - const char *";
@@ -70,6 +80,7 @@ main(int argc, char const *argv[])
     int a = 10, b = 20;
     s_MyVar = a + b;
     var_update_test();
+    var_list_children();
     gdb_set_show_print_char_array_as_string_test();
     gdb_set_show_print_expand_aggregates();
     gdb_set_show_print_aggregate_field_names();

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp?rev=236820&r1=236819&r2=236820&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp Fri May  8 05:10:14 2015
@@ -935,13 +935,17 @@ CMICmdCmdVarSetFormat::CreateSelf(void)
 // Throws:  None.
 //--
 CMICmdCmdVarListChildren::CMICmdCmdVarListChildren(void)
-    : m_bValueValid(false)
-    , m_nChildren(0)
-    , m_constStrArgPrintValues("print-values")
-    , m_constStrArgName("name")
+    : m_constStrArgPrintValues("print-values")
     , m_constStrArgNoValues("no-values")
     , m_constStrArgAllValues("all-values")
     , m_constStrArgSimpleValues("simple-values")
+    , m_constStrArgName("name")
+    , m_constStrArgFrom("from")
+    , m_constStrArgTo("to")
+    , m_bValueValid(false)
+    , m_nChildren(0)
+    , m_miValueList(true)
+    , m_bHasMore(false)
     {
     // Command factory matches this name with that received from the stdin stream
     m_strMiCmd = "var-list-children";
@@ -959,7 +963,6 @@ CMICmdCmdVarListChildren::CMICmdCmdVarLi
 //--
 CMICmdCmdVarListChildren::~CMICmdCmdVarListChildren(void)
 {
-    m_vecMiValueResult.clear();
 }
 
 //++ ------------------------------------------------------------------------------------
@@ -979,6 +982,8 @@ CMICmdCmdVarListChildren::ParseArgs(void
     bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgAllValues, false, true)));
     bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValOptionLong(m_constStrArgSimpleValues, false, true)));
     bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
+    bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgFrom, false, true)));
+    bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValNumber(m_constStrArgTo, false, true)));
     return (bOk && ParseValidateCmdOptions());
 }
 
@@ -994,25 +999,34 @@ CMICmdCmdVarListChildren::ParseArgs(void
 bool
 CMICmdCmdVarListChildren::Execute(void)
 {
+    CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues);
+    CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues);
+    CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues);
+    CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues);
     CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
-    CMICMDBASE_GETOPTION(pArgPrintValue, Number, m_constStrArgPrintValues);
-    CMICMDBASE_GETOPTION(pArgNoValue, OptionLong, m_constStrArgNoValues);
-    CMICMDBASE_GETOPTION(pArgAllValue, OptionLong, m_constStrArgAllValues);
-    CMICMDBASE_GETOPTION(pArgSimpleValue, OptionLong, m_constStrArgSimpleValues);
-
-    MIuint print_value = 0;
-    if (pArgPrintValue->GetFound())
-    {
-        MIuint tmp = pArgPrintValue->GetValue();
-        if (tmp <= 2)
-            print_value = tmp;
-    }
-    else if (pArgNoValue->GetFound())
-        print_value = 0; // no value
-    else if (pArgAllValue->GetFound())
-        print_value = 1; // all values
-    else if (pArgSimpleValue->GetFound())
-        print_value = 2; // simple values
+    CMICMDBASE_GETOPTION(pArgFrom, Number, m_constStrArgFrom);
+    CMICMDBASE_GETOPTION(pArgTo, Number, m_constStrArgTo);
+
+    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<CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e>(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
+        // If no print-values, default is "no-values"
+        eVarInfoFormat = CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues;
 
     const CMIUtilString &rVarObjName(pArgName->GetValue());
     CMICmnLLDBDebugSessionInfoVarObj varObj;
@@ -1022,18 +1036,32 @@ CMICmdCmdVarListChildren::Execute(void)
         return MIstatus::failure;
     }
 
+    MIuint nFrom = 0;
+    MIuint nTo = UINT32_MAX;
+    if (pArgFrom->GetFound() && pArgTo->GetFound())
+    {
+        nFrom = pArgFrom->GetValue();
+        nTo = pArgTo->GetValue();
+    }
+    else if (pArgFrom->GetFound() || pArgTo->GetFound())
+    {
+        // Only from or to was specified but both are required
+        SetError(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_VARIABLE_CHILD_RANGE_INVALID), m_cmdData.strMiCmd.c_str()));
+        return MIstatus::failure;
+    }
+
     lldb::SBValue &rValue = const_cast<lldb::SBValue &>(varObj.GetValue());
     m_bValueValid = rValue.IsValid();
     if (!m_bValueValid)
         return MIstatus::success;
 
-    m_vecMiValueResult.clear();
-    m_nChildren = rValue.GetNumChildren();
-    for (MIuint i = 0; i < m_nChildren; i++)
+    const MIuint nChildren = rValue.GetNumChildren();
+    m_bHasMore = nTo < nChildren;
+    nTo = std::min(nTo, nChildren);
+    m_nChildren = nFrom < nTo ? nTo - nFrom : 0;
+    for (MIuint i = nFrom; i < nTo; i++)
     {
         lldb::SBValue member = rValue.GetChildAtIndex(i);
-        if (!member.IsValid())
-            continue;
         const CMICmnLLDBUtilSBValue utilValue(member);
         const CMIUtilString strExp = utilValue.GetName();
         const CMIUtilString name(CMIUtilString::Format("%s.%s", rVarObjName.c_str(), strExp.c_str()));
@@ -1046,19 +1074,20 @@ CMICmdCmdVarListChildren::Execute(void)
         CMICmnMIValueTuple miValueTuple(miValueResult);
         const CMICmnMIValueConst miValueConst2(strExp);
         const CMICmnMIValueResult miValueResult2("exp", miValueConst2);
-        miValueTuple.Add(miValueResult2);
-        const CMIUtilString strNumChild(CMIUtilString::Format("%d", nChildren));
+        bool bOk = miValueTuple.Add(miValueResult2);
+        const CMIUtilString strNumChild(CMIUtilString::Format("%u", nChildren));
         const CMICmnMIValueConst miValueConst3(strNumChild);
         const CMICmnMIValueResult miValueResult3("numchild", miValueConst3);
-        miValueTuple.Add(miValueResult3);
+        bOk = bOk && miValueTuple.Add(miValueResult3);
         const CMICmnMIValueConst miValueConst5(utilValue.GetTypeNameDisplay());
         const CMICmnMIValueResult miValueResult5("type", miValueConst5);
-        miValueTuple.Add(miValueResult5);
+        bOk = bOk && miValueTuple.Add(miValueResult5);
         const CMICmnMIValueConst miValueConst6(strThreadId);
         const CMICmnMIValueResult miValueResult6("thread-id", miValueConst6);
-        miValueTuple.Add(miValueResult6);
+        bOk = bOk && miValueTuple.Add(miValueResult6);
         // nChildren == 0 is used to check for simple values
-        if ( (print_value == 2 && nChildren == 0) || (print_value == 1) )
+        if (eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues ||
+            (eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues && nChildren == 0))
         {
             // Varobj gets added to CMICmnLLDBDebugSessionInfoVarObj static container of varObjs
             CMICmnLLDBDebugSessionInfoVarObj var(strExp, name, member, rVarObjName);
@@ -1066,14 +1095,15 @@ CMICmdCmdVarListChildren::Execute(void)
             CMICmnLLDBDebugSessionInfoVarObj::GetValueStringFormatted(member, CMICmnLLDBDebugSessionInfoVarObj::eVarFormat_Natural));
             const CMICmnMIValueConst miValueConst7(strValue);
             const CMICmnMIValueResult miValueResult7("value", miValueConst7);
-            miValueTuple.Add(miValueResult7);
+            bOk = bOk && miValueTuple.Add(miValueResult7);
         }
         const CMICmnMIValueConst miValueConst8("0");
         const CMICmnMIValueResult miValueResult8("has_more", miValueConst8);
-        miValueTuple.Add(miValueResult8);
+        bOk = bOk && miValueTuple.Add(miValueResult8);
         const CMICmnMIValueResult miValueResult9("child", miValueTuple);
-        m_vecMiValueResult.push_back(miValueResult9);
-
+        bOk = bOk && m_miValueList.Add(miValueResult9);
+        if (!bOk)
+            return MIstatus::failure;
     }
 
     return MIstatus::success;
@@ -1093,36 +1123,29 @@ CMICmdCmdVarListChildren::Acknowledge(vo
 {
     if (m_bValueValid)
     {
-        // MI print "%s^done,numchild=\"%u\",children=[]""
+        // MI print "%s^done,numchild=\"%u\",children=[%s],has_more=\"%d\""
         const CMIUtilString strNumChild(CMIUtilString::Format("%u", m_nChildren));
         const CMICmnMIValueConst miValueConst(strNumChild);
         CMICmnMIValueResult miValueResult("numchild", miValueConst);
-
-        VecMIValueResult_t::const_iterator it = m_vecMiValueResult.begin();
-        if (it != m_vecMiValueResult.end())
-        {
-            CMICmnMIValueList miValueList(*it);
-            ++it;
-            while (it != m_vecMiValueResult.end())
-            {
-                const CMICmnMIValueResult &rResult(*it);
-                miValueList.Add(rResult);
-
-                // Next
-                ++it;
-            }
-            miValueResult.Add("children", miValueList);
-        }
+        bool bOk = MIstatus::success;
+        if (m_nChildren != 0)
+            bOk = bOk && miValueResult.Add("children", m_miValueList);
+        const CMIUtilString strHasMore(m_bHasMore ? "1" : "0");
+        const CMICmnMIValueConst miValueConst2(strHasMore);
+        bOk = bOk && miValueResult.Add("has_more", miValueConst2);
+        if (!bOk)
+            return MIstatus::failure;
 
         const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
         m_miResultRecord = miRecordResult;
+
         return MIstatus::success;
     }
 
-    // MI print "%s^done,numchild=\"0\""
-    const CMICmnMIValueConst miValueConst("0");
-    const CMICmnMIValueResult miValueResult("numchild", miValueConst);
-    const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Done, miValueResult);
+    // MI print "%s^error,msg=\"variable invalid\""
+    const CMICmnMIValueConst miValueConst("variable invalid");
+    const CMICmnMIValueResult miValueResult("msg", miValueConst);
+    const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
     m_miResultRecord = miRecordResult;
 
     return MIstatus::success;

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdVar.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdVar.h?rev=236820&r1=236819&r2=236820&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdVar.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdVar.h Fri May  8 05:10:14 2015
@@ -263,20 +263,19 @@ class CMICmdCmdVarListChildren : public
     // From CMICmnBase
     /* dtor */ virtual ~CMICmdCmdVarListChildren(void);
 
-    // Typedefs:
-  private:
-    typedef std::vector<CMICmnMIValueResult> VecMIValueResult_t;
-
     // Attributes:
   private:
-    bool m_bValueValid; // True = yes SBValue object is valid, false = not valid
-    VecMIValueResult_t m_vecMiValueResult;
-    MIuint m_nChildren;
     const CMIUtilString m_constStrArgPrintValues;
-    const CMIUtilString m_constStrArgName;
     const CMIUtilString m_constStrArgNoValues;
     const CMIUtilString m_constStrArgAllValues;
     const CMIUtilString m_constStrArgSimpleValues;
+    const CMIUtilString m_constStrArgName;
+    const CMIUtilString m_constStrArgFrom;
+    const CMIUtilString m_constStrArgTo;
+    bool m_bValueValid; // True = yes SBValue object is valid, false = not valid
+    MIuint m_nChildren;
+    CMICmnMIValueList m_miValueList;
+    bool m_bHasMore;
 };
 
 //++ ============================================================================

Modified: lldb/trunk/tools/lldb-mi/MICmnResources.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnResources.cpp?rev=236820&r1=236819&r2=236820&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnResources.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmnResources.cpp Fri May  8 05:10:14 2015
@@ -227,6 +227,7 @@ const CMICmnResources::SRsrcTextData CMI
     {IDS_CMD_ERR_VARIABLE_ENUM_INVALID, "Command '%s'. Invalid enumeration for variable '%s' formatted string '%s'"},
     {IDS_CMD_ERR_VARIABLE_EXPRESSIONPATH, "Command '%s'. Failed to get expression for variable '%s'"},
     {IDS_CMD_ERR_VARIABLE_CREATION_FAILED, "Failed to create variable object for '%s'"},
+    {IDS_CMD_ERR_VARIABLE_CHILD_RANGE_INVALID, "Command '%s'. Variable children range invalid"},
     {IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION, "<Error: Command run but command did not do anything useful. No MI response formed>"},
     {IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION, "<Error: Command run and event caught, did nothing useful. No MI Out-of-Bound formed>"},
     {IDS_CMD_ERR_DISASM_ADDR_START_INVALID, "Command '%s'. Invalid start value '%s'"},

Modified: lldb/trunk/tools/lldb-mi/MICmnResources.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmnResources.h?rev=236820&r1=236819&r2=236820&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmnResources.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmnResources.h Fri May  8 05:10:14 2015
@@ -245,6 +245,7 @@ enum
     IDS_CMD_ERR_VARIABLE_ENUM_INVALID,
     IDS_CMD_ERR_VARIABLE_EXPRESSIONPATH,
     IDS_CMD_ERR_VARIABLE_CREATION_FAILED,
+    IDS_CMD_ERR_VARIABLE_CHILD_RANGE_INVALID,
     IDS_CMD_ERR_CMD_RUN_BUT_NO_ACTION,
     IDS_CMD_ERR_EVENT_HANDLED_BUT_NO_ACTION,
     IDS_CMD_ERR_DISASM_ADDR_START_INVALID,





More information about the lldb-commits mailing list