diff options
author | Greg Clayton <gclayton@apple.com> | 2012-02-18 05:35:26 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-02-18 05:35:26 +0000 |
commit | d9e416c0ea61c13440e99fdab86e44c6e71a8eff (patch) | |
tree | 7cdcdc10fb941cb0658a5a651a5f6ceb2cd40e63 /lldb/source/Core/EmulateInstruction.cpp | |
parent | 0dea49e324ecb836ddad859495bde8ffc48a8ae0 (diff) | |
download | bcm5719-llvm-d9e416c0ea61c13440e99fdab86e44c6e71a8eff.tar.gz bcm5719-llvm-d9e416c0ea61c13440e99fdab86e44c6e71a8eff.zip |
The second part in thread hardening the internals of LLDB where we make
the lldb_private::StackFrame objects hold onto a weak pointer to the thread
object. The lldb_private::StackFrame objects the the most volatile objects
we have as when we are doing single stepping, frames can often get lost or
thrown away, only to be re-created as another object that still refers to the
same frame. We have another bug tracking that. But we need to be able to
have frames no longer be able to get the thread when they are not part of
a thread anymore, and this is the first step (this fix makes that possible
but doesn't implement it yet).
Also changed lldb_private::ExecutionContextScope to return shared pointers to
all objects in the execution context to further thread harden the internals.
llvm-svn: 150871
Diffstat (limited to 'lldb/source/Core/EmulateInstruction.cpp')
-rw-r--r-- | lldb/source/Core/EmulateInstruction.cpp | 46 |
1 files changed, 17 insertions, 29 deletions
diff --git a/lldb/source/Core/EmulateInstruction.cpp b/lldb/source/Core/EmulateInstruction.cpp index a3990fc5de7..f17924747d8 100644 --- a/lldb/source/Core/EmulateInstruction.cpp +++ b/lldb/source/Core/EmulateInstruction.cpp @@ -10,7 +10,6 @@ #include "lldb/Core/EmulateInstruction.h" #include "lldb/Core/Address.h" -#include "lldb/Core/DataBufferHeap.h" #include "lldb/Core/DataExtractor.h" #include "lldb/Core/Error.h" #include "lldb/Core/PluginManager.h" @@ -287,24 +286,20 @@ EmulateInstruction::ReadMemoryFrame (EmulateInstruction *instruction, const Context &context, lldb::addr_t addr, void *dst, - size_t length) + size_t dst_len) { - if (!baton) + if (!baton || dst == NULL || dst_len == 0) return 0; - - + StackFrame *frame = (StackFrame *) baton; - DataBufferSP data_sp (new DataBufferHeap (length, '\0')); - Error error; - - size_t bytes_read = frame->GetThread().GetProcess().ReadMemory (addr, data_sp->GetBytes(), data_sp->GetByteSize(), - error); - - if (bytes_read > 0) - ((DataBufferHeap *) data_sp.get())->CopyData (dst, length); - - return bytes_read; + ProcessSP process_sp (frame->CalculateProcess()); + if (process_sp) + { + Error error; + return process_sp->ReadMemory (addr, dst, dst_len, error); + } + return 0; } size_t @@ -312,26 +307,19 @@ EmulateInstruction::WriteMemoryFrame (EmulateInstruction *instruction, void *baton, const Context &context, lldb::addr_t addr, - const void *dst, - size_t length) + const void *src, + size_t src_len) { - if (!baton) + if (!baton || src == NULL || src_len == 0) return 0; StackFrame *frame = (StackFrame *) baton; - lldb::DataBufferSP data_sp (new DataBufferHeap (dst, length)); - if (data_sp) + ProcessSP process_sp (frame->CalculateProcess()); + if (process_sp) { - length = data_sp->GetByteSize(); - if (length > 0) - { - Error error; - size_t bytes_written = frame->GetThread().GetProcess().WriteMemory (addr, data_sp->GetBytes(), length, - error); - - return bytes_written; - } + Error error; + return process_sp->WriteMemory (addr, src, src_len, error); } return 0; |