Index: packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py =================================================================== --- packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py +++ packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py @@ -36,7 +36,7 @@ self.runCmd("-var-create var1 * undef") 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\"") + self.expect("\^error,msg=\"error: use of undeclared identifier \'undef\'\\\\nerror: 1 errors parsing expression\\\\n\"") # Print global "g_MyVar", modify, delete and create again self.runCmd("-data-evaluate-expression g_MyVar") Index: tools/lldb-mi/MICmdCmdData.h =================================================================== --- tools/lldb-mi/MICmdCmdData.h +++ tools/lldb-mi/MICmdCmdData.h @@ -32,6 +32,7 @@ // Third party headers: #include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBError.h" // In-house headers: #include "MICmdBase.h" @@ -71,6 +72,7 @@ private: bool m_bExpressionValid; // True = yes is valid, false = not valid bool m_bEvaluatedExpression; // True = yes is expression evaluated, false = failed + lldb::SBError m_Error; // Error object, which is examined when m_bEvaluatedExpression is false CMIUtilString m_strValue; CMICmnMIValueTuple m_miValueTuple; bool m_bFoundInvalidChar; // True = yes found unexpected character in the expression, false = all ok Index: tools/lldb-mi/MICmdCmdData.cpp =================================================================== --- tools/lldb-mi/MICmdCmdData.cpp +++ tools/lldb-mi/MICmdCmdData.cpp @@ -117,7 +117,8 @@ lldb::SBFrame frame = thread.GetSelectedFrame(); lldb::SBValue value = frame.EvaluateExpression(rExpression.c_str()); - if (!value.IsValid() || value.GetError().Fail()) + m_Error = value.GetError(); + if (!value.IsValid() || m_Error.Fail()) value = frame.FindVariable(rExpression.c_str()); const CMICmnLLDBUtilSBValue utilValue(value, true); if (!utilValue.IsValid() || utilValue.IsValueUnknown()) @@ -177,8 +178,10 @@ m_miResultRecord = miRecordResult; return MIstatus::success; } - - const CMICmnMIValueConst miValueConst("Could not evaluate expression"); + CMIUtilString mi_error_msg = "Could not evaluate expression"; + if (const char* err_msg = m_Error.GetCString()) + mi_error_msg = err_msg; + const CMICmnMIValueConst miValueConst(mi_error_msg.Escape(true)); const CMICmnMIValueResult miValueResult("msg", miValueConst); const CMICmnMIResultRecord miRecordResult(m_cmdData.strMiCmdToken, CMICmnMIResultRecord::eResultClass_Error, miValueResult); m_miResultRecord = miRecordResult;