<rdar://problem/11791234>
Fixed a case where the python interpreter could end up holding onto a previous lldb::SBProcess (probably in lldb.process) when run under Xcode. Prior to this fix, the lldb::SBProcess held onto a shared pointer to a lldb_private::Process. This in turn could cause the process to still have a thread list with stack frames. The stack frames would have module shared pointers in the lldb_private::SymbolContext objects.
We also had issues with things staying in the shared module list too long when we found things by UUID (we didn't remove the out of date ModuleSP from the global module cache).
Now all of this is fixed and everything goes away between runs.
git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@160140 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/source/Interpreter/CommandInterpreter.cpp b/source/Interpreter/CommandInterpreter.cpp
index 8d29133..2879ec4 100644
--- a/source/Interpreter/CommandInterpreter.cpp
+++ b/source/Interpreter/CommandInterpreter.cpp
@@ -1143,7 +1143,8 @@
{
std::string expr_str (command, expr_content_start, end_backtick - expr_content_start);
- Target *target = m_exe_ctx.GetTargetPtr();
+ ExecutionContext exe_ctx(GetExecutionContext());
+ Target *target = exe_ctx.GetTargetPtr();
// Get a dummy target to allow for calculator mode while processing backticks.
// This also helps break the infinite loop caused when target is null.
if (!target)
@@ -1155,7 +1156,7 @@
const bool keep_in_memory = false;
ValueObjectSP expr_result_valobj_sp;
ExecutionResults expr_result = target->EvaluateExpression (expr_str.c_str(),
- m_exe_ctx.GetFramePtr(),
+ exe_ctx.GetFramePtr(),
eExecutionPolicyOnlyWhenNeeded,
coerce_to_id,
unwind_on_error,
@@ -2228,7 +2229,8 @@
PlatformSP platform_sp;
if (prefer_target_platform)
{
- Target *target = m_exe_ctx.GetTargetPtr();
+ ExecutionContext exe_ctx(GetExecutionContext());
+ Target *target = exe_ctx.GetTargetPtr();
if (target)
platform_sp = target->GetPlatform();
}
@@ -2618,39 +2620,14 @@
void
CommandInterpreter::UpdateExecutionContext (ExecutionContext *override_context)
{
- m_exe_ctx.Clear();
-
if (override_context != NULL)
{
- m_exe_ctx = *override_context;
+ m_exe_ctx_ref = *override_context;
}
else
{
- TargetSP target_sp (m_debugger.GetSelectedTarget());
- if (target_sp)
- {
- m_exe_ctx.SetTargetSP (target_sp);
- ProcessSP process_sp (target_sp->GetProcessSP());
- m_exe_ctx.SetProcessSP (process_sp);
- if (process_sp && process_sp->IsAlive() && !process_sp->IsRunning())
- {
- ThreadSP thread_sp (process_sp->GetThreadList().GetSelectedThread());
- if (thread_sp)
- {
- m_exe_ctx.SetThreadSP (thread_sp);
- StackFrameSP frame_sp (thread_sp->GetSelectedFrame());
- if (!frame_sp)
- {
- frame_sp = thread_sp->GetStackFrameAtIndex (0);
- // If we didn't have a selected frame select one here.
- if (frame_sp)
- thread_sp->SetSelectedFrame(frame_sp.get());
- }
- if (frame_sp)
- m_exe_ctx.SetFrameSP (frame_sp);
- }
- }
- }
+ const bool adopt_selected = true;
+ m_exe_ctx_ref.SetTargetPtr (m_debugger.GetSelectedTarget().get(), adopt_selected);
}
}