@@ -917,14 +917,15 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
917
917
// Remove any bogus child tasks.
918
918
// Very rarely, the child tasks include a bogus task which has an
919
919
// 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
+ });
928
929
929
930
std::string mangled_typename =
930
931
mangledTypenameForTasksTuple (tasks.size ());
@@ -970,15 +971,14 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
970
971
}
971
972
972
973
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 ()) {
975
975
ValueObjectSP task_obj_sp = m_backend.GetChildMemberWithName (" _task" );
976
976
if (!task_obj_sp)
977
977
return ChildCacheState::eRefetch;
978
978
m_task_ptr = task_obj_sp->GetValueAsUnsigned (LLDB_INVALID_ADDRESS);
979
979
if (m_task_ptr != LLDB_INVALID_ADDRESS) {
980
980
llvm::Expected<ReflectionContextInterface::AsyncTaskInfo> task_info =
981
- m_reflection_ctx ->asyncTaskInfo (m_task_ptr);
981
+ reflection_ctx ->asyncTaskInfo (m_task_ptr);
982
982
if (auto err = task_info.takeError ()) {
983
983
LLDB_LOG_ERROR (
984
984
GetLog (LLDBLog::DataFormatters | LLDBLog::Types), std::move (err),
@@ -1010,7 +1010,12 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
1010
1010
}
1011
1011
1012
1012
private:
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
+
1014
1019
TypeSystemSwiftTypeRef *m_ts = nullptr ;
1015
1020
addr_t m_task_ptr = LLDB_INVALID_ADDRESS;
1016
1021
ReflectionContextInterface::AsyncTaskInfo m_task_info;
0 commit comments