From 8d94ba0fb18e0b40631737b88f8c9a9abf025d80 Mon Sep 17 00:00:00 2001 From: Jim Ingham Date: Sat, 12 Mar 2016 02:45:34 +0000 Subject: This change introduces a "ExpressionExecutionThread" to the ThreadList. Turns out that most of the code that runs expressions (e.g. the ObjC runtime grubber) on behalf of the expression parser was using the currently selected thread. But sometimes, e.g. when we are evaluating breakpoint conditions/commands, we don't select the thread we're running on, we instead set the context for the interpreter, and explicitly pass that to other callers. That wasn't getting communicated to these utility expressions, so they would run on some other thread instead, and that could cause a variety of subtle and hard to reproduce problems. I also went through the commands and cleaned up the use of GetSelectedThread. All those uses should have been trying the thread in the m_exe_ctx belonging to the command object first. It would actually have been pretty hard to get misbehavior in these cases, but for correctness sake it is good to make this usage consistent. llvm-svn: 263326 --- lldb/source/DataFormatters/FormattersHelpers.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'lldb/source/DataFormatters/FormattersHelpers.cpp') diff --git a/lldb/source/DataFormatters/FormattersHelpers.cpp b/lldb/source/DataFormatters/FormattersHelpers.cpp index 4b0e82e975e..6c1b8c37480 100644 --- a/lldb/source/DataFormatters/FormattersHelpers.cpp +++ b/lldb/source/DataFormatters/FormattersHelpers.cpp @@ -140,13 +140,18 @@ lldb_private::formatters::GetViableFrame (ExecutionContext exe_ctx) if (frame) return frame; + Thread *thread = exe_ctx.GetThreadPtr(); + if (thread) + return thread->GetSelectedFrame().get(); + Process* process = exe_ctx.GetProcessPtr(); if (!process) return nullptr; - ThreadSP thread_sp(process->GetThreadList().GetSelectedThread()); - if (thread_sp) - return thread_sp->GetSelectedFrame().get(); + thread = process->GetThreadList().GetSelectedThread().get(); + if (thread) + return thread->GetSelectedFrame().get(); + return nullptr; } -- cgit v1.2.3