Skip to content

Commit 4887626

Browse files
committed
[lldb] Include "suspended" flag for Tasks
1 parent 8b8af30 commit 4887626

File tree

6 files changed

+38
-3
lines changed

6 files changed

+38
-3
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,6 +824,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
824824
"isEscalated",
825825
"isEnqueued",
826826
"isComplete",
827+
"isSuspended",
827828
"isRunning",
828829
// clang-format on
829830
};
@@ -957,7 +958,9 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
957958
RETURN_CHILD(m_is_enqueued_sp, isEnqueued, bool_type);
958959
case 13:
959960
RETURN_CHILD(m_is_complete_sp, isComplete, bool_type);
960-
case 14: {
961+
case 14:
962+
RETURN_CHILD(m_is_suspended_sp, isSuspended, bool_type);
963+
case 15: {
961964
if (m_task_info.hasIsRunning)
962965
RETURN_CHILD(m_is_running_sp, isRunning, bool_type);
963966
return {};
@@ -990,8 +993,8 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
990993
m_is_child_task_sp, m_is_future_sp, m_is_group_child_task_sp,
991994
m_is_async_let_task_sp, m_is_cancelled_sp,
992995
m_is_status_record_locked_sp, m_is_escalated_sp,
993-
m_is_enqueued_sp, m_is_complete_sp, m_parent_task_sp,
994-
m_child_tasks_sp, m_is_running_sp})
996+
m_is_enqueued_sp, m_is_complete_sp, m_is_suspended_sp,
997+
m_parent_task_sp, m_child_tasks_sp, m_is_running_sp})
995998
child.reset();
996999
}
9971000
}
@@ -1027,6 +1030,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
10271030
ValueObjectSP m_is_escalated_sp;
10281031
ValueObjectSP m_is_enqueued_sp;
10291032
ValueObjectSP m_is_complete_sp;
1033+
ValueObjectSP m_is_suspended_sp;
10301034
ValueObjectSP m_parent_task_sp;
10311035
ValueObjectSP m_child_tasks_sp;
10321036
ValueObjectSP m_is_running_sp;
@@ -1917,6 +1921,7 @@ bool lldb_private::formatters::swift::TaskPriority_SummaryProvider(
19171921

19181922
static const std::pair<StringRef, StringRef> TASK_FLAGS[] = {
19191923
{"isComplete", "complete"},
1924+
{"isSuspended", "suspended"},
19201925
{"isRunning", "running"},
19211926
{"isCancelled", "cancelled"},
19221927
{"isEscalated", "escalated"},

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,7 @@ class TargetReflectionContext : public ReflectionContextInterface {
415415
result.isRunning = task_info.IsRunning;
416416
result.isEnqueued = task_info.IsEnqueued;
417417
result.isComplete = task_info.IsComplete;
418+
result.isSuspended = task_info.IsSuspended;
418419
result.id = task_info.Id;
419420
result.kind = task_info.Kind;
420421
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;
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+
}

0 commit comments

Comments
 (0)