Author: ki.stfu Date: Tue May 12 01:15:16 2015 New Revision: 237094 URL: http://llvm.org/viewvc/llvm-project?rev=237094&view=rev Log: Show error message from failed evaluation when doing -var-create
Summary: When -var-create fails, we will now show the error message from the failed evaluation if it is available. Patch from chu...@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 Modified: lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp Modified: lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py?rev=237094&r1=237093&r2=237094&view=diff ============================================================================== --- lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py (original) +++ lldb/trunk/test/tools/lldb-mi/variable/TestMiVar.py Tue May 12 01:15:16 2015 @@ -32,7 +32,7 @@ class MiVarTestCase(lldbmi_testcase.MiTe # 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\"") Modified: lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp?rev=237094&r1=237093&r2=237094&view=diff ============================================================================== --- lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp (original) +++ lldb/trunk/tools/lldb-mi/MICmdCmdVar.cpp Tue May 12 01:15:16 2015 @@ -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; _______________________________________________ lldb-commits mailing list lldb-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/lldb-commits