From dca9c4a31e795d84bb85fa8a602b6c5f1e659aa7 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 8 Jul 2020 14:35:02 -0700 Subject: [PATCH] Unify the ExecutionContextScope computation in Materializer. This is an NFC cleanup for Clang, and a bugfix for the Swift branch. In swift-lldb one target may have multiple scratch TypeSystems, so it is important to pick the one that belongs to the current frame, rather than the one for the current target. (cherry picked from commit 3728133d3f124c4c6972b118b0265de48ba89db1) --- lldb/source/Expression/Materializer.cpp | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/lldb/source/Expression/Materializer.cpp b/lldb/source/Expression/Materializer.cpp index cd332484debbc..e94832f09ef8e 100644 --- a/lldb/source/Expression/Materializer.cpp +++ b/lldb/source/Expression/Materializer.cpp @@ -784,7 +784,9 @@ class EntityResultVariable : public Materializer::Entity { const lldb::addr_t load_addr = process_address + m_offset; - ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = frame_sp.get(); + if (!exe_scope) + exe_scope = map.GetBestExecutionContextScope(); llvm::Optional byte_size = m_type.GetByteSize(exe_scope); if (!byte_size) { @@ -834,7 +836,9 @@ class EntityResultVariable : public Materializer::Entity { lldb::addr_t frame_bottom, Status &err) override { err.Clear(); - ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = frame_sp.get(); + if (!exe_scope) + exe_scope = map.GetBestExecutionContextScope(); if (!exe_scope) { err.SetErrorString("Couldn't dematerialize a result variable: invalid " @@ -1062,7 +1066,9 @@ class EntitySymbol : public Materializer::Entity { const Address sym_address = m_symbol.GetAddress(); - ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = frame_sp.get(); + if (!exe_scope) + exe_scope = map.GetBestExecutionContextScope(); lldb::TargetSP target_sp; @@ -1346,7 +1352,6 @@ Materializer::DematerializerSP Materializer::Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map, lldb::addr_t process_address, Status &error) { ExecutionContextScope *exe_scope = frame_sp.get(); - if (!exe_scope) exe_scope = map.GetBestExecutionContextScope(); @@ -1397,7 +1402,9 @@ void Materializer::Dematerializer::Dematerialize(Status &error, if (thread_sp) frame_sp = thread_sp->GetFrameWithStackID(m_stack_id); - ExecutionContextScope *exe_scope = m_map->GetBestExecutionContextScope(); + ExecutionContextScope *exe_scope = frame_sp.get(); + if (!exe_scope) + exe_scope = m_map->GetBestExecutionContextScope(); if (!IsValid()) { error.SetErrorToGenericError();