diff options
| author | Greg Clayton <gclayton@apple.com> | 2015-02-12 00:34:25 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2015-02-12 00:34:25 +0000 |
| commit | 526ae040bab73b5c9ae273d499a1ab8cb5fb0381 (patch) | |
| tree | 6230dad5200ab6945fe18d81874c463dcfd0bd1c | |
| parent | 36f807c8603b170ad71e0f15ec0279aa1c40384c (diff) | |
| download | bcm5719-llvm-526ae040bab73b5c9ae273d499a1ab8cb5fb0381.tar.gz bcm5719-llvm-526ae040bab73b5c9ae273d499a1ab8cb5fb0381.zip | |
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.
llvm-svn: 228892
| -rw-r--r-- | lldb/include/lldb/Expression/IRForTarget.h | 3 | ||||
| -rw-r--r-- | lldb/include/lldb/Expression/IRMemoryMap.h | 12 | ||||
| -rw-r--r-- | lldb/include/lldb/Symbol/ClangASTType.h | 4 | ||||
| -rw-r--r-- | lldb/source/Core/ValueObject.cpp | 8 | ||||
| -rw-r--r-- | lldb/source/Core/ValueObjectConstResult.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Core/ValueObjectVariable.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/DataFormatters/CXXFormatterFunctions.cpp | 2 | ||||
| -rw-r--r-- | lldb/source/Expression/IRForTarget.cpp | 20 | ||||
| -rw-r--r-- | lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp | 4 | ||||
| -rw-r--r-- | lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp | 6 | ||||
| -rw-r--r-- | lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp | 12 | ||||
| -rw-r--r-- | lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp | 12 | ||||
| -rw-r--r-- | lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp | 10 | ||||
| -rw-r--r-- | lldb/source/Symbol/ClangASTType.cpp | 34 | ||||
| -rw-r--r-- | lldb/source/Target/ExecutionContext.cpp | 31 |
16 files changed, 103 insertions, 65 deletions
diff --git a/lldb/include/lldb/Expression/IRForTarget.h b/lldb/include/lldb/Expression/IRForTarget.h index 0ad34904f56..b81fab7a8a8 100644 --- a/lldb/include/lldb/Expression/IRForTarget.h +++ b/lldb/include/lldb/Expression/IRForTarget.h @@ -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; diff --git a/lldb/include/lldb/Expression/IRMemoryMap.h b/lldb/include/lldb/Expression/IRMemoryMap.h index 4faa5226d9b..0da8384c8e6 100644 --- a/lldb/include/lldb/Expression/IRMemoryMap.h +++ b/lldb/include/lldb/Expression/IRMemoryMap.h @@ -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 { diff --git a/lldb/include/lldb/Symbol/ClangASTType.h b/lldb/include/lldb/Symbol/ClangASTType.h index 94c768780a0..2524751e092 100644 --- a/lldb/include/lldb/Symbol/ClangASTType.h +++ b/lldb/include/lldb/Symbol/ClangASTType.h @@ -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; diff --git a/lldb/source/Core/ValueObject.cpp b/lldb/source/Core/ValueObject.cpp index ebbcb8ec408..231f4972c27 100644 --- a/lldb/source/Core/ValueObject.cpp +++ b/lldb/source/Core/ValueObject.cpp @@ -973,7 +973,7 @@ ValueObject::GetPointeeData (DataExtractor& data, 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 (DataExtractor& data, 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(uint32_t offset, const ClangASTType& type 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 offset, const ClangASTType& type, bool c ValueObjectChild *synthetic_child = new ValueObjectChild(*this, type, name_const_str, - type.GetByteSize(&exe_ctx), + type.GetByteSize(exe_ctx.GetBestExecutionContextScope()), offset, 0, 0, diff --git a/lldb/source/Core/ValueObjectConstResult.cpp b/lldb/source/Core/ValueObjectConstResult.cpp index e8b477a74a5..b4e63030646 100644 --- a/lldb/source/Core/ValueObjectConstResult.cpp +++ b/lldb/source/Core/ValueObjectConstResult.cpp @@ -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; } diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index ed2aeb3d963..c86bece42eb 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -112,7 +112,7 @@ ValueObjectVariable::GetByteSize() if (!type.IsValid()) return 0; - return type.GetByteSize(&exe_ctx); + return type.GetByteSize(exe_ctx.GetBestExecutionContextScope()); } lldb::ValueType diff --git a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp index 5aa8289794c..9c45e272a63 100644 --- a/lldb/source/DataFormatters/CXXFormatterFunctions.cpp +++ b/lldb/source/DataFormatters/CXXFormatterFunctions.cpp @@ -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(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); diff --git a/lldb/source/Expression/IRForTarget.cpp b/lldb/source/Expression/IRForTarget.cpp index 42390b35fdd..7951812cb7e 100644 --- a/lldb/source/Expression/IRForTarget.cpp +++ b/lldb/source/Expression/IRForTarget.cpp @@ -59,7 +59,8 @@ IRForTarget::FunctionValueCache::~FunctionValueCache() { } -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::FunctionValueCache::GetValue(llvm::Function *function) 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::StaticDataAllocator::Allocate() 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::Function &llvm_function) &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); diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 42acba232de..fdd88b0a17d 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -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(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 (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(nullptr); + size_t bit_width = clang_type.GetBitSize(&thread); switch (bit_width) { diff --git a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp index c2ba165afb4..72241f307c3 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm64/ABIMacOSX_arm64.cpp @@ -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(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 { diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index ee5b9298721..ff6f29062dc 100644 --- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -552,7 +552,7 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread, 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 (Thread &thread, 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 (Thread &thread, 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]; diff --git a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp index 741afebfcb8..316937779b5 100644 --- a/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp +++ b/lldb/source/Plugins/ABI/SysV-ppc/ABISysV_ppc.cpp @@ -390,7 +390,7 @@ static bool ReadIntegerArgument(Scalar &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 &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 &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::StackFrameSP &frame_sp, lldb::ValueObjec 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 (Thread &thread, ClangASTType &return_clan 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 (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(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) diff --git a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp index 88c18fb6f20..decdc7e76c7 100644 --- a/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp +++ b/lldb/source/Plugins/ABI/SysV-ppc64/ABISysV_ppc64.cpp @@ -390,7 +390,7 @@ static bool ReadIntegerArgument(Scalar &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 &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 &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::StackFrameSP &frame_sp, lldb::ValueObj 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 (Thread &thread, ClangASTType &return_cl 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 (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(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) diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 71d99c8c65d..6e716cd8b9b 100644 --- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -510,7 +510,7 @@ ABISysV_x86_64::GetArgumentValues (Thread &thread, 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 (Thread &thread, 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(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(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 (Thread &thread, ClangASTType &return_c 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 (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(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) diff --git a/lldb/source/Symbol/ClangASTType.cpp b/lldb/source/Symbol/ClangASTType.cpp index 8e3d7bd7292..3f26848a058 100644 --- a/lldb/source/Symbol/ClangASTType.cpp +++ b/lldb/source/Symbol/ClangASTType.cpp @@ -2093,7 +2093,7 @@ ClangASTType::GetBasicTypeFromAST (lldb::BasicType basic_type) const //---------------------------------------------------------------------- uint64_t -ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const +ClangASTType::GetBitSize (ExecutionContextScope *exe_scope) const { if (GetCompleteType ()) { @@ -2102,9 +2102,12 @@ ClangASTType::GetBitSize (ExecutionContext *exe_ctx) const { 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 (ExecutionContext *exe_ctx) const 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 (ExecutionContext *exe_ctx) const } 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 (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(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 (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(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 (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(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 (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(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 (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(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 (ExecutionContext *exe_ctx, // 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 (ExecutionContext *exe_ctx, // 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_private::ExecutionContext *exe_ctx, 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_private::ExecutionContext *exe_ctx, 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) { diff --git a/lldb/source/Target/ExecutionContext.cpp b/lldb/source/Target/ExecutionContext.cpp index e03a560bd06..750af92d759 100644 --- a/lldb/source/Target/ExecutionContext.cpp +++ b/lldb/source/Target/ExecutionContext.cpp @@ -119,31 +119,42 @@ ExecutionContext::ExecutionContext (const lldb::StackFrameWP &frame_wp) : } 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) : |

