From 0b9e04b7c481fc26529fac8cd753af1aa0990785 Mon Sep 17 00:00:00 2001 From: Ilia K Date: Thu, 25 Jun 2015 11:10:12 +0000 Subject: [PATCH] Expand result with type char* to string in -data-evaluate-expression Summary: Expand result with type char* to string in -data-evaluate-expression. was: ``` -data-evaluate-expression str ^done,value="0x00007fffffffece0" ``` now: ``` -data-evaluate-expression str ^done,value="0x00007fffffffece0 \"hello\"" ``` All tests pass on Linux. Test Plan: ./dotest.py -v --executable $BUILDDIR/bin/lldb tools/lldb-mi Reviewers: abidh Reviewed By: abidh Subscribers: lldb-commits, dawn, abidh Differential Revision: http://reviews.llvm.org/D10728 llvm-svn: 240631 --- lldb/test/tools/lldb-mi/data/TestMiData.py | 2 +- lldb/test/tools/lldb-mi/variable/TestMiVar.py | 2 +- lldb/tools/lldb-mi/MICmdCmdData.cpp | 9 ++------- 3 files changed, 4 insertions(+), 9 deletions(-) diff --git a/lldb/test/tools/lldb-mi/data/TestMiData.py b/lldb/test/tools/lldb-mi/data/TestMiData.py index 3a28139..1920a95 100644 --- a/lldb/test/tools/lldb-mi/data/TestMiData.py +++ b/lldb/test/tools/lldb-mi/data/TestMiData.py @@ -122,7 +122,7 @@ class MiDataTestCase(lldbmi_testcase.MiTestCaseBase): self.expect(r'\*stopped,reason="breakpoint-hit"') # Get address of local char[] - self.runCmd('-data-evaluate-expression &array') + self.runCmd('-data-evaluate-expression "(void *)&array"') self.expect(r'\^done,value="0x[0-9a-f]+"') addr = int(self.child.after.split('"')[1], 16) size = 4 diff --git a/lldb/test/tools/lldb-mi/variable/TestMiVar.py b/lldb/test/tools/lldb-mi/variable/TestMiVar.py index 1a3d601..eeb4f60 100644 --- a/lldb/test/tools/lldb-mi/variable/TestMiVar.py +++ b/lldb/test/tools/lldb-mi/variable/TestMiVar.py @@ -111,7 +111,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): # Print argument "argv[0]" self.runCmd("-data-evaluate-expression \"argv[0]\"") - self.expect("\^done,value=\"0x[0-9a-f]+\"") + self.expect("\^done,value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\"" % self.myexe) self.runCmd("-var-create var6 * \"argv[0]\"") self.expect("\^done,name=\"var6\",numchild=\"1\",value=\"0x[0-9a-f]+ \\\\\\\".*?%s\\\\\\\"\",type=\"const char \*\",thread-id=\"1\",has_more=\"0\"" % self.myexe) self.runCmd("-var-evaluate-expression var6") diff --git a/lldb/tools/lldb-mi/MICmdCmdData.cpp b/lldb/tools/lldb-mi/MICmdCmdData.cpp index 9be9f1b..d0cd4f8 100644 --- a/lldb/tools/lldb-mi/MICmdCmdData.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdData.cpp @@ -125,7 +125,7 @@ CMICmdCmdDataEvaluateExpression::Execute(void) lldb::SBValue value = frame.EvaluateExpression(rExpression.c_str()); if (!value.IsValid() || value.GetError().Fail()) value = frame.FindVariable(rExpression.c_str()); - const CMICmnLLDBUtilSBValue utilValue(value); + const CMICmnLLDBUtilSBValue utilValue(value, true); if (!utilValue.IsValid() || utilValue.IsValueUnknown()) { m_bEvaluatedExpression = false; @@ -153,12 +153,7 @@ CMICmdCmdDataEvaluateExpression::Execute(void) { const lldb::ValueType eValueType = value.GetValueType(); MIunused(eValueType); - m_strValue = utilValue.GetValue(); - CMIUtilString strCString; - if (CMICmnLLDBProxySBValue::GetCString(value, strCString)) - { - m_strValue += CMIUtilString::Format(" '%s'", strCString.c_str()); - } + m_strValue = utilValue.GetValue().Escape().AddSlashes(); return MIstatus::success; } -- 2.7.4