Skip to content

Commit 8c09a32

Browse files
authored
[lldb] Add complete flag to Swift Task summary formatter (#10311)
Update the Task summary formatter to indicate when a task is complete. rdar://147448235
1 parent 39a1a9e commit 8c09a32

File tree

6 files changed

+36
-2
lines changed

6 files changed

+36
-2
lines changed

lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
794794
"isStatusRecordLocked",
795795
"isEscalated",
796796
"isEnqueued",
797+
"isComplete",
797798
"isRunning",
798799
// clang-format on
799800
};
@@ -881,7 +882,9 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
881882
RETURN_CHILD(m_is_escalated_sp, isEscalated, bool_type);
882883
case 11:
883884
RETURN_CHILD(m_is_enqueued_sp, isEnqueued, bool_type);
884-
case 12: {
885+
case 12:
886+
RETURN_CHILD(m_is_complete_sp, isComplete, bool_type);
887+
case 13: {
885888
if (m_task_info.hasIsRunning)
886889
RETURN_CHILD(m_is_running_sp, isRunning, bool_type);
887890
return {};
@@ -915,7 +918,8 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
915918
m_is_child_task_sp, m_is_future_sp, m_is_group_child_task_sp,
916919
m_is_async_let_task_sp, m_is_cancelled_sp,
917920
m_is_status_record_locked_sp, m_is_escalated_sp,
918-
m_is_enqueued_sp, m_child_tasks_sp, m_is_running_sp})
921+
m_is_enqueued_sp, m_is_complete_sp, m_child_tasks_sp,
922+
m_is_running_sp})
919923
child.reset();
920924
}
921925
}
@@ -978,6 +982,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
978982
ValueObjectSP m_is_status_record_locked_sp;
979983
ValueObjectSP m_is_escalated_sp;
980984
ValueObjectSP m_is_enqueued_sp;
985+
ValueObjectSP m_is_complete_sp;
981986
ValueObjectSP m_child_tasks_sp;
982987
ValueObjectSP m_is_running_sp;
983988
};
@@ -1647,6 +1652,7 @@ bool lldb_private::formatters::swift::TaskPriority_SummaryProvider(
16471652
}
16481653

16491654
static const std::pair<StringRef, StringRef> TASK_FLAGS[] = {
1655+
{"isComplete", "complete"},
16501656
{"isRunning", "running"},
16511657
{"isCancelled", "cancelled"},
16521658
{"isEscalated", "escalated"},

lldb/source/Plugins/LanguageRuntime/Swift/ReflectionContext.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,7 @@ class TargetReflectionContext : public ReflectionContextInterface {
409409
result.hasIsRunning = task_info.HasIsRunning;
410410
result.isRunning = task_info.IsRunning;
411411
result.isEnqueued = task_info.IsEnqueued;
412+
result.isComplete = task_info.IsComplete;
412413
result.id = task_info.Id;
413414
result.kind = task_info.Kind;
414415
result.enqueuePriority = task_info.EnqueuePriority;

lldb/source/Plugins/LanguageRuntime/Swift/ReflectionContextInterface.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ class ReflectionContextInterface {
168168
bool hasIsRunning = false;
169169
bool isRunning = false;
170170
bool isEnqueued = false;
171+
bool isComplete = false;
171172
uint64_t id = 0;
172173
uint32_t kind = 0;
173174
uint32_t enqueuePriority = 0;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
SWIFT_SOURCES := main.swift
2+
SWIFTFLAGS_EXTRAS := -parse-as-library
3+
include Makefile.rules
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import textwrap
2+
import lldb
3+
from lldbsuite.test.decorators import *
4+
from lldbsuite.test.lldbtest import *
5+
from lldbsuite.test import lldbutil
6+
7+
8+
class TestCase(TestBase):
9+
10+
@swiftTest
11+
def test(self):
12+
self.build()
13+
lldbutil.run_to_source_breakpoint(
14+
self, "break here", lldb.SBFileSpec("main.swift")
15+
)
16+
self.expect("v task", substrs=["flags:complete"])
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
@main struct Main {
2+
static func main() async {
3+
let task = Task { return 15 }
4+
_ = await task.value
5+
print("break here")
6+
}
7+
}

0 commit comments

Comments
 (0)