@@ -237,6 +237,8 @@ SwiftLanguageRuntimeImpl::GetMemoryReader() {
237
237
m_process, [&](swift::remote::RemoteAbsolutePointer pointer) {
238
238
ThreadSafeReflectionContext reflection_context =
239
239
GetReflectionContext ();
240
+ if (!reflection_context)
241
+ return pointer;
240
242
return reflection_context->StripSignedPointer (pointer);
241
243
}));
242
244
}
@@ -651,6 +653,9 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
651
653
return {};
652
654
653
655
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
656
+ if (!reflection_ctx)
657
+ return {};
658
+
654
659
LLDBTypeInfoProvider tip (*this , *ts);
655
660
auto *cti = reflection_ctx->GetClassInstanceTypeInfo (tr, &tip);
656
661
if (auto *rti =
@@ -724,6 +729,9 @@ SwiftLanguageRuntimeImpl::GetNumFields(CompilerType type,
724
729
return 0 ;
725
730
case ReferenceKind::Strong:
726
731
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
732
+ if (!reflection_ctx)
733
+ return {};
734
+
727
735
LLDBTypeInfoProvider tip (*this , *ts);
728
736
auto *cti = reflection_ctx->GetClassInstanceTypeInfo (tr, &tip);
729
737
if (auto *rti = llvm::dyn_cast_or_null<RecordTypeInfo>(cti)) {
@@ -856,6 +864,9 @@ SwiftLanguageRuntimeImpl::GetIndexOfChildMemberWithName(
856
864
child_indexes);
857
865
case ReferenceKind::Strong: {
858
866
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
867
+ if (!reflection_ctx)
868
+ return {false , {}};
869
+
859
870
LLDBTypeInfoProvider tip (*this , *ts);
860
871
// `current_tr` iterates the class hierarchy, from the current class, each
861
872
// superclass, and ends on null.
@@ -1553,6 +1564,9 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
1553
1564
}
1554
1565
Log *log (GetLog (LLDBLog::Types));
1555
1566
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
1567
+ if (!reflection_ctx)
1568
+ return false ;
1569
+
1556
1570
const auto *typeref =
1557
1571
reflection_ctx->ReadTypeFromInstance (instance_ptr, true );
1558
1572
if (!typeref) {
@@ -1705,6 +1719,9 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
1705
1719
swift::remote::RemoteAddress remote_existential (existential_address);
1706
1720
1707
1721
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
1722
+ if (!reflection_ctx)
1723
+ return false ;
1724
+
1708
1725
auto pair = reflection_ctx->ProjectExistentialAndUnwrapClass (
1709
1726
remote_existential, *protocol_typeref);
1710
1727
if (use_local_buffer)
@@ -2159,22 +2176,23 @@ SwiftLanguageRuntimeImpl::GetValueType(ValueObject &in_value,
2159
2176
// Read the value witness table and check if the data is inlined in
2160
2177
// the existential container or not.
2161
2178
swift::remote::RemoteAddress remote_existential (existential_address);
2162
- ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
2163
- llvm::Optional<bool > is_inlined =
2164
- reflection_ctx->IsValueInlinedInExistentialContainer (
2165
- remote_existential);
2166
-
2167
- if (use_local_buffer)
2168
- PopLocalBuffer ();
2169
-
2170
- // An error has occurred when trying to read value witness table,
2171
- // default to treating it as pointer.
2172
- if (!is_inlined.has_value ())
2173
- return Value::ValueType::LoadAddress;
2174
-
2175
- // Inlined data, same as static data.
2176
- if (*is_inlined)
2177
- return static_value_type;
2179
+ if (ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ()) {
2180
+ llvm::Optional<bool > is_inlined =
2181
+ reflection_ctx->IsValueInlinedInExistentialContainer (
2182
+ remote_existential);
2183
+
2184
+ if (use_local_buffer)
2185
+ PopLocalBuffer ();
2186
+
2187
+ // An error has occurred when trying to read value witness table,
2188
+ // default to treating it as pointer.
2189
+ if (!is_inlined.has_value ())
2190
+ return Value::ValueType::LoadAddress;
2191
+
2192
+ // Inlined data, same as static data.
2193
+ if (*is_inlined)
2194
+ return static_value_type;
2195
+ }
2178
2196
2179
2197
// If the data is not inlined, we have a pointer.
2180
2198
return Value::ValueType::LoadAddress;
0 commit comments