[Lldb-commits] [lldb] r260082 - Show real error message in -data-evaluate-expression

Eugene Leviant via lldb-commits lldb-commits at lists.llvm.org
Mon Feb 8 02:04:52 PST 2016


Author: evgeny777
Date: Mon Feb  8 04:04:51 2016
New Revision: 260082

URL: http://llvm.org/viewvc/llvm-project?rev=260082&view=rev
Log:
Show real error message in -data-evaluate-expression

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
    lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
    lldb/trunk/tools/lldb-mi/MICmdCmdData.h

Modified: lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py?rev=260082&r1=260081&r2=260082&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/tools/lldb-mi/variable/TestMiVar.py Mon Feb  8 04:04:51 2016
@@ -38,7 +38,7 @@ class MiVarTestCase(lldbmi_testcase.MiTe
         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")

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp?rev=260082&r1=260081&r2=260082&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.cpp Mon Feb  8 04:04:51 2016
@@ -117,7 +117,8 @@ CMICmdCmdDataEvaluateExpression::Execute
 
     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 @@ CMICmdCmdDataEvaluateExpression::Acknowl
             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;

Modified: lldb/trunk/tools/lldb-mi/MICmdCmdData.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/tools/lldb-mi/MICmdCmdData.h?rev=260082&r1=260081&r2=260082&view=diff
==============================================================================
--- lldb/trunk/tools/lldb-mi/MICmdCmdData.h (original)
+++ lldb/trunk/tools/lldb-mi/MICmdCmdData.h Mon Feb  8 04:04:51 2016
@@ -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 @@ class CMICmdCmdDataEvaluateExpression :
   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




More information about the lldb-commits mailing list