Preparatory infrastructural work to support dynamically determining sizes of ObjC...
authorEnrico Granata <egranata@apple.com>
Wed, 28 Jan 2015 00:07:51 +0000 (00:07 +0000)
committerEnrico Granata <egranata@apple.com>
Wed, 28 Jan 2015 00:07:51 +0000 (00:07 +0000)
This is necessary because the byte size of an ObjC class type is not reliably statically knowable (e.g. because superclasses sit deep in frameworks that we have no debug info for)
The lack of reliable size info is a problem when trying to freeze-dry an ObjC instance (not the pointer, the pointee)

This commit lays the foundation for having language runtimes help in figuring out byte sizes, and having ClangASTType ask for runtime help
No feature change as no runtime actually implements the logic, and nowhere is an ExecutionContext passed in yet

llvm-svn: 227274

26 files changed:
lldb/include/lldb/Symbol/ClangASTType.h
lldb/include/lldb/Target/LanguageRuntime.h
lldb/include/lldb/Utility/ProcessStructReader.h
lldb/source/API/SBType.cpp
lldb/source/Commands/CommandObjectMemory.cpp
lldb/source/Core/Value.cpp
lldb/source/Core/ValueObject.cpp
lldb/source/Core/ValueObjectConstResult.cpp
lldb/source/Core/ValueObjectMemory.cpp
lldb/source/Core/ValueObjectVariable.cpp
lldb/source/DataFormatters/CXXFormatterFunctions.cpp
lldb/source/DataFormatters/LibCxx.cpp
lldb/source/DataFormatters/LibCxxInitializerList.cpp
lldb/source/DataFormatters/LibCxxVector.cpp
lldb/source/Expression/IRForTarget.cpp
lldb/source/Expression/Materializer.cpp
lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARF.cpp
lldb/source/Symbol/ClangASTContext.cpp
lldb/source/Symbol/ClangASTType.cpp
lldb/source/Symbol/Type.cpp

index ef23a8b..4011ff9 100644 (file)
@@ -347,10 +347,10 @@ public:
     //----------------------------------------------------------------------
 
     uint64_t
-    GetByteSize () const;
+    GetByteSize (ExecutionContext *exe_ctx) const;
 
     uint64_t
-    GetBitSize () const;
+    GetBitSize (ExecutionContext *exe_ctx) const;
 
     lldb::Encoding
     GetEncoding (uint64_t &count) const;
index 0aaa67c..d5ed819 100644 (file)
@@ -102,6 +102,13 @@ public:
     
     virtual lldb::SearchFilterSP
     CreateExceptionSearchFilter ();
+    
+    virtual bool
+    GetTypeBitSize (const ClangASTType& clang_type,
+                    uint64_t &size)
+    {
+        return false;
+    }
 
 protected:
     //------------------------------------------------------------------
index 7b05d93..d053b70 100644 (file)
@@ -59,7 +59,7 @@ namespace lldb_private {
                 // no support for bitfields in here (yet)
                 if (is_bitfield)
                     return;
-                auto size = field_type.GetByteSize();
+                auto size = field_type.GetByteSize(nullptr);
                 // no support for things larger than a uint64_t (yet)
                 if (size > 8)
                     return;
@@ -67,7 +67,7 @@ namespace lldb_private {
                 size_t byte_index = static_cast<size_t>(bit_offset / 8);
                 m_fields[const_name] = FieldImpl{field_type, byte_index, static_cast<size_t>(size)};
             }
-            size_t total_size = struct_type.GetByteSize();
+            size_t total_size = struct_type.GetByteSize(nullptr);
             lldb::DataBufferSP buffer_sp(new DataBufferHeap(total_size,0));
             Error error;
             process->ReadMemoryFromInferior(base_addr,
index 8a0f5d8..1f25380 100644 (file)
@@ -143,7 +143,7 @@ SBType::GetByteSize()
     if (!IsValid())
         return 0;
     
-    return m_opaque_sp->GetClangASTType(false).GetByteSize();
+    return m_opaque_sp->GetClangASTType(false).GetByteSize(nullptr);
     
 }
 
index 569d13a..ed650a1 100644 (file)
@@ -567,7 +567,7 @@ protected:
                 --pointer_count;
             }
 
