Skip to content

Commit d57002f

Browse files
Merge pull request #10980 from swiftlang/dl/lldb-Include-suspended-flag-for-Tasks
[lldb] Include "suspended" flag for Tasks
2 parents a48c2c0 + 806ee27 commit d57002f

File tree

8 files changed

+42
-7
lines changed

8 files changed

+42
-7
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -828,6 +828,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
828828
"isEscalated",
829829
"isEnqueued",
830830
"isComplete",
831+
"isSuspended",
831832
"isRunning",
832833
// clang-format on
833834
};
@@ -964,7 +965,9 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
964965
RETURN_CHILD(m_is_enqueued_sp, isEnqueued, bool_type);
965966
case 13:
966967
RETURN_CHILD(m_is_complete_sp, isComplete, bool_type);
967-
case 14: {
968+
case 14:
969+
RETURN_CHILD(m_is_suspended_sp, isSuspended, bool_type);
970+
case 15: {
968971
if (m_task_info.hasIsRunning)
969972
RETURN_CHILD(m_is_running_sp, isRunning, bool_type);
970973
return {};
@@ -996,8 +999,8 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
996999
m_is_child_task_sp, m_is_future_sp, m_is_group_child_task_sp,
9971000
m_is_async_let_task_sp, m_is_cancelled_sp,
9981001
m_is_status_record_locked_sp, m_is_escalated_sp,
999-
m_is_enqueued_sp, m_is_complete_sp, m_parent_task_sp,
1000-
m_child_tasks_sp, m_is_running_sp})
1002+
m_is_enqueued_sp, m_is_complete_sp, m_is_suspended_sp,
1003+
m_parent_task_sp, m_child_tasks_sp, m_is_running_sp})
10011004
child.reset();
10021005
}
10031006
}
@@ -1038,6 +1041,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
10381041
ValueObjectSP m_is_escalated_sp;
10391042
ValueObjectSP m_is_enqueued_sp;
10401043
ValueObjectSP m_is_complete_sp;
1044+
ValueObjectSP m_is_suspended_sp;
10411045
ValueObjectSP m_parent_task_sp;
10421046
ValueObjectSP m_child_tasks_sp;
10431047
ValueObjectSP m_is_running_sp;
@@ -1928,6 +1932,7 @@ bool lldb_private::formatters::swift::TaskPriority_SummaryProvider(
19281932

19291933
static const std::pair<StringRef, StringRef> TASK_FLAGS[] = {
19301934
{"isComplete", "complete"},
1935+
{"isSuspended", "suspended"},
19311936
{"isRunning", "running"},
19321937
{"isCancelled", "cancelled"},
19331938
{"isEscalated", "escalated"},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ class TargetReflectionContext : public ReflectionContextInterface {
428428
result.isRunning = task_info.IsRunning;
429429
result.isEnqueued = task_info.IsEnqueued;
430430
result.isComplete = task_info.IsComplete;
431+
result.isSuspended = task_info.IsSuspended;
431432
result.id = task_info.Id;
432433
result.kind = task_info.Kind;
433434
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
@@ -169,6 +169,7 @@ class ReflectionContextInterface {
169169
bool isRunning = false;
170170
bool isEnqueued = false;
171171
bool isComplete = false;
172+
bool isSuspended = false;
172173
uint64_t id = 0;
173174
uint32_t kind = 0;
174175
uint32_t enqueuePriority = 0;

lldb/test/API/lang/swift/async/formatters/task/TestSwiftTaskSyntheticProvider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ def test_top_level_task(self):
2121
patterns=[
2222
textwrap.dedent(
2323
r"""
24-
\(Task<\(\), Error>\) task = id:([1-9]\d*) flags:(?:running|enqueued) \{
24+
\(Task<\(\), Error>\) task = id:([1-9]\d*) flags:(?:suspended\|)?(?:running|enqueued) \{
2525
address = 0x[0-9a-f]+
2626
id = \1
2727
enqueuePriority = \.medium
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:suspended"])
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
@main struct Main {
2+
static func main() async {
3+
let task = Task {
4+
try? await Task.sleep(for: .seconds(100))
5+
}
6+
try? await Task.sleep(for: .seconds(0.5))
7+
print("break here")
8+
}
9+
}

lldb/test/API/lang/swift/async/taskgroups/TestSwiftTaskGroupSynthetic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,21 @@ def do_test_print(self):
3232
textwrap.dedent(
3333
r"""
3434
\((?:Throwing)?TaskGroup<\(\)\??(?:, Error)?>\) group = \{
35-
\[0\] = id:([1-9]\d*) flags:(?:running\|)?(?:enqueued\|)?groupChildTask \{
35+
\[0\] = id:([1-9]\d*) flags:(?:suspended\|)?(?:running\|)?(?:enqueued\|)?groupChildTask \{
3636
address = 0x[0-9a-f]+
3737
id = \1
3838
enqueuePriority = \.medium
3939
parent = (.+)
4040
children = \{\}
4141
\}
42-
\[1\] = id:([1-9]\d*) flags:(?:running\|)?(?:enqueued\|)?groupChildTask \{
42+
\[1\] = id:([1-9]\d*) flags:(?:suspended\|)?(?:running\|)?(?:enqueued\|)?groupChildTask \{
4343
address = 0x[0-9a-f]+
4444
id = \3
4545
enqueuePriority = \.medium
4646
parent = \2
4747
children = \{\}
4848
\}
49-
\[2\] = id:([1-9]\d*) flags:(?:running\|)?(?:enqueued\|)?groupChildTask \{
49+
\[2\] = id:([1-9]\d*) flags:(?:suspended\|)?(?:running\|)?(?:enqueued\|)?groupChildTask \{
5050
address = 0x[0-9a-f]+
5151
id = \4
5252
enqueuePriority = \.medium

0 commit comments

Comments
 (0)