From 311d08f8de5864a5f918adb5e36b4f80a062e51b Mon Sep 17 00:00:00 2001 From: Hafiz Abid Qadeer Date: Fri, 31 Jul 2015 09:24:39 +0000 Subject: [PATCH] Escape new line and tabs in the result of variable evaluation. Expression evaluation error messages may have embedded new lines and tabs. These should be escaped in the result string. Patch by paulmaybee. Reviewed in http://reviews.llvm.org/D11570. llvm-svn: 243741 --- lldb/test/tools/lldb-mi/variable/TestMiVar.py | 2 +- lldb/tools/lldb-mi/MICmdCmdVar.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/test/tools/lldb-mi/variable/TestMiVar.py b/lldb/test/tools/lldb-mi/variable/TestMiVar.py index eeb4f60..e8813c4 100644 --- a/lldb/test/tools/lldb-mi/variable/TestMiVar.py +++ b/lldb/test/tools/lldb-mi/variable/TestMiVar.py @@ -33,7 +33,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase): # Print non-existant variable self.runCmd("-var-create var1 * undef") - self.expect("\^error,msg=\"error: error: use of undeclared identifier \'undef\'\s+error: 1 errors parsing expression\"") + self.expect("\^error,msg=\"error: error: use of undeclared identifier \'undef\'\\\\nerror: 1 errors parsing expression\\\\n\"") self.runCmd("-data-evaluate-expression undef") self.expect("\^error,msg=\"Could not evaluate expression\"") diff --git a/lldb/tools/lldb-mi/MICmdCmdVar.cpp b/lldb/tools/lldb-mi/MICmdCmdVar.cpp index 3c3c922..97270ec 100644 --- a/lldb/tools/lldb-mi/MICmdCmdVar.cpp +++ b/lldb/tools/lldb-mi/MICmdCmdVar.cpp @@ -255,7 +255,7 @@ CMICmdCmdVarCreate::Acknowledge(void) CMIUtilString strErrMsg(m_strValue); if (m_strValue.empty()) strErrMsg = CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_VARIABLE_CREATION_FAILED), m_strExpression.c_str()); - const CMICmnMIValueConst miValueConst(strErrMsg); + const CMICmnMIValueConst miValueConst(strErrMsg.Escape(true /* vbEscapeQuotes */)); CMICmnMIValueResult miValueResult("msg", miValueConst); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult); m_miResultRecord = miRecordResult; -- 2.7.4