@@ -917,14 +917,15 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
917917 // Remove any bogus child tasks.
918918 // Very rarely, the child tasks include a bogus task which has an
919919 // invalid task id of 0.
920- llvm::erase_if (tasks, [&](auto task_ptr) {
921- if (auto task_info =
922- expectedToOptional (m_reflection_ctx->asyncTaskInfo (task_ptr)))
923- return task_info->id == 0 ;
924- // Don't filter children with errors here. Let these tasks reach the
925- // formatter's existing error handling.
926- return false ;
927- });
920+ if (auto reflection_ctx = GetReflectionContext ())
921+ llvm::erase_if (tasks, [&](auto task_ptr) {
922+ if (auto task_info =
923+ expectedToOptional (reflection_ctx->asyncTaskInfo (task_ptr)))
924+ return task_info->id == 0 ;
925+ // Don't filter children with errors here. Let these tasks reach the
926+ // formatter's existing error handling.
927+ return false ;
928+ });
928929
929930 std::string mangled_typename =
930931 mangledTypenameForTasksTuple (tasks.size ());
@@ -970,15 +971,14 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
970971 }
971972
972973 lldb::ChildCacheState Update () override {
973- if (auto *runtime = SwiftLanguageRuntime::Get (m_backend.GetProcessSP ())) {
974- m_reflection_ctx = runtime->GetReflectionContext ();
974+ if (auto reflection_ctx = GetReflectionContext ()) {
975975 ValueObjectSP task_obj_sp = m_backend.GetChildMemberWithName (" _task" );
976976 if (!task_obj_sp)
977977 return ChildCacheState::eRefetch;
978978 m_task_ptr = task_obj_sp->GetValueAsUnsigned (LLDB_INVALID_ADDRESS);
979979 if (m_task_ptr != LLDB_INVALID_ADDRESS) {
980980 llvm::Expected<ReflectionContextInterface::AsyncTaskInfo> task_info =
981- m_reflection_ctx ->asyncTaskInfo (m_task_ptr);
981+ reflection_ctx ->asyncTaskInfo (m_task_ptr);
982982 if (auto err = task_info.takeError ()) {
983983 LLDB_LOG_ERROR (
984984 GetLog (LLDBLog::DataFormatters | LLDBLog::Types), std::move (err),
@@ -1010,7 +1010,12 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
10101010 }
10111011
10121012private:
1013- ThreadSafeReflectionContext m_reflection_ctx;
1013+ ThreadSafeReflectionContext GetReflectionContext () {
1014+ if (auto *runtime = SwiftLanguageRuntime::Get (m_backend.GetProcessSP ()))
1015+ return runtime->GetReflectionContext ();
1016+ return {};
1017+ }
1018+
10141019 TypeSystemSwiftTypeRef *m_ts = nullptr ;
10151020 addr_t m_task_ptr = LLDB_INVALID_ADDRESS;
10161021 ReflectionContextInterface::AsyncTaskInfo m_task_info;
0 commit comments