@@ -2161,10 +2161,10 @@ class CommandObjectSwift_RefCount : public CommandObjectRaw {
2161
2161
}
2162
2162
};
2163
2163
2164
- // / Construct a `ThreadTask` instance for a Task variable contained in the first
2165
- // / argument.
2164
+ // / Construct a `ThreadTask` instance for a live (yet to be completed) Task
2165
+ // / variable contained in the first argument.
2166
2166
static llvm::Expected<ThreadSP>
2167
- ThreadForTaskArgument (Args &command, ExecutionContext &exe_ctx) {
2167
+ ThreadForLiveTaskArgument (Args &command, ExecutionContext &exe_ctx) {
2168
2168
if (!exe_ctx.GetFramePtr ())
2169
2169
return llvm::createStringError (" no active frame selected" );
2170
2170
@@ -2196,12 +2196,15 @@ ThreadForTaskArgument(Args &command, ExecutionContext &exe_ctx) {
2196
2196
2197
2197
if (auto *runtime = SwiftLanguageRuntime::Get (exe_ctx.GetProcessSP ()))
2198
2198
if (auto reflection_ctx = runtime->GetReflectionContext ()) {
2199
- if (auto task_info = reflection_ctx->asyncTaskInfo (task_ptr))
2200
- return std::make_shared<ThreadTask>(task_info->id ,
2201
- task_info->resumeAsyncContext ,
2202
- task_info->runJob , exe_ctx);
2203
- else
2199
+ auto task_info = reflection_ctx->asyncTaskInfo (task_ptr);
2200
+ if (!task_info)
2204
2201
return task_info.takeError ();
2202
+ if (task_info->isComplete )
2203
+ return llvm::createStringError (" task has completed" );
2204
+
2205
+ return std::make_shared<ThreadTask>(task_info->id ,
2206
+ task_info->resumeAsyncContext ,
2207
+ task_info->runJob , exe_ctx);
2205
2208
}
2206
2209
2207
2210
return llvm::createStringError (" failed to access Task data from runtime" );
@@ -2230,7 +2233,7 @@ class CommandObjectLanguageSwiftTaskBacktrace final
2230
2233
}
2231
2234
2232
2235
llvm::Expected<ThreadSP> thread_task =
2233
- ThreadForTaskArgument (command, m_exe_ctx);
2236
+ ThreadForLiveTaskArgument (command, m_exe_ctx);
2234
2237
if (auto error = thread_task.takeError ()) {
2235
2238
result.AppendError (toString (std::move (error)));
2236
2239
return ;
@@ -2265,7 +2268,7 @@ class CommandObjectLanguageSwiftTaskSelect final : public CommandObjectParsed {
2265
2268
}
2266
2269
2267
2270
llvm::Expected<ThreadSP> thread_task =
2268
- ThreadForTaskArgument (command, m_exe_ctx);
2271
+ ThreadForLiveTaskArgument (command, m_exe_ctx);
2269
2272
if (auto error = thread_task.takeError ()) {
2270
2273
result.AppendError (toString (std::move (error)));
2271
2274
return ;
0 commit comments