Fixing an issue where the expression parser was not correctly freeze-drying bitfields...
authorEnrico Granata <egranata@apple.com>
Tue, 24 Apr 2012 22:15:37 +0000 (22:15 +0000)
committerEnrico Granata <egranata@apple.com>
Tue, 24 Apr 2012 22:15:37 +0000 (22:15 +0000)
llvm-svn: 155494

lldb/include/lldb/Core/ValueObject.h
lldb/source/Core/ValueObject.cpp
lldb/source/Target/Target.cpp

index bc3cab3..0de3f91 100644 (file)
@@ -656,17 +656,23 @@ public:
     }
 
     virtual uint32_t
-    GetBitfieldBitSize()
+    GetBitfieldBitSize ()
     {
         return 0;
     }
 
     virtual uint32_t
-    GetBitfieldBitOffset()
+    GetBitfieldBitOffset ()
     {
         return 0;
     }
     
+    bool
+    IsBitfield ()
+    {
+        return (GetBitfieldBitSize() != 0) || (GetBitfieldOffset() != 0);
+    }
+    
     virtual bool
     IsArrayItemForPointer()
     {
index 800ab06..008ff4f 100644 (file)
@@ -3485,7 +3485,13 @@ ValueObject::CreateConstantValue (const ConstString &name)
         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,
index 3fdf166..6671a76 100644 (file)
@@ -1594,6 +1594,9 @@ Target::EvaluateExpression
                                                                          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)