@@ -249,6 +249,8 @@ SwiftLanguageRuntimeImpl::GetMemoryReader() {
249
249
m_process, [&](swift::remote::RemoteAbsolutePointer pointer) {
250
250
ThreadSafeReflectionContext reflection_context =
251
251
GetReflectionContext ();
252
+ if (!reflection_context)
253
+ return pointer;
252
254
return reflection_context->StripSignedPointer (pointer);
253
255
}));
254
256
}
@@ -663,6 +665,9 @@ SwiftLanguageRuntimeImpl::GetNumChildren(CompilerType type,
663
665
return {};
664
666
665
667
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
668
+ if (!reflection_ctx)
669
+ return {};
670
+
666
671
LLDBTypeInfoProvider tip (*this , *ts);
667
672
auto *cti = reflection_ctx->GetClassInstanceTypeInfo (tr, &tip);
668
673
if (auto *rti =
@@ -736,6 +741,9 @@ SwiftLanguageRuntimeImpl::GetNumFields(CompilerType type,
736
741
return 0 ;
737
742
case ReferenceKind::Strong:
738
743
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
744
+ if (!reflection_ctx)
745
+ return {};
746
+
739
747
LLDBTypeInfoProvider tip (*this , *ts);
740
748
auto *cti = reflection_ctx->GetClassInstanceTypeInfo (tr, &tip);
741
749
if (auto *rti = llvm::dyn_cast_or_null<RecordTypeInfo>(cti)) {
@@ -868,6 +876,9 @@ SwiftLanguageRuntimeImpl::GetIndexOfChildMemberWithName(
868
876
child_indexes);
869
877
case ReferenceKind::Strong: {
870
878
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
879
+ if (!reflection_ctx)
880
+ return {false , {}};
881
+
871
882
LLDBTypeInfoProvider tip (*this , *ts);
872
883
// `current_tr` iterates the class hierarchy, from the current class, each
873
884
// superclass, and ends on null.
@@ -1565,6 +1576,9 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Class(
1565
1576
}
1566
1577
Log *log (GetLog (LLDBLog::Types));
1567
1578
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
1579
+ if (!reflection_ctx)
1580
+ return false ;
1581
+
1568
1582
const auto *typeref =
1569
1583
reflection_ctx->ReadTypeFromInstance (instance_ptr, true );
1570
1584
if (!typeref) {
@@ -1717,6 +1731,9 @@ bool SwiftLanguageRuntimeImpl::GetDynamicTypeAndAddress_Protocol(
1717
1731
swift::remote::RemoteAddress remote_existential (existential_address);
1718
1732
1719
1733
ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
1734
+ if (!reflection_ctx)
1735
+ return false ;
1736
+
1720
1737
auto pair = reflection_ctx->ProjectExistentialAndUnwrapClass (
1721
1738
remote_existential, *protocol_typeref);
1722
1739
if (use_local_buffer)
@@ -2108,22 +2125,23 @@ SwiftLanguageRuntimeImpl::GetValueType(ValueObject &in_value,
2108
2125
// Read the value witness table and check if the data is inlined in
2109
2126
// the existential container or not.
2110
2127
swift::remote::RemoteAddress remote_existential (existential_address);
2111
- ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ();
2112
- llvm::Optional<bool > is_inlined =
2113
- reflection_ctx->IsValueInlinedInExistentialContainer (
2114
- remote_existential);
2115
-
2116
- if (use_local_buffer)
2117
- PopLocalBuffer ();
2118
-
2119
- // An error has occurred when trying to read value witness table,
2120
- // default to treating it as pointer.
2121
- if (!is_inlined.has_value ())
2122
- return Value::ValueType::LoadAddress;
2123
-
2124
- // Inlined data, same as static data.
2125
- if (*is_inlined)
2126
- return static_value_type;
2128
+ if (ThreadSafeReflectionContext reflection_ctx = GetReflectionContext ()) {
2129
+ llvm::Optional<bool > is_inlined =
2130
+ reflection_ctx->IsValueInlinedInExistentialContainer (
2131
+ remote_existential);
2132
+
2133
+ if (use_local_buffer)
2134
+ PopLocalBuffer ();
2135
+
2136
+ // An error has occurred when trying to read value witness table,
2137
+ // default to treating it as pointer.
2138
+ if (!is_inlined.has_value ())
2139
+ return Value::ValueType::LoadAddress;
2140
+
2141
+ // Inlined data, same as static data.
2142
+ if (*is_inlined)
2143
+ return static_value_type;
2144
+ }
2127
2145
2128
2146
// If the data is not inlined, we have a pointer.
2129
2147
return Value::ValueType::LoadAddress;
0 commit comments