diff options
author | Greg Clayton <gclayton@apple.com> | 2012-02-17 07:49:44 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2012-02-17 07:49:44 +0000 |
commit | cc4d0146b4f5edf4cebf06697f52959409136591 (patch) | |
tree | 9aa64046056d513eb1e506b126f89584e8ef9aee /lldb/source/Core/ValueObjectVariable.cpp | |
parent | dd19169988da4fca1149852c67019e448f13c75f (diff) | |
download | bcm5719-llvm-cc4d0146b4f5edf4cebf06697f52959409136591.tar.gz bcm5719-llvm-cc4d0146b4f5edf4cebf06697f52959409136591.zip |
This checking is part one of trying to add some threading safety to our
internals. The first part of this is to use a new class:
lldb_private::ExecutionContextRef
This class holds onto weak pointers to the target, process, thread and frame
and it also contains the thread ID and frame Stack ID in case the thread and
frame objects go away and come back as new objects that represent the same
logical thread/frame.
ExecutionContextRef objcets have accessors to access shared pointers for
the target, process, thread and frame which might return NULL if the backing
object is no longer available. This allows for references to persistent program
state without needing to hold a shared pointer to each object and potentially
keeping that object around for longer than it needs to be.
You can also "Lock" and ExecutionContextRef (which contains weak pointers)
object into an ExecutionContext (which contains strong, or shared pointers)
with code like
ExecutionContext exe_ctx (my_obj->GetExectionContextRef().Lock());
llvm-svn: 150801
Diffstat (limited to 'lldb/source/Core/ValueObjectVariable.cpp')
-rw-r--r-- | lldb/source/Core/ValueObjectVariable.cpp | 30 |
1 files changed, 21 insertions, 9 deletions
diff --git a/lldb/source/Core/ValueObjectVariable.cpp b/lldb/source/Core/ValueObjectVariable.cpp index 181324db251..24f189d9f95 100644 --- a/lldb/source/Core/ValueObjectVariable.cpp +++ b/lldb/source/Core/ValueObjectVariable.cpp @@ -127,7 +127,7 @@ ValueObjectVariable::UpdateValue () else { lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; - ExecutionContext exe_ctx (GetExecutionContextScope()); + ExecutionContext exe_ctx (GetExecutionContextRef()); Target *target = exe_ctx.GetTargetPtr(); if (target) @@ -242,15 +242,27 @@ ValueObjectVariable::UpdateValue () bool ValueObjectVariable::IsInScope () { - ExecutionContextScope *exe_scope = GetExecutionContextScope(); - if (!exe_scope) - return true; - - StackFrame *frame = exe_scope->CalculateStackFrame(); - if (!frame) - return true; + const ExecutionContextRef &exe_ctx_ref = GetExecutionContextRef(); + if (exe_ctx_ref.HasFrameRef()) + { + ExecutionContext exe_ctx (exe_ctx_ref); + StackFrame *frame = exe_ctx.GetFramePtr(); + if (frame) + { + return m_variable_sp->IsInScope (frame); + } + else + { + // This ValueObject had a frame at one time, but now we + // can't locate it, so return false since we probably aren't + // in scope. + return false; + } + } + // We have a variable that wasn't tied to a frame, which + // means it is a global and is always in scope. + return true; - return m_variable_sp->IsInScope (frame); } Module * |