Show error message from failed evaluation when doing -var-create
authorIlia K <ki.stfu@gmail.com>
Tue, 12 May 2015 06:15:16 +0000 (06:15 +0000)
committerIlia K <ki.stfu@gmail.com>
Tue, 12 May 2015 06:15:16 +0000 (06:15 +0000)
Summary:
When -var-create fails, we will now show the error message from the failed evaluation if it is available.

Patch from chuckr@microsoft.com

Test Plan: I fixed the MiVarTestCase.test_lldbmi_eval test to expect the new error string. All MI tests passing on OS X.

Reviewers: abidh, ChuckR

Subscribers: greggm, lldb-commits, paulmaybee

Differential Revision: http://reviews.llvm.org/D9691

llvm-svn: 237094

lldb/test/tools/lldb-mi/variable/TestMiVar.py
lldb/tools/lldb-mi/MICmdCmdVar.cpp

index 6d9972d..f1bb6e8 100644 (file)
@@ -32,7 +32,7 @@ class MiVarTestCase(lldbmi_testcase.MiTestCaseBase):
 
         # Print non-existant variable
         self.runCmd("-var-create var1 * undef")
-        self.expect("\^error,msg=\"Failed to create variable object for 'undef'\"")
+        self.expect("\^error,msg=\"error: error: use of undeclared identifier \'undef\'\s+error: 1 errors parsing expression\"")
         self.runCmd("-data-evaluate-expression undef")
         self.expect("\^error,msg=\"Could not evaluate expression\"")
 
index 99c0906..37e5eb0 100644 (file)
@@ -208,6 +208,12 @@ CMICmdCmdVarCreate::Execute(void)
         CMICmnLLDBDebugSessionInfoVarObj varObj(rStrExpression, m_strVarName, value);
         m_strValue = varObj.GetValueFormatted();
     }
+    else 
+    {
+        lldb::SBStream err;
+        if (value.GetError().GetDescription(err))
+            m_strValue = err.GetData();
+    }
 
     return MIstatus::success;
 }
@@ -248,7 +254,10 @@ CMICmdCmdVarCreate::Acknowledge(void)
         return MIstatus::success;
     }
 
-    const CMICmnMIValueConst miValueConst(CMIUtilString::Format(MIRSRC(IDS_CMD_ERR_VARIABLE_CREATION_FAILED), m_strExpression.c_str()));
+    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);
     CMICmnMIValueResult miValueResult("msg", miValueConst);
     const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult);
     m_miResultRecord = miRecordResult;