diff options
| author | Greg Clayton <gclayton@apple.com> | 2012-02-21 00:09:25 +0000 |
|---|---|---|
| committer | Greg Clayton <gclayton@apple.com> | 2012-02-21 00:09:25 +0000 |
| commit | 1ac04c308832f7a9b2e07e360f07c82f7cb2a02c (patch) | |
| tree | bb908a56f1d08a946f4f25aa7b4b762066e1ec57 /lldb/source/Plugins/ABI | |
| parent | 3508a0054301ef24b8d8619351788698bcd97620 (diff) | |
| download | bcm5719-llvm-1ac04c308832f7a9b2e07e360f07c82f7cb2a02c.tar.gz bcm5719-llvm-1ac04c308832f7a9b2e07e360f07c82f7cb2a02c.zip | |
Thread hardening part 3. Now lldb_private::Thread objects have std::weak_ptr
objects for the backlink to the lldb_private::Process. The issues we were
running into before was someone was holding onto a shared pointer to a
lldb_private::Thread for too long, and the lldb_private::Process parent object
would get destroyed and the lldb_private::Thread had a "Process &m_process"
member which would just treat whatever memory that used to be a Process as a
valid Process. This was mostly happening for lldb_private::StackFrame objects
that had a member like "Thread &m_thread". So this completes the internal
strong/weak changes.
Documented the ExecutionContext and ExecutionContextRef classes so that our
LLDB developers can understand when and where to use ExecutionContext and
ExecutionContextRef objects.
llvm-svn: 151009
Diffstat (limited to 'lldb/source/Plugins/ABI')
| -rw-r--r-- | lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp | 17 | ||||
| -rw-r--r-- | lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp | 53 | ||||
| -rw-r--r-- | lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp | 13 |
3 files changed, 43 insertions, 40 deletions
diff --git a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp index 3477695425f..5e6d27b0d64 100644 --- a/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-arm/ABIMacOSX_arm.cpp @@ -264,14 +264,14 @@ ABIMacOSX_arm::PrepareTrivialCall (Thread &thread, } - Target *target = &thread.GetProcess().GetTarget(); + TargetSP target_sp (thread.CalculateTarget()); Address so_addr; // Figure out if our return address is ARM or Thumb by using the // Address::GetCallableLoadAddress(Target*) which will figure out the ARM // thumb-ness and set the correct address bits for us. - so_addr.SetLoadAddress (return_addr, target); - return_addr = so_addr.GetCallableLoadAddress (target); + so_addr.SetLoadAddress (return_addr, target_sp.get()); + return_addr = so_addr.GetCallableLoadAddress (target_sp.get()); // Set "lr" to the return address if (!reg_ctx->WriteRegisterFromUnsigned (ra_reg_num, return_addr)) @@ -283,8 +283,8 @@ ABIMacOSX_arm::PrepareTrivialCall (Thread &thread, // If bit zero or 1 is set, this must be a thumb function, no need to figure // this out from the symbols. - so_addr.SetLoadAddress (function_addr, target); - function_addr = so_addr.GetCallableLoadAddress (target); + so_addr.SetLoadAddress (function_addr, target_sp.get()); + function_addr = so_addr.GetCallableLoadAddress (target_sp.get()); const RegisterInfo *cpsr_reg_info = reg_ctx->GetRegisterInfoByName("cpsr"); const uint32_t curr_cpsr = reg_ctx->ReadRegisterAsUnsigned(cpsr_reg_info, 0); @@ -319,10 +319,11 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread, uint32_t num_values = values.GetSize(); + ExecutionContext exe_ctx (thread.shared_from_this()); // For now, assume that the types in the AST values come from the Target's // scratch AST. - clang::ASTContext *ast_context = thread.CalculateTarget()->GetScratchClangASTContext()->getASTContext(); + clang::ASTContext *ast_context = exe_ctx.GetTargetRef().GetScratchClangASTContext()->getASTContext(); // Extract the register context so we can read arguments from registers @@ -364,7 +365,7 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread, return false; } - if (bit_width <= (thread.GetProcess().GetAddressByteSize() * 8)) + if (bit_width <= (exe_ctx.GetProcessRef().GetAddressByteSize() * 8)) { if (value_idx < 4) { @@ -407,7 +408,7 @@ ABIMacOSX_arm::GetArgumentValues (Thread &thread, // Arguments 5 on up are on the stack const uint32_t arg_byte_size = (bit_width + (8-1)) / 8; Error error; - if (!thread.GetProcess().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error)) + if (!exe_ctx.GetProcessRef().ReadScalarIntegerFromMemory(sp, arg_byte_size, is_signed, value->GetScalar(), error)) return false; sp += arg_byte_size; diff --git a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp index a8f407d042b..f31e1a7e9fe 100644 --- a/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp +++ b/lldb/source/Plugins/ABI/MacOSX-i386/ABIMacOSX_i386.cpp @@ -418,9 +418,12 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread, addr_t return_addr, ValueList &args) const { + ExecutionContext exe_ctx (thread.shared_from_this()); RegisterContext *reg_ctx = thread.GetRegisterContext().get(); if (!reg_ctx) return false; + + Process *process = exe_ctx.GetProcessPtr(); Error error; uint32_t fp_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_FP); uint32_t pc_reg_num = reg_ctx->ConvertRegisterKindToRegisterNumber (eRegisterKindGeneric, LLDB_REGNUM_GENERIC_PC); @@ -528,7 +531,7 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread, sp -= (cstr_length + 1); - if (thread.GetProcess().WriteMemory(sp, cstr, cstr_length + 1, error) != (cstr_length + 1)) + if (process->WriteMemory(sp, cstr, cstr_length + 1, error) != (cstr_length + 1)) return false; // Put the address of the string into the argument array. @@ -563,14 +566,14 @@ ABIMacOSX_i386::PrepareNormalCall (Thread &thread, size_t numChunks = argLayout.size(); for (index = 0; index < numChunks; ++index) - if (thread.GetProcess().WriteMemory(sp + (index * 4), &argLayout[index], sizeof(uint32_t), error) != sizeof(uint32_t)) + if (process->WriteMemory(sp + (index * 4), &argLayout[index], sizeof(uint32_t), error) != sizeof(uint32_t)) return false; // The return address is pushed onto the stack. sp -= 4; uint32_t returnAddressU32 = return_addr; - if (thread.GetProcess().WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32)) + if (process->WriteMemory (sp, &returnAddressU32, sizeof(returnAddressU32), error) != sizeof(returnAddressU32)) return false; // %esp is set to the actual stack value. @@ -595,13 +598,13 @@ static bool ReadIntegerArgument (Scalar &scalar, unsigned int bit_width, bool is_signed, - Process &process, + Process *process, addr_t ¤t_stack_argument) { uint32_t byte_size = (bit_width + (8-1))/8; Error error; - if (process.ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) + if (process->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) { current_stack_argument += byte_size; return true; @@ -652,29 +655,29 @@ ABIMacOSX_i386::GetArgumentValues (Thread &thread, default: return false; case Value::eContextTypeClangType: - { - void *value_type = value->GetClangType(); - bool is_signed; - - if (ClangASTContext::IsIntegerType (value_type, is_signed)) { - size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); + void *value_type = value->GetClangType(); + bool is_signed; - ReadIntegerArgument(value->GetScalar(), - bit_width, - is_signed, - thread.GetProcess(), - current_stack_argument); - } - else if (ClangASTContext::IsPointerType (value_type)) - { - ReadIntegerArgument(value->GetScalar(), - 32, - false, - thread.GetProcess(), - current_stack_argument); + if (ClangASTContext::IsIntegerType (value_type, is_signed)) + { + size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, value_type); + + ReadIntegerArgument(value->GetScalar(), + bit_width, + is_signed, + thread.GetProcess().get(), + current_stack_argument); + } + else if (ClangASTContext::IsPointerType (value_type)) + { + ReadIntegerArgument(value->GetScalar(), + 32, + false, + thread.GetProcess().get(), + current_stack_argument); + } } - } break; } } 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 cd8b7b8cd09..9de0cf2dc39 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 @@ -450,7 +450,7 @@ static bool ReadIntegerArgument(Scalar &scalar, { uint32_t byte_size = (bit_width + (8-1))/8; Error error; - if (thread.GetProcess().ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) + if (thread.GetProcess()->ReadScalarIntegerFromMemory(current_stack_argument, byte_size, is_signed, scalar, error)) { current_stack_argument += byte_size; return true; @@ -690,12 +690,11 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread, } ValueObjectSP -ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, - ClangASTType &ast_type) const +ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, ClangASTType &ast_type) const { - ValueObjectSP return_valobj_sp; + ExecutionContext exe_ctx (thread.shared_from_this()); return_valobj_sp = GetReturnValueObjectSimple(thread, ast_type); if (return_valobj_sp) return return_valobj_sp; @@ -715,15 +714,15 @@ ABISysV_x86_64::GetReturnValueObjectImpl (Thread &thread, size_t bit_width = ClangASTType::GetClangTypeBitWidth(ast_context, ret_value_type); if (ClangASTContext::IsAggregateType(ret_value_type)) { - Target &target = thread.GetProcess().GetTarget(); + Target *target = exe_ctx.GetTargetPtr(); bool is_memory = true; if (bit_width <= 128) { - ByteOrder target_byte_order = target.GetArchitecture().GetByteOrder(); + ByteOrder target_byte_order = target->GetArchitecture().GetByteOrder(); DataBufferSP data_sp (new DataBufferHeap(16, 0)); DataExtractor return_ext (data_sp, target_byte_order, - target.GetArchitecture().GetAddressByteSize()); + target->GetArchitecture().GetAddressByteSize()); const RegisterInfo *rax_info = reg_ctx_sp->GetRegisterInfoByName("rax", 0); const RegisterInfo *rdx_info = reg_ctx_sp->GetRegisterInfoByName("rdx", 0); |

