Updated patch with suggested changes

REPOSITORY
  rL LLVM

http://reviews.llvm.org/D8008

Files:
  lldb/tools/lldb-mi/MICmdCmdVar.cpp
  lldb/tools/lldb-mi/MICmdCmdVar.h
  lldb/tools/lldb-mi/MICmnResources.cpp

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/
Index: lldb/tools/lldb-mi/MICmdCmdVar.cpp
===================================================================
--- lldb/tools/lldb-mi/MICmdCmdVar.cpp
+++ lldb/tools/lldb-mi/MICmdCmdVar.cpp
@@ -276,6 +276,9 @@
     : m_eVarInfoFormat(CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues)
     , m_constStrArgPrintValues("print-values")
     , m_constStrArgName("name")
+    , m_constStrArgNoValues("no-values")
+    , m_constStrArgAllValues("all-values")
+    , m_constStrArgSimpleValues("simple-values")
     , m_bValueChangedArrayType(false)
     , m_bValueChangedCompositeType(false)
     , m_bValueChangedNormalType(false)
@@ -312,6 +315,9 @@
 CMICmdCmdVarUpdate::ParseArgs(void)
 {
     bool 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)));
     bOk = bOk && m_setCmdArgs.Add(*(new CMICmdArgValString(m_constStrArgName, true, true)));
     return (bOk && ParseValidateCmdOptions());
 }
@@ -330,7 +336,32 @@
 {
     CMICMDBASE_GETOPTION(pArgPrintValues, Number, m_constStrArgPrintValues);
     CMICMDBASE_GETOPTION(pArgName, String, m_constStrArgName);
+    CMICMDBASE_GETOPTION(pArgNoValues, OptionLong, m_constStrArgNoValues);
+    CMICMDBASE_GETOPTION(pArgAllValues, OptionLong, m_constStrArgAllValues);
+    CMICMDBASE_GETOPTION(pArgSimpleValues, OptionLong, m_constStrArgSimpleValues);
 
+    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;
+    m_eVarInfoFormat = eVarInfoFormat;
+
     const CMIUtilString &rVarObjName(pArgName->GetValue());
     CMICmnLLDBDebugSessionInfoVarObj varObj;
     if (!CMICmnLLDBDebugSessionInfoVarObj::VarObjGet(rVarObjName, varObj))
@@ -339,14 +370,6 @@
         return MIstatus::failure;
     }
 
-    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;
-    }
-    m_eVarInfoFormat = static_cast<CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e>(nPrintValues);
-
     const CMIUtilString &rVarRealName(varObj.GetNameReal());
     MIunused(rVarRealName);
     lldb::SBValue &rValue = const_cast<lldb::SBValue &>(varObj.GetValue());
@@ -436,7 +459,9 @@
         const CMICmnMIValueConst miValueConst(m_strValueName);
         CMICmnMIValueResult miValueResult("name", miValueConst);
         CMICmnMIValueTuple miValueTuple(miValueResult);
-        if (m_eVarInfoFormat != CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_NoValues)
+        if (m_eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues ||
+           (m_eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_SimpleValues
+           && m_bValueChangedNormalType))
         {
             const CMICmnMIValueConst miValueConst2(strValue);
             CMICmnMIValueResult miValueResult2("value", miValueConst2);
@@ -511,8 +536,12 @@
     CMICmnMIValueResult miValueResult("name", miValueConst);
     CMICmnMIValueTuple miValueTuple(miValueResult);
     const CMICmnMIValueConst miValueConst2(vrStrValue);
-    CMICmnMIValueResult miValueResult2("value", miValueConst2);
-    bool bOk = miValueTuple.Add(miValueResult2);
+    bool bOk = true;
+    if(m_eVarInfoFormat == CMICmnLLDBDebugSessionInfo::eVariableInfoFormat_AllValues)
+    {
+      CMICmnMIValueResult miValueResult2("value", miValueConst2);
+      bOk = bOk && miValueTuple.Add(miValueResult2);
+    }
     const CMICmnMIValueConst miValueConst3(vrStrScope);
     CMICmnMIValueResult miValueResult3("in_scope", miValueConst3);
     bOk = bOk && miValueTuple.Add(miValueResult3);
Index: lldb/tools/lldb-mi/MICmdCmdVar.h
===================================================================
--- lldb/tools/lldb-mi/MICmdCmdVar.h
+++ lldb/tools/lldb-mi/MICmdCmdVar.h
@@ -131,8 +131,11 @@
   private:
     CMIUtilString m_strValueName;
     CMICmnLLDBDebugSessionInfo::VariableInfoFormat_e m_eVarInfoFormat;
-    const CMIUtilString m_constStrArgPrintValues; // Not handled by *this command
+    const CMIUtilString m_constStrArgPrintValues;
     const CMIUtilString m_constStrArgName;
+    const CMIUtilString m_constStrArgNoValues;
+    const CMIUtilString m_constStrArgAllValues;
+    const CMIUtilString m_constStrArgSimpleValues;
     bool m_bValueChangedArrayType;     // True = yes value changed, false = no change
     bool m_bValueChangedCompositeType; // True = yes value changed, false = no change
     bool m_bValueChangedNormalType;    // True = yes value changed, false = no change
Index: lldb/tools/lldb-mi/MICmnResources.cpp
===================================================================
--- lldb/tools/lldb-mi/MICmnResources.cpp
+++ lldb/tools/lldb-mi/MICmnResources.cpp
@@ -255,7 +255,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_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 "},
_______________________________________________
lldb-commits mailing list
lldb-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits

Reply via email to