[Lldb-commits] [lldb] r228892 - Make a more complete fix for always supplying an execution context when getting byte sizes from types.

Greg Clayton gclayton at apple.com
Wed Feb 11 16:34:26 PST 2015


Author: gclayton
Date: Wed Feb 11 18:34:25 2015
New Revision: 228892

URL: http://llvm.org/viewvc/llvm-project?rev=228892&view=rev
Log:
Make a more complete fix for always supplying an execution context when getting byte sizes from types.

There was a test in the test suite that was triggering the backtrace logging output that requested that the client pass an execution context. Sometimes we need the process for Objective C types because our static notion of the type might not align with the reality when being run in a live runtime.

Switched from an "ExecutionContext *" to an "ExecutionContextScope *" for greater ease of use.


Modified:
    lldb/trunk/include/lldb/Expression/IRForTarget.h
    lldb/trunk/include/lldb/Expression/IRMemoryMap.h
    lldb/trunk/include/lldb/Symbol/ClangASTType.h
    lldb/trunk/source/Core/ValueObject.cpp
    lldb/trunk/source/Core/ValueObjectConstResult.cpp
    lldb/trunk/source/Core/ValueObjectVariable.cpp
    lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
    lldb/trunk/source/Expression/IRForTarget.cpp
    lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
    lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
    lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
    lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
    lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
    lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
    lldb/trunk/source/Symbol/ClangASTType.cpp
    lldb/trunk/source/Target/ExecutionContext.cpp

Modified: lldb/trunk/include/lldb/Expression/IRForTarget.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRForTarget.h?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/IRForTarget.h (original)
+++ lldb/trunk/include/lldb/Expression/IRForTarget.h Wed Feb 11 18:34:25 2015
@@ -640,6 +640,9 @@ private:
             return m_stream_string;
         }
         lldb::addr_t Allocate();
+
+        lldb::TargetSP
+        GetTarget();
     private:
         lldb_private::IRExecutionUnit  &m_execution_unit;
         lldb_private::StreamString      m_stream_string;

Modified: lldb/trunk/include/lldb/Expression/IRMemoryMap.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Expression/IRMemoryMap.h?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Expression/IRMemoryMap.h (original)
+++ lldb/trunk/include/lldb/Expression/IRMemoryMap.h Wed Feb 11 18:34:25 2015
@@ -69,14 +69,22 @@ public:
     // This function can return NULL.
     ExecutionContextScope *GetBestExecutionContextScope() const;
 
+    lldb::TargetSP
+    GetTarget ()
+    {
+        return m_target_wp.lock();
+    }
+
 protected:
     // This function should only be used if you know you are using the JIT.
     // Any other cases should use GetBestExecutionContextScope().
-    lldb::ProcessWP GetProcessWP ()
+
+    lldb::ProcessWP &
+    GetProcessWP ()
     {
         return m_process_wp;
     }
