@@ -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
}
@@ -653,6 +655,9 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
653
655
return {};
654
656
655
657
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
658
+ if (!reflection_ctx)
659
+ return {};
660
+
656
661
LLDBTypeInfoProvider tip (*this , *ts);
657
662
auto *cti = reflection_ctx->GetClassInstanceTypeInfo (
658
663
tr, &tip, ts->GetDescriptorFinder ());
@@ -728,6 +733,9 @@ SwiftLanguageRuntimeImpl::GetNumFields(CompilerType type,
728
733
return 0 ;
729
734
case ReferenceKind::Strong:
730
735
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
736
+ if (!reflection_ctx)
737
+ return {};
738
+
731
739
LLDBTypeInfoProvider tip (*this , *ts);
732
740
auto *cti = reflection_ctx->GetClassInstanceTypeInfo (
733
741
tr, &tip, ts->GetDescriptorFinder ());
@@ -861,6 +869,9 @@ SwiftLanguageRuntimeImpl::GetIndexOfChildMemberWithName(
861
869
child_indexes);
862
870
case ReferenceKind::Strong: {
863
871
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
872
+ if (!reflection_ctx)
873
+ return {false , {}};
874
+
864
875
LLDBTypeInfoProvider tip (*this , *ts);
865
876
// `current_tr` iterates the class hierarchy, from the current class, each
866
877
// superclass, and ends on null.
@@ -1721,6 +1732,9 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
1721
1732
swift::remote::RemoteAddress remote_existential (existential_address);
1722
1733
1723
1734
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
1735
+ if (!reflection_ctx)
1736
+ return false ;
1737
+
1724
1738
auto pair = reflection_ctx->ProjectExistentialAndUnwrapClass (
1725
1739
remote_existential, *protocol_typeref,
1726
1740
tss->GetTypeSystemSwiftTypeRef ().GetDescriptorFinder ());
@@ -2184,22 +2198,23 @@ SwiftLanguageRuntimeImpl::GetValueType(ValueObject &in_value,
2184
2198
// Read the value witness table and check if the data is inlined in
2185
2199
// the existential container or not.
2186
2200
swift::remote::RemoteAddress remote_existential (existential_address);
2187
- ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
2188
- llvm::Optional<bool > is_inlined =
2189
- reflection_ctx->IsValueInlinedInExistentialContainer (
2190
- remote_existential);
2191
-
2192
- if (use_local_buffer)
2193
- PopLocalBuffer ();
2194
-
2195
- // An error has occurred when trying to read value witness table,
2196
- // default to treating it as pointer.
2197
- if (!is_inlined.has_value ())
2198
- return Value::ValueType::LoadAddress;
2199
-
2200
- // Inlined data, same as static data.
2201
- if (*is_inlined)
2202
- return static_value_type;
2201
+ if (ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ()) {
2202
+ llvm::Optional<bool > is_inlined =
2203
+ reflection_ctx->IsValueInlinedInExistentialContainer (
2204
+ remote_existential);
2205
+
2206
+ if (use_local_buffer)
2207
+ PopLocalBuffer ();
2208
+
2209
+ // An error has occurred when trying to read value witness table,
2210
+ // default to treating it as pointer.
2211
+ if (!is_inlined.has_value ())
2212
+ return Value::ValueType::LoadAddress;
2213
+
2214
+ // Inlined data, same as static data.
2215
+ if (*is_inlined)
2216
+ return static_value_type;
2217
+ }
2203
2218
2204
2219
// If the data is not inlined, we have a pointer.
2205
2220
return Value::ValueType::LoadAddress;
0 commit comments