[Lldb-commits] [lldb] r146309 - in /lldb/trunk: include/lldb/Core/ValueObject.h source/Core/ValueObject.cpp
Jim Ingham
jingham at apple.com
Fri Dec 9 17:49:43 PST 2011
Author: jingham
Date: Fri Dec 9 19:49:43 2011
New Revision: 146309
URL: http://llvm.org/viewvc/llvm-project?rev=146309&view=rev
Log:
Don't try to cache the ExecutionContextScope in the ValueObject::EvaluationPoint, it is too
hard to ensure it doesn't get invalidated out from under us. Instead look it up from the ThreadID
and StackID when asked for it.
<rdar://problem/10554409>
Modified:
lldb/trunk/include/lldb/Core/ValueObject.h
lldb/trunk/source/Core/ValueObject.cpp
Modified: lldb/trunk/include/lldb/Core/ValueObject.h
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/include/lldb/Core/ValueObject.h?rev=146309&r1=146308&r2=146309&view=diff
==============================================================================
--- lldb/trunk/include/lldb/Core/ValueObject.h (original)
+++ lldb/trunk/include/lldb/Core/ValueObject.h Fri Dec 9 19:49:43 2011
@@ -445,10 +445,15 @@
private:
bool
- SyncWithProcessState ();
+ SyncWithProcessState ()
+ {
+ ExecutionContextScope *exe_scope;
+ return SyncWithProcessState(exe_scope);
+ }
+
+ bool
+ SyncWithProcessState (ExecutionContextScope *&exe_scope);
- ExecutionContextScope *m_exe_scope; // This is not the way to store the evaluation point state, it is just
- // a cache of the lookup, and gets thrown away when we update.
bool m_needs_update;
bool m_first_update;
Modified: lldb/trunk/source/Core/ValueObject.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Core/ValueObject.cpp?rev=146309&r1=146308&r2=146309&view=diff
==============================================================================
--- lldb/trunk/source/Core/ValueObject.cpp (original)
+++ lldb/trunk/source/Core/ValueObject.cpp Fri Dec 9 19:49:43 2011
@@ -3441,8 +3441,7 @@
{
ExecutionContext exe_ctx;
- ExecutionContextScope *computed_exe_scope = exe_scope; // If use_selected is true, we may find a better scope,
- // and if so we want to cache that not the original.
+
if (exe_scope)
exe_scope->CalculateExecutionContext(exe_ctx);
Target *target = exe_ctx.GetTargetPtr();
@@ -3462,11 +3461,7 @@
if (thread == NULL)
{
if (use_selected)
- {
thread = m_process_sp->GetThreadList().GetSelectedThread().get();
- if (thread)
- computed_exe_scope = thread;
- }
}
if (thread != NULL)
@@ -3480,10 +3475,7 @@
{
frame = thread->GetSelectedFrame().get();
if (frame)
- {
m_stack_id = frame->GetStackID();
- computed_exe_scope = frame;
- }
}
}
else
@@ -3491,11 +3483,9 @@
}
}
}
- m_exe_scope = computed_exe_scope;
}
ValueObject::EvaluationPoint::EvaluationPoint (const ValueObject::EvaluationPoint &rhs) :
- m_exe_scope (rhs.m_exe_scope),
m_needs_update(true),
m_first_update(true),
m_target_sp (rhs.m_target_sp),
@@ -3513,10 +3503,11 @@
ExecutionContextScope *
ValueObject::EvaluationPoint::GetExecutionContextScope ()
{
- // We have to update before giving out the scope, or we could be handing out stale pointers.
- SyncWithProcessState();
+ // We have to update before giving out the scope, or we could be handing out stale pointers.
+ ExecutionContextScope *exe_scope;
+ SyncWithProcessState(exe_scope);
- return m_exe_scope;
+ return exe_scope;
}
// This function checks the EvaluationPoint against the current process state. If the current
@@ -3524,14 +3515,15 @@
// false, meaning "no change". If the current state is different, we update our state, and return
// true meaning "yes, change". If we did see a change, we also set m_needs_update to true, so
// future calls to NeedsUpdate will return true.
+// exe_scope will be set to the current execution context scope.
bool
-ValueObject::EvaluationPoint::SyncWithProcessState()
+ValueObject::EvaluationPoint::SyncWithProcessState(ExecutionContextScope *&exe_scope)
{
// If we don't have a process nothing can change.
if (!m_process_sp)
{
- m_exe_scope = m_target_sp.get();
+ exe_scope = m_target_sp.get();
return false;
}
@@ -3542,22 +3534,28 @@
// In either case, we aren't going to be able to sync with the process state.
if (current_mod_id.GetStopID() == 0)
{
- m_exe_scope = m_target_sp.get();
+ exe_scope = m_target_sp.get();
return false;
}
-
+
+ bool changed;
+
if (m_mod_id.IsValid())
{
if (m_mod_id == current_mod_id)
{
// Everything is already up to date in this object, no need do
// update the execution context scope.
- return false;
+ changed = false;
}
- m_mod_id = current_mod_id;
- m_needs_update = true;
+ else
+ {
+ m_mod_id = current_mod_id;
+ m_needs_update = true;
+ changed = true;
+ }
}
- m_exe_scope = m_process_sp.get();
+ exe_scope = m_process_sp.get();
// Something has changed, so we will return true. Now make sure the thread & frame still exist, and if either
// doesn't, mark ourselves as invalid.
@@ -3571,7 +3569,7 @@
}
else
{
- m_exe_scope = our_thread;
+ exe_scope = our_thread;
if (m_stack_id.IsValid())
{
@@ -3579,18 +3577,18 @@
if (our_frame == NULL)
SetInvalid();
else
- m_exe_scope = our_frame;
+ exe_scope = our_frame;
}
}
}
- return true;
+ return changed;
}
void
ValueObject::EvaluationPoint::SetUpdated ()
{
- // this will update the execution context scope and the m_mod_id
- SyncWithProcessState();
+ if (m_process_sp)
+ m_mod_id = m_process_sp->GetModID();
m_first_update = false;
m_needs_update = false;
}
@@ -3603,7 +3601,6 @@
return false;
bool needs_update = false;
- m_exe_scope = NULL;
// The target has to be non-null, and the
Target *target = exe_scope->CalculateTarget();
More information about the lldb-commits
mailing list