Skip to content

Commit 3728133

Browse files
committed
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. <rdar://problem/65001402>
1 parent 1bfdf7c commit 3728133

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

lldb/source/Expression/Materializer.cpp

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,7 +785,9 @@ class EntityResultVariable : public Materializer::Entity {
785785

786786
const lldb::addr_t load_addr = process_address + m_offset;
787787

788-
ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
788+
ExecutionContextScope *exe_scope = frame_sp.get();
789+
if (!exe_scope)
790+
exe_scope = map.GetBestExecutionContextScope();
789791

790792
llvm::Optional<uint64_t> byte_size = m_type.GetByteSize(exe_scope);
791793
if (!byte_size) {
@@ -835,7 +837,9 @@ class EntityResultVariable : public Materializer::Entity {
835837
lldb::addr_t frame_bottom, Status &err) override {
836838
err.Clear();
837839

838-
ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
840+
ExecutionContextScope *exe_scope = frame_sp.get();
841+
if (!exe_scope)
842+
exe_scope = map.GetBestExecutionContextScope();
839843

840844
if (!exe_scope) {
841845
err.SetErrorString("Couldn't dematerialize a result variable: invalid "
@@ -1061,7 +1065,9 @@ class EntitySymbol : public Materializer::Entity {
10611065

10621066
const Address sym_address = m_symbol.GetAddress();
10631067

1064-
ExecutionContextScope *exe_scope = map.GetBestExecutionContextScope();
1068+
ExecutionContextScope *exe_scope = frame_sp.get();
1069+
if (!exe_scope)
1070+
exe_scope = map.GetBestExecutionContextScope();
10651071

10661072
lldb::TargetSP target_sp;
10671073

@@ -1342,7 +1348,6 @@ Materializer::DematerializerSP
13421348
Materializer::Materialize(lldb::StackFrameSP &frame_sp, IRMemoryMap &map,
13431349
lldb::addr_t process_address, Status &error) {
13441350
ExecutionContextScope *exe_scope = frame_sp.get();
1345-
13461351
if (!exe_scope)
13471352
exe_scope = map.GetBestExecutionContextScope();
13481353

@@ -1393,7 +1398,9 @@ void Materializer::Dematerializer::Dematerialize(Status &error,
13931398
if (thread_sp)
13941399
frame_sp = thread_sp->GetFrameWithStackID(m_stack_id);
13951400

1396-
ExecutionContextScope *exe_scope = m_map->GetBestExecutionContextScope();
1401+
ExecutionContextScope *exe_scope = frame_sp.get();
1402+
if (!exe_scope)
1403+
exe_scope = m_map->GetBestExecutionContextScope();
13971404

13981405
if (!IsValid()) {
13991406
error.SetErrorToGenericError();

0 commit comments

Comments
 (0)