-            m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize();
+            m_format_options.GetByteSizeValue() = clang_ast_type.GetByteSize(nullptr);
             
             if (m_format_options.GetByteSizeValue() == 0)
             {
@@ -690,7 +690,7 @@ protected:
             if (m_format_options.GetFormatValue().OptionWasSet() == false)
                 m_format_options.GetFormatValue().SetCurrentValue(eFormatDefault);
 
-            bytes_read = clang_ast_type.GetByteSize() * m_format_options.GetCountValue().GetCurrentValue();
+            bytes_read = clang_ast_type.GetByteSize(nullptr) * m_format_options.GetCountValue().GetCurrentValue();
         }
         else if (m_format_options.GetFormatValue().GetCurrentValue() != eFormatCString)
         {
@@ -1114,7 +1114,7 @@ protected:
           if (process->GetTarget().EvaluateExpression(m_memory_options.m_expr.GetStringValue(), frame, result_sp) && result_sp.get())
           {
               uint64_t value = result_sp->GetValueAsUnsigned(0);
-              switch (result_sp->GetClangType().GetByteSize())
+              switch (result_sp->GetClangType().GetByteSize(nullptr))
               {
                   case 1: {
                       uint8_t byte = (uint8_t)value;
index db33fce..a416d07 100644 (file)
@@ -277,7 +277,7 @@ Value::GetValueByteSize (Error *error_ptr)
         {
             const ClangASTType &ast_type = GetClangType();
             if (ast_type.IsValid())
-                byte_size = ast_type.GetByteSize();
+                byte_size = ast_type.GetByteSize(nullptr);
         }
         break;
     }
@@ -434,7 +434,7 @@ Value::GetValueAsData (ExecutionContext *exe_ctx,
                 lldb::Encoding type_encoding = ast_type.GetEncoding(type_encoding_count);
                 
                 if (type_encoding == eEncodingUint || type_encoding == eEncodingSint)
-                    limit_byte_size = ast_type.GetByteSize();
+                    limit_byte_size = ast_type.GetByteSize(nullptr);
             }
             
             if (m_value.GetData (data, limit_byte_size))
index 3937424..99b38dd 100644 (file)
@@ -971,7 +971,7 @@ ValueObject::GetPointeeData (DataExtractor& data,
     if (item_count == 0)
         return 0;
     
-    const uint64_t item_type_size = pointee_or_element_clang_type.GetByteSize();
+    const uint64_t item_type_size = pointee_or_element_clang_type.GetByteSize(nullptr);
     const uint64_t bytes = item_count * item_type_size;
     const uint64_t offset = item_idx * item_type_size;
     
@@ -1047,7 +1047,7 @@ ValueObject::GetPointeeData (DataExtractor& data,
                 break;
             case eAddressTypeHost:
                 {
-                    const uint64_t max_bytes = GetClangType().GetByteSize();
+                    const uint64_t max_bytes = GetClangType().GetByteSize(nullptr);
                     if (max_bytes > offset)
                     {
                         size_t bytes_read = std::min<uint64_t>(max_bytes - offset, bytes);
@@ -2225,7 +2225,7 @@ ValueObject::GetSyntheticChildAtOffset(uint32_t offset, const ClangASTType& type
     ValueObjectChild *synthetic_child = new ValueObjectChild(*this,
                                                              type,
                                                              name_const_str,
-                                                             type.GetByteSize(),
+                                                             type.GetByteSize(nullptr),
                                                              offset,
                                                              0,
                                                              0,
@@ -2266,7 +2266,7 @@ ValueObject::GetSyntheticBase (uint32_t offset, const ClangASTType& type, bool c
     ValueObjectChild *synthetic_child = new ValueObjectChild(*this,
                                                              type,
                                                              name_const_str,
-                                                             type.GetByteSize(),
+                                                             type.GetByteSize(nullptr),
                                                              offset,
                                                              0,
                                                              0,
index fc870d7..cbeb2ab 100644 (file)
@@ -257,7 +257,7 @@ uint64_t
 ValueObjectConstResult::GetByteSize()
 {
     if (m_byte_size == 0)
-        m_byte_size = GetClangType().GetByteSize();
+        m_byte_size = GetClangType().GetByteSize(nullptr);
     return m_byte_size;
 }
 
index 5fbe87b..9f19531 100644 (file)
@@ -169,7 +169,7 @@ ValueObjectMemory::GetByteSize()
 {
     if (m_type_sp)
         return m_type_sp->GetByteSize();
-    return m_clang_type.GetByteSize ();
+    return m_clang_type.GetByteSize (nullptr);
 }
 
 lldb::ValueType
index ab74a50..e4fd212 100644 (file)
@@ -110,7 +110,7 @@ ValueObjectVariable::GetByteSize()
     if (!type.IsValid())
         return 0;
     
-    return type.GetByteSize();
+    return type.GetByteSize(nullptr);
 }
 
 lldb::ValueType
index 04cdadf..5aa8289 100644 (file)
@@ -317,7 +317,7 @@ lldb_private::formatters::WCharStringSummaryProvider (ValueObject& valobj, Strea
         return false;
 
     ClangASTType wchar_clang_type = ClangASTContext::GetBasicType(ast, lldb::eBasicTypeWChar);
-    const uint32_t wchar_size = wchar_clang_type.GetBitSize();
+    const uint32_t wchar_size = wchar_clang_type.GetBitSize(nullptr);
 
     ReadStringAndDumpToStreamOptions options(valobj);
     options.SetLocation(data_addr);
index 26bbcf9..33b8532 100644 (file)
@@ -139,7 +139,7 @@ lldb_private::formatters::LibcxxVectorBoolSyntheticFrontEnd::GetChildAtIndex (si
             return ValueObjectSP();
     }
     bool bit_set = ((byte & mask) != 0);
-    DataBufferSP buffer_sp(new DataBufferHeap(m_bool_type.GetByteSize(),0));
+    DataBufferSP buffer_sp(new DataBufferHeap(m_bool_type.GetByteSize(nullptr),0));
     if (bit_set && buffer_sp && buffer_sp->GetBytes())
         *(buffer_sp->GetBytes()) = 1; // regardless of endianness, anything non-zero is true
     StreamString name; name.Printf("[%" PRIu64 "]", (uint64_t)idx);
index e76b0be..91f1f90 100644 (file)
@@ -107,7 +107,7 @@ lldb_private::formatters::LibcxxInitializerListSyntheticFrontEnd::Update()
     if (kind != lldb::eTemplateArgumentKindType || false == m_element_type.IsValid())
         return false;
     
-    m_element_size = m_element_type.GetByteSize();
+    m_element_size = m_element_type.GetByteSize(nullptr);
     
     if (m_element_size > 0)
         m_start = m_backend.GetChildMemberWithName(g___begin_,true).get(); // store raw pointers or end up with a circular dependency
index 26c62af..d0e6be4 100644 (file)
@@ -115,7 +115,7 @@ lldb_private::formatters::LibcxxStdVectorSyntheticFrontEnd::Update()
     if (!data_type_finder_sp)
         return false;
     m_element_type = data_type_finder_sp->GetClangType().GetPointeeType();
-    m_element_size = m_element_type.GetByteSize();
+    m_element_size = m_element_type.GetByteSize(nullptr);
     
     if (m_element_size > 0)
     {
index 8e75c32..42390b3 100644 (file)
@@ -590,7 +590,7 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function)
                                                      &result_decl->getASTContext());
     }
 
-    if (m_result_type.GetBitSize() == 0)
+    if (m_result_type.GetBitSize(nullptr) == 0)
     {
         lldb_private::StreamString type_desc_stream;
         m_result_type.DumpTypeDescription(&type_desc_stream);
@@ -617,7 +617,7 @@ IRForTarget::CreateResultVariable (llvm::Function &llvm_function)
     if (log)
         log->Printf("Creating a new result global: \"%s\" with size 0x%" PRIx64,
                     m_result_name.GetCString(),
-                    m_result_type.GetByteSize());
+                    m_result_type.GetByteSize(nullptr));
 
     // Construct a new result global and set up its metadata
 
@@ -1518,7 +1518,7 @@ IRForTarget::MaybeHandleVariable (Value *llvm_value_ptr)
             value_type = global_variable->getType();
         }
 
-        const uint64_t value_size = clang_type.GetByteSize();
+        const uint64_t value_size = clang_type.GetByteSize(nullptr);
         lldb::offset_t value_alignment = (clang_type.GetTypeBitAlign() + 7ull) / 8ull;
 
         if (log)
index b119216..f1f2f99 100644 (file)
@@ -49,7 +49,7 @@ Materializer::AddStructMember (Entity &entity)
 void
 Materializer::Entity::SetSizeAndAlignmentFromType (ClangASTType &type)
 {
-    m_size = type.GetByteSize();
+    m_size = type.GetByteSize(nullptr);
     
     uint32_t bit_alignment = type.GetTypeBitAlign();
     
@@ -780,7 +780,7 @@ public:
             
             const lldb::addr_t load_addr = process_address + m_offset;
 
-            size_t byte_size = m_type.GetByteSize();
+            size_t byte_size = m_type.GetByteSize(nullptr);
             size_t bit_align = m_type.GetTypeBitAlign();
             size_t byte_align = (bit_align + 7) / 8;
             
index 5073b13..42acba2 100644 (file)
@@ -334,11 +334,11 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread,
             size_t bit_width = 0;
             if (clang_type.IsIntegerType (is_signed))
             {
-                bit_width = clang_type.GetBitSize();
+                bit_width = clang_type.GetBitSize(nullptr);
             }
             else if (clang_type.IsPointerOrReferenceType ())
             {
-                bit_width = clang_type.GetBitSize();
+                bit_width = clang_type.GetBitSize(nullptr);
             }
             else
             {
@@ -437,7 +437,7 @@ ABIMacOSX_arm::GetReturnValueObjectImpl (Thread &thread,
     const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0);
     if (clang_type.IsIntegerType (is_signed))
     {
-        size_t bit_width = clang_type.GetBitSize();
+        size_t bit_width = clang_type.GetBitSize(nullptr);
         
         switch (bit_width)
         {
index 465257d..c2ba165 100644 (file)
@@ -322,11 +322,11 @@ ABIMacOSX_arm64::GetArgumentValues (Thread &thread, ValueList &values) const
             size_t bit_width = 0;
             if (value_type.IsIntegerType (is_signed))
             {
-                bit_width = value_type.GetBitSize();
+                bit_width = value_type.GetBitSize(nullptr);
             }
             else if (value_type.IsPointerOrReferenceType ())
             {
-                bit_width = value_type.GetBitSize();
+                bit_width = value_type.GetBitSize(nullptr);
             }
             else
             {
@@ -709,7 +709,7 @@ LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx,
                                       uint32_t &NSRN,       // NSRN (see ABI documentation)
                                       DataExtractor &data)
 {
-    const size_t byte_size = value_type.GetByteSize();
+    const size_t byte_size = value_type.GetByteSize(nullptr);
     
     if (byte_size == 0)
         return false;
@@ -728,7 +728,7 @@ LoadValueFromConsecutiveGPRRegisters (ExecutionContext &exe_ctx,
         {
             if (!base_type)
                 return false;
-            const size_t base_byte_size = base_type.GetByteSize();
+            const size_t base_byte_size = base_type.GetByteSize(nullptr);
             printf ("ClangASTContext::IsHomogeneousAggregate() => base_byte_size = %" PRIu64 "\n", (uint64_t) base_byte_size);
             uint32_t data_offset = 0;
 
@@ -871,7 +871,7 @@ ABIMacOSX_arm64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_
     if (!reg_ctx)
         return return_valobj_sp;
     
-    const size_t byte_size = return_clang_type.GetByteSize();
+    const size_t byte_size = return_clang_type.GetByteSize(nullptr);
 
     const uint32_t type_flags = return_clang_type.GetTypeInfo (NULL);
     if (type_flags & eTypeIsScalar ||
index ba7f5b3..ee5b929 100644 (file)
@@ -552,7 +552,7 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread,
             if (clang_type.IsIntegerType (is_signed))
             {
                 ReadIntegerArgument(value->GetScalar(),
-                                    clang_type.GetBitSize(),
+                                    clang_type.GetBitSize(nullptr),
                                     is_signed,
                                     thread.GetProcess().get(), 
                                     current_stack_argument);
@@ -560,7 +560,7 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread,
             else if (clang_type.IsPointerType())
             {
                 ReadIntegerArgument(value->GetScalar(),
-                                    clang_type.GetBitSize(),
+                                    clang_type.GetBitSize(nullptr),
                                     false,
                                     thread.GetProcess().get(),
                                     current_stack_argument);
@@ -672,7 +672,7 @@ ABIMacOSX_i386::GetReturnValueObjectImpl (Thread &thread,
             
     if (clang_type.IsIntegerType (is_signed))
     {
-        size_t bit_width = clang_type.GetBitSize();
+        size_t bit_width = clang_type.GetBitSize(nullptr);
         
         unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
         unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB];
index adb3313..f53ed92 100644 (file)
@@ -444,7 +444,7 @@ ABISysV_ppc::GetArgumentValues (Thread &thread,
         if (clang_type.IsIntegerType (is_signed))
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(),
+                                clang_type.GetBitSize(nullptr),
                                 is_signed,
                                 thread,
                                 argument_register_ids,
@@ -454,7 +454,7 @@ ABISysV_ppc::GetArgumentValues (Thread &thread,
         else if (clang_type.IsPointerType ())
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(),
+                                clang_type.GetBitSize(nullptr),
                                 false,
                                 thread,
                                 argument_register_ids,
@@ -524,7 +524,7 @@ ABISysV_ppc::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObjec
             error.SetErrorString ("We don't support returning complex values at present");
         else
         {
-            size_t bit_width = clang_type.GetBitSize();
+            size_t bit_width = clang_type.GetBitSize(nullptr);
             if (bit_width <= 64)
             {
                 DataExtractor data;
@@ -588,7 +588,7 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
         {
             // Extract the register context so we can read arguments from registers
 
-            const size_t byte_size = return_clang_type.GetByteSize();
+            const size_t byte_size = return_clang_type.GetByteSize(nullptr);
             uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r3", 0), 0);
             const bool is_signed = (type_flags & eTypeIsSigned) != 0;
             switch (byte_size)
@@ -637,7 +637,7 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
             }
             else
             {
-                const size_t byte_size = return_clang_type.GetByteSize();
+                const size_t byte_size = return_clang_type.GetByteSize(nullptr);
                 if (byte_size <= sizeof(long double))
                 {
                     const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
@@ -681,7 +681,7 @@ ABISysV_ppc::GetReturnValueObjectSimple (Thread &thread,
     }
     else if (type_flags & eTypeIsVector)
     {
-        const size_t byte_size = return_clang_type.GetByteSize();
+        const size_t byte_size = return_clang_type.GetByteSize(nullptr);
         if (byte_size > 0)
         {
 
@@ -742,7 +742,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
     if (!reg_ctx_sp)
         return return_valobj_sp;
 
-    const size_t bit_width = return_clang_type.GetBitSize();
+    const size_t bit_width = return_clang_type.GetBitSize(nullptr);
     if (return_clang_type.IsAggregateType())
     {
         Target *target = exe_ctx.GetTargetPtr();
@@ -784,7 +784,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_clan
                 uint32_t count;
 
                 ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
-                const size_t field_bit_width = field_clang_type.GetBitSize();
+                const size_t field_bit_width = field_clang_type.GetBitSize(nullptr);
 
                 // If there are any unaligned fields, this is stored in memory.
                 if (field_bit_offset % field_bit_width != 0)
index 46f1e10..8a942b5 100644 (file)
@@ -444,7 +444,7 @@ ABISysV_ppc64::GetArgumentValues (Thread &thread,
         if (clang_type.IsIntegerType (is_signed))
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(),
+                                clang_type.GetBitSize(nullptr),
                                 is_signed,
                                 thread,
                                 argument_register_ids,
@@ -454,7 +454,7 @@ ABISysV_ppc64::GetArgumentValues (Thread &thread,
         else if (clang_type.IsPointerType ())
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(),
+                                clang_type.GetBitSize(nullptr),
                                 false,
                                 thread,
                                 argument_register_ids,
@@ -524,7 +524,7 @@ ABISysV_ppc64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueObj
             error.SetErrorString ("We don't support returning complex values at present");
         else
         {
-            size_t bit_width = clang_type.GetBitSize();
+            size_t bit_width = clang_type.GetBitSize(nullptr);
             if (bit_width <= 64)
             {
                 DataExtractor data;
@@ -588,7 +588,7 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
         {
             // Extract the register context so we can read arguments from registers
 
-            const size_t byte_size = return_clang_type.GetByteSize();
+            const size_t byte_size = return_clang_type.GetByteSize(nullptr);
             uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("r3", 0), 0);
             const bool is_signed = (type_flags & eTypeIsSigned) != 0;
             switch (byte_size)
@@ -637,7 +637,7 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
             }
             else
             {
-                const size_t byte_size = return_clang_type.GetByteSize();
+                const size_t byte_size = return_clang_type.GetByteSize(nullptr);
                 if (byte_size <= sizeof(long double))
                 {
                     const RegisterInfo *f1_info = reg_ctx->GetRegisterInfoByName("f1", 0);
@@ -681,7 +681,7 @@ ABISysV_ppc64::GetReturnValueObjectSimple (Thread &thread,
     }
     else if (type_flags & eTypeIsVector)
     {
-        const size_t byte_size = return_clang_type.GetByteSize();
+        const size_t byte_size = return_clang_type.GetByteSize(nullptr);
         if (byte_size > 0)
         {
 
@@ -742,7 +742,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
     if (!reg_ctx_sp)
         return return_valobj_sp;
 
-    const size_t bit_width = return_clang_type.GetBitSize();
+    const size_t bit_width = return_clang_type.GetBitSize(nullptr);
     if (return_clang_type.IsAggregateType())
     {
         Target *target = exe_ctx.GetTargetPtr();
@@ -784,7 +784,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_cl
                 uint32_t count;
 
                 ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
-                const size_t field_bit_width = field_clang_type.GetBitSize();
+                const size_t field_bit_width = field_clang_type.GetBitSize(nullptr);
 
                 // If there are any unaligned fields, this is stored in memory.
                 if (field_bit_offset % field_bit_width != 0)
index 4acaa76..71d99c8 100644 (file)
@@ -510,7 +510,7 @@ ABISysV_x86_64::GetArgumentValues (Thread &thread,
         if (clang_type.IsIntegerType (is_signed))
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(),
+                                clang_type.GetBitSize(nullptr),
                                 is_signed,
                                 thread, 
                                 argument_register_ids, 
@@ -520,7 +520,7 @@ ABISysV_x86_64::GetArgumentValues (Thread &thread,
         else if (clang_type.IsPointerType ())
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(),
+                                clang_type.GetBitSize(nullptr),
                                 false,
                                 thread,
                                 argument_register_ids, 
@@ -590,7 +590,7 @@ ABISysV_x86_64::SetReturnValueObject(lldb::StackFrameSP &frame_sp, lldb::ValueOb
             error.SetErrorString ("We don't support returning complex values at present");
         else
         {
-            size_t bit_width = clang_type.GetBitSize();
+            size_t bit_width = clang_type.GetBitSize(nullptr);
             if (bit_width <= 64)
             {
                 const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
@@ -658,7 +658,7 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
         {
             // Extract the register context so we can read arguments from registers
             
-            const size_t byte_size = return_clang_type.GetByteSize();
+            const size_t byte_size = return_clang_type.GetByteSize(nullptr);
             uint64_t raw_value = thread.GetRegisterContext()->ReadRegisterAsUnsigned(reg_ctx->GetRegisterInfoByName("rax", 0), 0);
             const bool is_signed = (type_flags & eTypeIsSigned) != 0;
             switch (byte_size)
@@ -707,7 +707,7 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
             }
             else
             {
-                const size_t byte_size = return_clang_type.GetByteSize();
+                const size_t byte_size = return_clang_type.GetByteSize(nullptr);
                 if (byte_size <= sizeof(long double))
                 {
                     const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
@@ -755,7 +755,7 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread,
     }
     else if (type_flags & eTypeIsVector)
     {
-        const size_t byte_size = return_clang_type.GetByteSize();
+        const size_t byte_size = return_clang_type.GetByteSize(nullptr);
         if (byte_size > 0)
         {
 
@@ -821,7 +821,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
     if (!reg_ctx_sp)
         return return_valobj_sp;
         
-    const size_t bit_width = return_clang_type.GetBitSize();
+    const size_t bit_width = return_clang_type.GetBitSize(nullptr);
     if (return_clang_type.IsAggregateType())
     {
         Target *target = exe_ctx.GetTargetPtr();
@@ -869,7 +869,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &return_c
                 uint32_t count;
                 
                 ClangASTType field_clang_type = return_clang_type.GetFieldAtIndex (idx, name, &field_bit_offset, NULL, NULL);
-                const size_t field_bit_width = field_clang_type.GetBitSize();
+                const size_t field_bit_width = field_clang_type.GetBitSize(nullptr);
 
                 // If there are any unaligned fields, this is stored in memory.
                 if (field_bit_offset % field_bit_width != 0)
index e5fa755..e2aefd1 100644 (file)
@@ -6984,7 +6984,7 @@ SymbolFileDWARF::ParseType (const SymbolContext& sc, DWARFCompileUnit* dwarf_cu,
 
                         clang_type = pointee_clang_type.CreateMemberPointerType(class_clang_type);
 
-                        byte_size = clang_type.GetByteSize();
+                        byte_size = clang_type.GetByteSize(nullptr);
 
                         type_sp.reset( new Type (MakeUserID(die->GetOffset()), 
                                                  this, 
index d851ae7..73f6920 100644 (file)
@@ -708,7 +708,7 @@ uint32_t
 ClangASTContext::GetPointerByteSize ()
 {
     if (m_pointer_byte_size == 0)
-        m_pointer_byte_size = GetBasicType(lldb::eBasicTypeVoid).GetPointerType().GetByteSize();
+        m_pointer_byte_size = GetBasicType(lldb::eBasicTypeVoid).GetPointerType().GetByteSize(nullptr);
     return m_pointer_byte_size;
 }
 
index 8b672fa..4ffeadf 100644 (file)
@@ -1663,7 +1663,7 @@ ClangASTType::GetArrayElementType (uint64_t *stride) const
         
         // TODO: the real stride will be >= this value.. find the real one!
         if (stride)
-            *stride = element_type.GetByteSize();
+            *stride = element_type.GetByteSize(nullptr);
         
         return element_type;
         
@@ -2062,28 +2062,45 @@ ClangASTType::GetBasicTypeFromAST (lldb::BasicType basic_type) const
 //----------------------------------------------------------------------
 
 uint64_t
-ClangASTType::GetBitSize () const
+ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const
 {
     if (GetCompleteType ())
     {
         clang::QualType qual_type(GetCanonicalQualType());
-        const uint32_t bit_size = m_ast->getTypeSize (qual_type);
-        if (bit_size == 0)
+        switch (qual_type->getTypeClass())
         {
-            if (qual_type->isIncompleteArrayType())
-                return m_ast->getTypeSize (qual_type->getArrayElementTypeNoTypeQual()->getCanonicalTypeUnqualified());
+            case clang::Type::ObjCInterface:
+            case clang::Type::ObjCObject:
+                if (exe_ctx && exe_ctx->GetProcessPtr())
+                {
+                    ObjCLanguageRuntime *objc_runtime = exe_ctx->GetProcessPtr()->GetObjCLanguageRuntime();
+                    if (objc_runtime)
+                    {
+                        uint64_t bit_size = 0;
+                        if (objc_runtime->GetTypeBitSize(*this, bit_size))
+                            return bit_size;
+                    }
+                }
+                // fallthrough
+            default:
+                const uint32_t bit_size = m_ast->getTypeSize (qual_type);
+                if (bit_size == 0)
+                {
+                    if (qual_type->isIncompleteArrayType())
+                        return m_ast->getTypeSize (qual_type->getArrayElementTypeNoTypeQual()->getCanonicalTypeUnqualified());
+                }
+                if (qual_type->isObjCObjectOrInterfaceType())
+                    return bit_size + m_ast->getTypeSize(m_ast->ObjCBuiltinClassTy);
+                return bit_size;
         }
-        if (qual_type->isObjCObjectOrInterfaceType())
-            return bit_size + m_ast->getTypeSize(m_ast->ObjCBuiltinClassTy);
-        return bit_size;
     }
     return 0;
 }
 
 uint64_t
-ClangASTType::GetByteSize () const
+ClangASTType::GetByteSize (ExecutionContext *exe_ctx) const
 {
-    return (GetBitSize () + 7) / 8;
+    return (GetBitSize (exe_ctx) + 7) / 8;
 }
 
 size_t
@@ -3416,7 +3433,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
                             child_byte_offset = bit_offset/8;
                             ClangASTType base_class_clang_type(m_ast, base_class->getType());
                             child_name = base_class_clang_type.GetTypeName().AsCString("");
-                            uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize();
+                            uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize(nullptr);
                             
                             // Base classes bit sizes should be a multiple of 8 bits in size
                             assert (base_class_clang_type_bit_size % 8 == 0);
@@ -3444,7 +3461,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
                         // alignment (field_type_info.second) from the AST context.
                         ClangASTType field_clang_type (m_ast, field->getType());
                         assert(field_idx < record_layout.getFieldCount());
-                        child_byte_size = field_clang_type.GetByteSize();
+                        child_byte_size = field_clang_type.GetByteSize(nullptr);
                         
                         // Figure out the field offset within the current struct/union/class type
                         bit_offset = record_layout.getFieldOffset (field_idx);
@@ -3609,7 +3626,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
                     // We have a pointer to an simple type
                     if (idx == 0 && pointee_clang_type.GetCompleteType())
                     {
-                        child_byte_size = pointee_clang_type.GetByteSize();
+                        child_byte_size = pointee_clang_type.GetByteSize(nullptr);
                         child_byte_offset = 0;
                         return pointee_clang_type;
                     }
@@ -3630,7 +3647,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
                         char element_name[64];
                         ::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
                         child_name.assign(element_name);
-                        child_byte_size = element_type.GetByteSize();
+                        child_byte_size = element_type.GetByteSize(nullptr);
                         child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
                         return element_type;
                     }
@@ -3651,7 +3668,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
                         char element_name[64];
                         ::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
                         child_name.assign(element_name);
-                        child_byte_size = element_type.GetByteSize();
+                        child_byte_size = element_type.GetByteSize(nullptr);
                         child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
                         return element_type;
                     }
@@ -3701,7 +3718,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
                     // We have a pointer to an simple type
                     if (idx == 0)
                     {
-                        child_byte_size = pointee_clang_type.GetByteSize();
+                        child_byte_size = pointee_clang_type.GetByteSize(nullptr);
                         child_byte_offset = 0;
                         return pointee_clang_type;
                     }
@@ -3745,7 +3762,7 @@ ClangASTType::GetChildClangTypeAtIndex (ExecutionContext *exe_ctx,
                     // We have a pointer to an simple type
                     if (idx == 0)
                     {
-                        child_byte_size = pointee_clang_type.GetByteSize();
+                        child_byte_size = pointee_clang_type.GetByteSize(nullptr);
                         child_byte_offset = 0;
                         return pointee_clang_type;
                     }
@@ -6643,7 +6660,7 @@ ClangASTType::GetValueAsScalar (const lldb_private::DataExtractor &data,
         if (encoding == lldb::eEncodingInvalid || count != 1)
             return false;
 
-        const uint64_t byte_size = GetByteSize();
+        const uint64_t byte_size = GetByteSize(nullptr);
         lldb::offset_t offset = data_byte_offset;
         switch (encoding)
         {
@@ -6771,7 +6788,7 @@ ClangASTType::SetValueFromScalar (const Scalar &value, Stream &strm)
         if (encoding == lldb::eEncodingInvalid || count != 1)
             return false;
 
-        const uint64_t bit_width = GetBitSize();
+        const uint64_t bit_width = GetBitSize(nullptr);
         // This function doesn't currently handle non-byte aligned assignments
         if ((bit_width % 8) != 0)
             return false;
@@ -6851,7 +6868,7 @@ ClangASTType::ReadFromMemory (lldb_private::ExecutionContext *exe_ctx,
     if (!GetCompleteType())
         return false;
     
-    const uint64_t byte_size = GetByteSize();
+    const uint64_t byte_size = GetByteSize(nullptr);
     if (data.GetByteSize() < byte_size)
     {
         lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
@@ -6901,7 +6918,7 @@ ClangASTType::WriteToMemory (lldb_private::ExecutionContext *exe_ctx,
     if (!GetCompleteType())
         return false;
 
-    const uint64_t byte_size = GetByteSize();
+    const uint64_t byte_size = GetByteSize(nullptr);
 
     if (byte_size > 0)
     {
index 210cd50..6e67f46 100644 (file)
@@ -336,7 +336,7 @@ Type::GetByteSize()
                 if (encoding_type)
                     m_byte_size = encoding_type->GetByteSize();
                 if (m_byte_size == 0)
-                    m_byte_size = GetClangLayoutType().GetByteSize();
+                    m_byte_size = GetClangLayoutType().GetByteSize(nullptr);
             }
             break;