From: Igor Kulaychuk Date: Mon, 10 Jul 2017 19:46:30 +0000 (+0300) Subject: Enable printing values for var-list-children command X-Git-Tag: submit/tizen/20180620.071641~236 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=905b1bd728249dd7bdc43f5864185e3d6fb28a50;p=sdk%2Ftools%2Fnetcoredbg.git Enable printing values for var-list-children command --- diff --git a/src/debug/debugger/main.cpp b/src/debug/debugger/main.cpp index da32f5e..df187bb 100644 --- a/src/debug/debugger/main.cpp +++ b/src/debug/debugger/main.cpp @@ -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 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)) { diff --git a/src/debug/debugger/varobj.cpp b/src/debug/debugger/varobj.cpp index 0a2884e..340e112 100644 --- a/src/debug/debugger/varobj.cpp +++ b/src/debug/debugger/varobj.cpp @@ -163,7 +163,7 @@ void FixupInheritedFieldNames(std::vector &members) } } -void PrintChildren(std::vector &members, std::string &output) +void PrintChildren(std::vector &members, int print_values, ICorDebugILFrame *pILFrame, std::string &output) { std::stringstream ss; ss << "numchild=\"" << members.size() << "\""; @@ -181,7 +181,15 @@ void PrintChildren(std::vector &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)