Skip to content

[lldb] Include "suspended" flag for Tasks #10980

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: swift/release/6.2
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
"isEscalated",
"isEnqueued",
"isComplete",
"isSuspended",
"isRunning",
// clang-format on
};
Expand Down Expand Up @@ -957,7 +958,9 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
RETURN_CHILD(m_is_enqueued_sp, isEnqueued, bool_type);
case 13:
RETURN_CHILD(m_is_complete_sp, isComplete, bool_type);
case 14: {
case 14:
RETURN_CHILD(m_is_suspended_sp, isSuspended, bool_type);
case 15: {
if (m_task_info.hasIsRunning)
RETURN_CHILD(m_is_running_sp, isRunning, bool_type);
return {};
Expand Down Expand Up @@ -990,8 +993,8 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
m_is_child_task_sp, m_is_future_sp, m_is_group_child_task_sp,
m_is_async_let_task_sp, m_is_cancelled_sp,
m_is_status_record_locked_sp, m_is_escalated_sp,
m_is_enqueued_sp, m_is_complete_sp, m_parent_task_sp,
m_child_tasks_sp, m_is_running_sp})
m_is_enqueued_sp, m_is_complete_sp, m_is_suspended_sp,
m_parent_task_sp, m_child_tasks_sp, m_is_running_sp})
child.reset();
}
}
Expand Down Expand Up @@ -1027,6 +1030,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
ValueObjectSP m_is_escalated_sp;
ValueObjectSP m_is_enqueued_sp;
ValueObjectSP m_is_complete_sp;
ValueObjectSP m_is_suspended_sp;
ValueObjectSP m_parent_task_sp;
ValueObjectSP m_child_tasks_sp;
ValueObjectSP m_is_running_sp;
Expand Down Expand Up @@ -1917,6 +1921,7 @@ bool lldb_private::formatters::swift::TaskPriority_SummaryProvider(

static const std::pair<StringRef, StringRef> TASK_FLAGS[] = {
{"isComplete", "complete"},
{"isSuspended", "suspended"},
{"isRunning", "running"},
{"isCancelled", "cancelled"},
{"isEscalated", "escalated"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,7 @@ class TargetReflectionContext : public ReflectionContextInterface {
result.isRunning = task_info.IsRunning;
result.isEnqueued = task_info.IsEnqueued;
result.isComplete = task_info.IsComplete;
result.isSuspended = task_info.IsSuspended;
result.id = task_info.Id;
result.kind = task_info.Kind;
result.enqueuePriority = task_info.EnqueuePriority;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class ReflectionContextInterface {
bool isRunning = false;
bool isEnqueued = false;
bool isComplete = false;
bool isSuspended = false;
uint64_t id = 0;
uint32_t kind = 0;
uint32_t enqueuePriority = 0;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SWIFT_SOURCES := main.swift
SWIFTFLAGS_EXTRAS := -parse-as-library
include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import textwrap
import lldb
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
from lldbsuite.test import lldbutil


class TestCase(TestBase):

@swiftTest
def test(self):
self.build()
lldbutil.run_to_source_breakpoint(
self, "break here", lldb.SBFileSpec("main.swift")
)
self.expect("v task", substrs=["flags:suspended"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
@main struct Main {
static func main() async {
let task = Task {
try? await Task.sleep(for: .seconds(100))
}
try? await Task.sleep(for: .seconds(0.5))
print("break here")
}
}