[Lldb-commits] [lldb] r251727 - Abstract the notion of the truth value of an expression result, for use

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 30 17:02:18 PDT 2015


Author: jingham
Date: Fri Oct 30 19:02:18 2015
New Revision: 251727

URL: http://llvm.org/viewvc/llvm-project?rev=251727&view=rev
Log:
Abstract the notion of the truth value of an expression result, for use
in breakpoint conditions.

Modified:
    lldb/trunk/include/lldb/Core/ValueObject.h
    lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
    lldb/trunk/source/Core/ValueObject.cpp

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=251727&r1=251726&r2=251727&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Oct 30 19:02:18 2015
@@ -605,6 +605,12 @@ public:
     virtual bool
     ResolveValue (Scalar &scalar);
     
+    // return 'false' whenever you set the error, otherwise
+    // callers may assume true means everything is OK - this will
+    // break breakpoint conditions among potentially a few others
+    virtual bool
+    IsLogicalTrue (Error& error);
+    
     virtual const char *
     GetLocationAsCString ();
 

Modified: lldb/trunk/source/Breakpoint/BreakpointLocation.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Breakpoint/BreakpointLocation.cpp?rev=251727&r1=251726&r2=251727&view=diff
==============================================================================
--- lldb/trunk/source/Breakpoint/BreakpointLocation.cpp (original)
+++ lldb/trunk/source/Breakpoint/BreakpointLocation.cpp Fri Oct 30 19:02:18 2015
@@ -356,18 +356,20 @@ BreakpointLocation::ConditionSaysStop (E
 
         if (result_value_sp)
         {
-            Scalar scalar_value;
-            if (result_value_sp->ResolveValue (scalar_value))
+            ret = result_value_sp->IsLogicalTrue(error);
+            if (log)
             {
-                ret = (scalar_value.ULongLong(1) != 0);
-                if (log)
+                if (error.Success())
+                {
                     log->Printf("Condition successfully evaluated, result is %s.\n",
                                 ret ? "true" : "false");
-            }
-            else
-            {
-                ret = false;
-                error.SetErrorString("Failed to get an integer result from the expression");
+                }
+                else
+                {
+                    error.SetErrorString("Failed to get an integer result from the expression");
+                    ret = false;
+                }
+                
             }
         }
         else

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=251727&r1=251726&r2=251727&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Oct 30 19:02:18 2015
@@ -513,6 +513,26 @@ ValueObject::ResolveValue (Scalar &scala
 }
 
 bool
+ValueObject::IsLogicalTrue (Error& error)
+{
+    Scalar scalar_value;
+    
+    if (!ResolveValue (scalar_value))
+    {
+        error.SetErrorString("failed to get a scalar result");
+        return false;
+    }
+    
+    bool ret;
+    if (scalar_value.ULongLong(1) == 0)
+        ret = false;
+    else
+        ret = true;
+    error.Clear();
+    return ret;
+}
+
+bool
 ValueObject::GetValueIsValid () const
 {
     return m_value_is_valid;




More information about the lldb-commits mailing list