-    
+
 private:
     struct Allocation
     {

Modified: lldb/trunk/include/lldb/Symbol/ClangASTType.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Symbol/ClangASTType.h?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Symbol/ClangASTType.h (original)
+++ lldb/trunk/include/lldb/Symbol/ClangASTType.h Wed Feb 11 18:34:25 2015
@@ -351,10 +351,10 @@ public:
     //----------------------------------------------------------------------
 
     uint64_t
-    GetByteSize (ExecutionContext *exe_ctx) const;
+    GetByteSize (ExecutionContextScope *exe_scope) const;
 
     uint64_t
-    GetBitSize (ExecutionContext *exe_ctx) const;
+    GetBitSize (ExecutionContextScope *exe_scope) const;
 
     lldb::Encoding
     GetEncoding (uint64_t &count) const;

Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Wed Feb 11 18:34:25 2015
@@ -973,7 +973,7 @@ ValueObject::GetPointeeData (DataExtract
     
     ExecutionContext exe_ctx (GetExecutionContextRef());
     
-    const uint64_t item_type_size = pointee_or_element_clang_type.GetByteSize(&exe_ctx);
+    const uint64_t item_type_size = pointee_or_element_clang_type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
     const uint64_t bytes = item_count * item_type_size;
     const uint64_t offset = item_idx * item_type_size;
     
@@ -1049,7 +1049,7 @@ ValueObject::GetPointeeData (DataExtract
                 break;
             case eAddressTypeHost:
                 {
-                    const uint64_t max_bytes = GetClangType().GetByteSize(&exe_ctx);
+                    const uint64_t max_bytes = GetClangType().GetByteSize(exe_ctx.GetBestExecutionContextScope());
                     if (max_bytes > offset)
                     {
                         size_t bytes_read = std::min<uint64_t>(max_bytes - offset, bytes);
@@ -2244,7 +2244,7 @@ ValueObject::GetSyntheticChildAtOffset(u
     ValueObjectChild *synthetic_child = new ValueObjectChild(*this,
                                                              type,
                                                              name_const_str,
-                                                             type.GetByteSize(&exe_ctx),
+                                                             type.GetByteSize(exe_ctx.GetBestExecutionContextScope()),
                                                              offset,
                                                              0,
                                                              0,
@@ -2287,7 +2287,7 @@ ValueObject::GetSyntheticBase (uint32_t
     ValueObjectChild *synthetic_child = new ValueObjectChild(*this,
                                                              type,
                                                              name_const_str,
-                                                             type.GetByteSize(&exe_ctx),
+                                                             type.GetByteSize(exe_ctx.GetBestExecutionContextScope()),
                                                              offset,
                                                              0,
                                                              0,

Modified: lldb/trunk/source/Core/ValueObjectConstResult.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectConstResult.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectConstResult.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectConstResult.cpp Wed Feb 11 18:34:25 2015
@@ -259,7 +259,7 @@ ValueObjectConstResult::GetByteSize()
     ExecutionContext exe_ctx(GetExecutionContextRef());
 
     if (m_byte_size == 0)
-        SetByteSize(GetClangType().GetByteSize(&exe_ctx));
+        SetByteSize(GetClangType().GetByteSize(exe_ctx.GetBestExecutionContextScope()));
     return m_byte_size;
 }
 

Modified: lldb/trunk/source/Core/ValueObjectVariable.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObjectVariable.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObjectVariable.cpp (original)
+++ lldb/trunk/source/Core/ValueObjectVariable.cpp Wed Feb 11 18:34:25 2015
@@ -112,7 +112,7 @@ ValueObjectVariable::GetByteSize()
     if (!type.IsValid())
         return 0;
     
-    return type.GetByteSize(&exe_ctx);
+    return type.GetByteSize(exe_ctx.GetBestExecutionContextScope());
 }
 
 lldb::ValueType

Modified: lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp (original)
+++ lldb/trunk/source/DataFormatters/CXXFormatterFunctions.cpp Wed Feb 11 18:34:25 2015
@@ -317,7 +317,7 @@ lldb_private::formatters::WCharStringSum
         return false;
 
     ClangASTType wchar_clang_type = ClangASTContext::GetBasicType(ast, lldb::eBasicTypeWChar);
-    const uint32_t wchar_size = wchar_clang_type.GetBitSize(nullptr);
+    const uint32_t wchar_size = wchar_clang_type.GetBitSize(nullptr); // Safe to pass NULL for exe_scope here
 
     ReadStringAndDumpToStreamOptions options(valobj);
     options.SetLocation(data_addr);

Modified: lldb/trunk/source/Expression/IRForTarget.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Expression/IRForTarget.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Expression/IRForTarget.cpp (original)
+++ lldb/trunk/source/Expression/IRForTarget.cpp Wed Feb 11 18:34:25 2015
@@ -59,7 +59,8 @@ IRForTarget::FunctionValueCache::~Functi
 {
 }
 
-llvm::Value *IRForTarget::FunctionValueCache::GetValue(llvm::Function *function)
+llvm::Value *
+IRForTarget::FunctionValueCache::GetValue(llvm::Function *function)
 {
     if (!m_values.count(function))
     {
@@ -70,7 +71,8 @@ llvm::Value *IRForTarget::FunctionValueC
     return m_values[function];
 }
 
-lldb::addr_t IRForTarget::StaticDataAllocator::Allocate()
+lldb::addr_t
+IRForTarget::StaticDataAllocator::Allocate()
 {
     lldb_private::Error err;
 
@@ -85,7 +87,14 @@ lldb::addr_t IRForTarget::StaticDataAllo
     return m_allocation;
 }
 
-static llvm::Value *FindEntryInstruction (llvm::Function *function)
+lldb::TargetSP
+IRForTarget::StaticDataAllocator::GetTarget()
+{
+    return m_execution_unit.GetTarget();
+}
+
+static llvm::Value *
+FindEntryInstruction (llvm::Function *function)
 {
     if (function->empty())
         return NULL;
@@ -590,7 +599,10 @@ IRForTarget::CreateResultVariable (llvm:
                                                      &result_decl->getASTContext());
     }
 
-    if (m_result_type.GetBitSize(nullptr) == 0)
+
+    lldb::TargetSP target_sp (m_data_allocator.GetTarget());
+    lldb_private::ExecutionContext exe_ctx (target_sp.get(), true);
+    if (m_result_type.GetBitSize(exe_ctx.GetBestExecutionContextScope()) == 0)
     {
         lldb_private::StreamString type_desc_stream;
         m_result_type.DumpTypeDescription(&type_desc_stream);

Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp Wed Feb 11 18:34:25 2015
@@ -334,11 +334,11 @@ ABIMacOSX_arm::GetArgumentValues (Thread
             size_t bit_width = 0;
             if (clang_type.IsIntegerType (is_signed))
             {
-                bit_width = clang_type.GetBitSize(nullptr);
+                bit_width = clang_type.GetBitSize(&thread);
             }
             else if (clang_type.IsPointerOrReferenceType ())
             {
-                bit_width = clang_type.GetBitSize(nullptr);
+                bit_width = clang_type.GetBitSize(&thread);
             }
             else
             {
@@ -437,7 +437,7 @@ ABIMacOSX_arm::GetReturnValueObjectImpl
     const RegisterInfo *r0_reg_info = reg_ctx->GetRegisterInfoByName("r0", 0);
     if (clang_type.IsIntegerType (is_signed))
     {
-        size_t bit_width = clang_type.GetBitSize(nullptr);
+        size_t bit_width = clang_type.GetBitSize(&thread);
         
         switch (bit_width)
         {

Modified: lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp Wed Feb 11 18:34:25 2015
@@ -322,11 +322,11 @@ ABIMacOSX_arm64::GetArgumentValues (Thre
             size_t bit_width = 0;
             if (value_type.IsIntegerType (is_signed))
             {
-                bit_width = value_type.GetBitSize(nullptr);
+                bit_width = value_type.GetBitSize(&thread);
             }
             else if (value_type.IsPointerOrReferenceType ())
             {
-                bit_width = value_type.GetBitSize(nullptr);
+                bit_width = value_type.GetBitSize(&thread);
             }
             else
             {

Modified: lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp Wed Feb 11 18:34:25 2015
@@ -552,7 +552,7 @@ ABIMacOSX_i386::GetArgumentValues (Threa
             if (clang_type.IsIntegerType (is_signed))
             {
                 ReadIntegerArgument(value->GetScalar(),
-                                    clang_type.GetBitSize(nullptr),
+                                    clang_type.GetBitSize(&thread),
                                     is_signed,
                                     thread.GetProcess().get(), 
                                     current_stack_argument);
@@ -560,7 +560,7 @@ ABIMacOSX_i386::GetArgumentValues (Threa
             else if (clang_type.IsPointerType())
             {
                 ReadIntegerArgument(value->GetScalar(),
-                                    clang_type.GetBitSize(nullptr),
+                                    clang_type.GetBitSize(&thread),
                                     false,
                                     thread.GetProcess().get(),
                                     current_stack_argument);
@@ -672,7 +672,7 @@ ABIMacOSX_i386::GetReturnValueObjectImpl
             
     if (clang_type.IsIntegerType (is_signed))
     {
-        size_t bit_width = clang_type.GetBitSize(nullptr);
+        size_t bit_width = clang_type.GetBitSize(&thread);
         
         unsigned eax_id = reg_ctx->GetRegisterInfoByName("eax", 0)->kinds[eRegisterKindLLDB];
         unsigned edx_id = reg_ctx->GetRegisterInfoByName("edx", 0)->kinds[eRegisterKindLLDB];

Modified: lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp Wed Feb 11 18:34:25 2015
@@ -390,7 +390,7 @@ static bool ReadIntegerArgument(Scalar
 
 bool
 ABISysV_ppc::GetArgumentValues (Thread &thread,
-                                   ValueList &values) const
+                                ValueList &values) const
 {
     unsigned int num_values = values.GetSize();
     unsigned int value_index;
@@ -444,7 +444,7 @@ ABISysV_ppc::GetArgumentValues (Thread &
         if (clang_type.IsIntegerType (is_signed))
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(nullptr),
+                                clang_type.GetBitSize(&thread),
                                 is_signed,
                                 thread,
                                 argument_register_ids,
@@ -454,7 +454,7 @@ ABISysV_ppc::GetArgumentValues (Thread &
         else if (clang_type.IsPointerType ())
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(nullptr),
+                                clang_type.GetBitSize(&thread),
                                 false,
                                 thread,
                                 argument_register_ids,
@@ -524,7 +524,7 @@ ABISysV_ppc::SetReturnValueObject(lldb::
             error.SetErrorString ("We don't support returning complex values at present");
         else
         {
-            size_t bit_width = clang_type.GetBitSize(nullptr);
+            size_t bit_width = clang_type.GetBitSize(frame_sp.get());
             if (bit_width <= 64)
             {
                 DataExtractor data;
@@ -740,7 +740,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (T
     if (!reg_ctx_sp)
         return return_valobj_sp;
 
-    const size_t bit_width = return_clang_type.GetBitSize(nullptr);
+    const size_t bit_width = return_clang_type.GetBitSize(&thread);
     if (return_clang_type.IsAggregateType())
     {
         Target *target = exe_ctx.GetTargetPtr();
@@ -782,7 +782,7 @@ ABISysV_ppc::GetReturnValueObjectImpl (T
                 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(nullptr);
+                const size_t field_bit_width = field_clang_type.GetBitSize(&thread);
 
                 // If there are any unaligned fields, this is stored in memory.
                 if (field_bit_offset % field_bit_width != 0)

Modified: lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp Wed Feb 11 18:34:25 2015
@@ -390,7 +390,7 @@ static bool ReadIntegerArgument(Scalar
 
 bool
 ABISysV_ppc64::GetArgumentValues (Thread &thread,
-                                   ValueList &values) const
+                                  ValueList &values) const
 {
     unsigned int num_values = values.GetSize();
     unsigned int value_index;
@@ -444,7 +444,7 @@ ABISysV_ppc64::GetArgumentValues (Thread
         if (clang_type.IsIntegerType (is_signed))
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(nullptr),
+                                clang_type.GetBitSize(&thread),
                                 is_signed,
                                 thread,
                                 argument_register_ids,
@@ -454,7 +454,7 @@ ABISysV_ppc64::GetArgumentValues (Thread
         else if (clang_type.IsPointerType ())
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(nullptr),
+                                clang_type.GetBitSize(&thread),
                                 false,
                                 thread,
                                 argument_register_ids,
@@ -524,7 +524,7 @@ ABISysV_ppc64::SetReturnValueObject(lldb
             error.SetErrorString ("We don't support returning complex values at present");
         else
         {
-            size_t bit_width = clang_type.GetBitSize(nullptr);
+            size_t bit_width = clang_type.GetBitSize(frame_sp.get());
             if (bit_width <= 64)
             {
                 DataExtractor data;
@@ -740,7 +740,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl
     if (!reg_ctx_sp)
         return return_valobj_sp;
 
-    const size_t bit_width = return_clang_type.GetBitSize(nullptr);
+    const size_t bit_width = return_clang_type.GetBitSize(&thread);
     if (return_clang_type.IsAggregateType())
     {
         Target *target = exe_ctx.GetTargetPtr();
@@ -782,7 +782,7 @@ ABISysV_ppc64::GetReturnValueObjectImpl
                 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(nullptr);
+                const size_t field_bit_width = field_clang_type.GetBitSize(&thread);
 
                 // If there are any unaligned fields, this is stored in memory.
                 if (field_bit_offset % field_bit_width != 0)

Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Wed Feb 11 18:34:25 2015
@@ -510,7 +510,7 @@ ABISysV_x86_64::GetArgumentValues (Threa
         if (clang_type.IsIntegerType (is_signed))
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(nullptr),
+                                clang_type.GetBitSize(&thread),
                                 is_signed,
                                 thread, 
                                 argument_register_ids, 
@@ -520,7 +520,7 @@ ABISysV_x86_64::GetArgumentValues (Threa
         else if (clang_type.IsPointerType ())
         {
             ReadIntegerArgument(value->GetScalar(),
-                                clang_type.GetBitSize(nullptr),
+                                clang_type.GetBitSize(&thread),
                                 false,
                                 thread,
                                 argument_register_ids, 
@@ -590,7 +590,7 @@ ABISysV_x86_64::SetReturnValueObject(lld
             error.SetErrorString ("We don't support returning complex values at present");
         else
         {
-            size_t bit_width = clang_type.GetBitSize(nullptr);
+            size_t bit_width = clang_type.GetBitSize(frame_sp.get());
             if (bit_width <= 64)
             {
                 const RegisterInfo *xmm0_info = reg_ctx->GetRegisterInfoByName("xmm0", 0);
@@ -821,7 +821,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl
     if (!reg_ctx_sp)
         return return_valobj_sp;
         
-    const size_t bit_width = return_clang_type.GetBitSize(nullptr);
+    const size_t bit_width = return_clang_type.GetBitSize(&thread);
     if (return_clang_type.IsAggregateType())
     {
         Target *target = exe_ctx.GetTargetPtr();
@@ -869,7 +869,7 @@ ABISysV_x86_64::GetReturnValueObjectImpl
                 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(nullptr);
+                const size_t field_bit_width = field_clang_type.GetBitSize(&thread);
 
                 // If there are any unaligned fields, this is stored in memory.
                 if (field_bit_offset % field_bit_width != 0)

Modified: lldb/trunk/source/Symbol/ClangASTType.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Symbol/ClangASTType.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Symbol/ClangASTType.cpp (original)
+++ lldb/trunk/source/Symbol/ClangASTType.cpp Wed Feb 11 18:34:25 2015
@@ -2093,7 +2093,7 @@ ClangASTType::GetBasicTypeFromAST (lldb:
 //----------------------------------------------------------------------
 
 uint64_t
-ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const
+ClangASTType::GetBitSize (ExecutionContextScope *exe_scope) const
 {
     if (GetCompleteType ())
     {
@@ -2102,9 +2102,12 @@ ClangASTType::GetBitSize (ExecutionConte
         {
             case clang::Type::ObjCInterface:
             case clang::Type::ObjCObject:
-                if (exe_ctx && exe_ctx->GetProcessPtr())
+            {
+                ExecutionContext exe_ctx (exe_scope);
+                Process *process = exe_ctx.GetProcessPtr();
+                if (process)
                 {
-                    ObjCLanguageRuntime *objc_runtime = exe_ctx->GetProcessPtr()->GetObjCLanguageRuntime();
+                    ObjCLanguageRuntime *objc_runtime = process->GetObjCLanguageRuntime();
                     if (objc_runtime)
                     {
                         uint64_t bit_size = 0;
@@ -2121,11 +2124,12 @@ ClangASTType::GetBitSize (ExecutionConte
                         s.Printf("warning: trying to determine the size of type ");
                         DumpTypeDescription(&s);
                         s.Printf("\n without a valid ExecutionContext. this is not reliable. please file a bug against LLDB.\nbacktrace:\n");
-                        Host::Backtrace(s, 10);
+                        Host::Backtrace(s, UINT32_MAX);
                         printf("%s\n", s.GetData());
                         g_printed = true;
                     }
                 }
+            }
                 // fallthrough
             default:
                 const uint32_t bit_size = m_ast->getTypeSize (qual_type);
@@ -2143,9 +2147,9 @@ ClangASTType::GetBitSize (ExecutionConte
 }
 
 uint64_t
-ClangASTType::GetByteSize (ExecutionContext *exe_ctx) const
+ClangASTType::GetByteSize (ExecutionContextScope *exe_scope) const
 {
-    return (GetBitSize (exe_ctx) + 7) / 8;
+    return (GetBitSize (exe_scope) + 7) / 8;
 }
 
 size_t
@@ -3478,7 +3482,7 @@ ClangASTType::GetChildClangTypeAtIndex (
                             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(nullptr);
+                            uint64_t base_class_clang_type_bit_size = base_class_clang_type.GetBitSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
                             
                             // Base classes bit sizes should be a multiple of 8 bits in size
                             assert (base_class_clang_type_bit_size % 8 == 0);
@@ -3506,7 +3510,7 @@ ClangASTType::GetChildClangTypeAtIndex (
                         // 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(exe_ctx);
+                        child_byte_size = field_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
                         
                         // Figure out the field offset within the current struct/union/class type
                         bit_offset = record_layout.getFieldOffset (field_idx);
@@ -3671,7 +3675,7 @@ ClangASTType::GetChildClangTypeAtIndex (
                     // We have a pointer to an simple type
                     if (idx == 0 && pointee_clang_type.GetCompleteType())
                     {
-                        child_byte_size = pointee_clang_type.GetByteSize(exe_ctx);
+                        child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
                         child_byte_offset = 0;
                         return pointee_clang_type;
                     }
@@ -3692,7 +3696,7 @@ ClangASTType::GetChildClangTypeAtIndex (
                         char element_name[64];
                         ::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
                         child_name.assign(element_name);
-                        child_byte_size = element_type.GetByteSize(exe_ctx);
+                        child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
                         child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
                         return element_type;
                     }
@@ -3713,7 +3717,7 @@ ClangASTType::GetChildClangTypeAtIndex (
                         char element_name[64];
                         ::snprintf (element_name, sizeof (element_name), "[%zu]", idx);
                         child_name.assign(element_name);
-                        child_byte_size = element_type.GetByteSize(exe_ctx);
+                        child_byte_size = element_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
                         child_byte_offset = (int32_t)idx * (int32_t)child_byte_size;
                         return element_type;
                     }
@@ -3763,7 +3767,7 @@ ClangASTType::GetChildClangTypeAtIndex (
                     // We have a pointer to an simple type
                     if (idx == 0)
                     {
-                        child_byte_size = pointee_clang_type.GetByteSize(exe_ctx);
+                        child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
                         child_byte_offset = 0;
                         return pointee_clang_type;
                     }
@@ -3807,7 +3811,7 @@ ClangASTType::GetChildClangTypeAtIndex (
                     // We have a pointer to an simple type
                     if (idx == 0)
                     {
-                        child_byte_size = pointee_clang_type.GetByteSize(exe_ctx);
+                        child_byte_size = pointee_clang_type.GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
                         child_byte_offset = 0;
                         return pointee_clang_type;
                     }
@@ -6913,7 +6917,7 @@ ClangASTType::ReadFromMemory (lldb_priva
     if (!GetCompleteType())
         return false;
     
-    const uint64_t byte_size = GetByteSize(exe_ctx);
+    const uint64_t byte_size = GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
     if (data.GetByteSize() < byte_size)
     {
         lldb::DataBufferSP data_sp(new DataBufferHeap (byte_size, '\0'));
@@ -6963,7 +6967,7 @@ ClangASTType::WriteToMemory (lldb_privat
     if (!GetCompleteType())
         return false;
 
-    const uint64_t byte_size = GetByteSize(exe_ctx);
+    const uint64_t byte_size = GetByteSize(exe_ctx ? exe_ctx->GetBestExecutionContextScope() : NULL);
 
     if (byte_size > 0)
     {

Modified: lldb/trunk/source/Target/ExecutionContext.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Target/ExecutionContext.cpp?rev=228892&r1=228891&r2=228892&view=diff
==============================================================================
--- lldb/trunk/source/Target/ExecutionContext.cpp (original)
+++ lldb/trunk/source/Target/ExecutionContext.cpp Wed Feb 11 18:34:25 2015
@@ -119,31 +119,42 @@ ExecutionContext::ExecutionContext (cons
 }
 
 ExecutionContext::ExecutionContext (Target* t, bool fill_current_process_thread_frame) :
-    m_target_sp (t->shared_from_this()),
+    m_target_sp (),
     m_process_sp (),
     m_thread_sp (),
     m_frame_sp ()
 {
-    if (t && fill_current_process_thread_frame)
+    if (t)
     {
-        m_process_sp = t->GetProcessSP();
-        if (m_process_sp)
+        m_target_sp = t->shared_from_this();
+        if (fill_current_process_thread_frame)
         {
-            m_thread_sp = m_process_sp->GetThreadList().GetSelectedThread();
-            if (m_thread_sp)
-                m_frame_sp = m_thread_sp->GetSelectedFrame();
+            m_process_sp = t->GetProcessSP();
+            if (m_process_sp)
+            {
+                m_thread_sp = m_process_sp->GetThreadList().GetSelectedThread();
+                if (m_thread_sp)
+                    m_frame_sp = m_thread_sp->GetSelectedFrame();
+            }
         }
     }
 }
 
 ExecutionContext::ExecutionContext(Process* process, Thread *thread, StackFrame *frame) :
     m_target_sp (),
-    m_process_sp (process->shared_from_this()),
-    m_thread_sp (thread->shared_from_this()),
-    m_frame_sp (frame->shared_from_this())
+    m_process_sp (),
+    m_thread_sp (),
+    m_frame_sp ()
 {
     if (process)
+    {
+        m_process_sp = process->shared_from_this();
         m_target_sp = process->GetTarget().shared_from_this();
+    }
+    if (thread)
+        m_thread_sp = thread->shared_from_this();
+    if (frame)
+        m_frame_sp = frame->shared_from_this();
 }
 
 ExecutionContext::ExecutionContext (const ExecutionContextRef &exe_ctx_ref) :





More information about the lldb-commits mailing list