[Lldb-commits] [lldb] r155494 - in /lldb/trunk: include/lldb/Core/ValueObject.h source/Core/ValueObject.cpp source/Target/Target.cpp

Enrico Granata egranata at apple.com
Tue Apr 24 15:15:37 PDT 2012


Author: enrico
Date: Tue Apr 24 17:15:37 2012
New Revision: 155494

URL: http://llvm.org/viewvc/llvm-project?rev=155494&view=rev
Log:
Fixing an issue where the expression parser was not correctly freeze-drying bitfields - This patch ensures that (a) freeze-drying bitfields works correctly and (b) that we actually access bitfields through IR instead of the 'frame var en lieu of expr' shortcut, for added safety in corner cases that may arise

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

Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=155494&r1=155493&r2=155494&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Tue Apr 24 17:15:37 2012
@@ -656,17 +656,23 @@
     }
 
     virtual uint32_t
-    GetBitfieldBitSize()
+    GetBitfieldBitSize ()
     {
         return 0;
     }
 
     virtual uint32_t
-    GetBitfieldBitOffset()
+    GetBitfieldBitOffset ()
     {
         return 0;
     }
     
+    bool
+    IsBitfield ()
+    {
+        return (GetBitfieldBitSize() != 0) || (GetBitfieldOffset() != 0);
+    }
+    
     virtual bool
     IsArrayItemForPointer()
     {

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=155494&r1=155493&r2=155494&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Tue Apr 24 17:15:37 2012
@@ -3485,7 +3485,13 @@
         data.SetByteOrder (m_data.GetByteOrder());
         data.SetAddressByteSize(m_data.GetAddressByteSize());
         
-        m_error = m_value.GetValueAsData (&exe_ctx, ast, data, 0, GetModule().get());
+        if (IsBitfield())
+        {
+            Value v(Scalar(GetValueAsUnsigned(UINT64_MAX)));
+            m_error = v.GetValueAsData (&exe_ctx, ast, data, 0, GetModule().get());
+        }
+        else
+            m_error = m_value.GetValueAsData (&exe_ctx, ast, data, 0, GetModule().get());
         
         valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), 
                                                     ast,

Modified: lldb/trunk/source/Target/Target.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/Target.cpp?rev=155494&r1=155493&r2=155494&view=diff
==============================================================================
--- lldb/trunk/source/Target/Target.cpp (original)
+++ lldb/trunk/source/Target/Target.cpp Tue Apr 24 17:15:37 2012
@@ -1594,6 +1594,9 @@
                                                                          expr_path_options, 
                                                                          var_sp, 
                                                                          error);
+            // if this expression results in a bitfield, we give up and let the IR handle it
+            if (result_valobj_sp && result_valobj_sp->IsBitfield())
+                result_valobj_sp.reset();
         }
     }
     else if (m_process_sp)





More information about the lldb-commits mailing list