Enable printing values for var-list-children command
authorIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 10 Jul 2017 19:46:30 +0000 (22:46 +0300)
committerIgor Kulaychuk <i.kulaychuk@samsung.com>
Mon, 13 Nov 2017 19:22:40 +0000 (22:22 +0300)
src/debug/debugger/main.cpp
src/debug/debugger/varobj.cpp

index da32f5e..df187bb 100644 (file)
@@ -129,7 +129,7 @@ void NotifyEvalComplete();
 // Varobj
 HRESULT ListVariables(ICorDebugFrame *pFrame, std::string &output);
 HRESULT CreateVar(ICorDebugFrame *pFrame, const std::string &varobjName, const std::string &expression, std::string &output);
-HRESULT ListChildren(const std::string &name, ICorDebugFrame *pFrame, std::string &output);
+HRESULT ListChildren(const std::string &name, int print_values, ICorDebugFrame *pFrame, std::string &output);
 HRESULT DeleteVar(const std::string &varobjName);
 
 // TypePrinter
@@ -1197,7 +1197,23 @@ int main(int argc, char *argv[])
         }
         else if (command == "var-list-children")
         {
-            if (args.size() < 1)
+            int print_values = 0;
+            int var_index = 0;
+            if (!args.empty())
+            {
+                if (args.at(0) == "1" || args.at(0) == "--all-values")
+                {
+                    print_values = 1;
+                    var_index++;
+                }
+                else if (args.at(0) == "2" || args.at(0) == "--simple-values")
+                {
+                    print_values = 2;
+                    var_index++;
+                }
+            }
+
+            if (args.size() < (var_index + 1))
             {
                 out_printf("%s^error,msg=\"%s requires an argument\"\n", token.c_str(), command.c_str());
             } else {
@@ -1210,7 +1226,7 @@ int main(int argc, char *argv[])
                     ToRelease<ICorDebugFrame> pFrame;
                     hr = g_currentThread ? g_currentThread->GetActiveFrame(&pFrame) : E_FAIL;
                     if (SUCCEEDED(hr))
-                        hr = ListChildren(args.at(0), pFrame, output);
+                        hr = ListChildren(args.at(var_index), print_values, pFrame, output);
                 }
                 if (SUCCEEDED(hr))
                 {
index 0a2884e..340e112 100644 (file)
@@ -163,7 +163,7 @@ void FixupInheritedFieldNames(std::vector<VarObjValue> &members)
     }
 }
 
-void PrintChildren(std::vector<VarObjValue> &members, std::string &output)
+void PrintChildren(std::vector<VarObjValue> &members, int print_values, ICorDebugILFrame *pILFrame, std::string &output)
 {
     std::stringstream ss;
     ss << "numchild=\"" << members.size() << "\"";
@@ -181,7 +181,15 @@ void PrintChildren(std::vector<VarObjValue> &members, std::string &output)
         ss << sep;
         sep = ",";
 
-        ss << "child={name=\"" << m.varobjName << "\",exp=\"" << m.name << "\",";
+        ss << "child={name=\"" << m.varobjName << "\",";
+        if (print_values)
+        {
+            std::string strVal;
+            if (m.value)
+                PrintValue(m.value, pILFrame, strVal);
+            ss << "value=\"" << strVal << "\",";
+        }
+        ss << "exp=\"" << m.name << "\",";
         ss << "numchild=\"" << m.numchild << "\",type=\"" << m.typeName << "\"}";
         //thread-id="452958",has_more="0"}
     }
@@ -213,7 +221,7 @@ static std::string InsertVar(VarObjValue &varobj)
     return varName;
 }
 
-HRESULT ListChildren(VarObjValue &objValue, ICorDebugFrame *pFrame, std::string &output)
+HRESULT ListChildren(VarObjValue &objValue, int print_values, ICorDebugFrame *pFrame, std::string &output)
 {
     HRESULT Status;
 
@@ -253,17 +261,17 @@ HRESULT ListChildren(VarObjValue &objValue, ICorDebugFrame *pFrame, std::string
         InsertVar(m);
     }
 
-    PrintChildren(members, output);
+    PrintChildren(members, print_values, pILFrame, output);
 
     return S_OK;
 }
 
-HRESULT ListChildren(const std::string &name, ICorDebugFrame *pFrame, std::string &output)
+HRESULT ListChildren(const std::string &name, int print_values, ICorDebugFrame *pFrame, std::string &output)
 {
     auto it = g_vars.find(name);
     if (it == g_vars.end())
         return E_FAIL;
-    return ListChildren(it->second, pFrame, output);
+    return ListChildren(it->second, print_values, pFrame, output);
 }
 
 HRESULT ListVariables(ICorDebugFrame *pFrame, std::string &output)