Skip to content

[lldb] Add complete flag to Swift Task summary formatter #10311

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

Merged
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
10 changes: 8 additions & 2 deletions lldb/source/Plugins/Language/Swift/SwiftFormatters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
"isStatusRecordLocked",
"isEscalated",
"isEnqueued",
"isComplete",
"isRunning",
// clang-format on
};
Expand Down Expand Up @@ -881,7 +882,9 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
RETURN_CHILD(m_is_escalated_sp, isEscalated, bool_type);
case 11:
RETURN_CHILD(m_is_enqueued_sp, isEnqueued, bool_type);
case 12: {
case 12:
RETURN_CHILD(m_is_complete_sp, isComplete, bool_type);
case 13: {
if (m_task_info.hasIsRunning)
RETURN_CHILD(m_is_running_sp, isRunning, bool_type);
return {};
Expand Down Expand Up @@ -915,7 +918,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_child_tasks_sp, m_is_running_sp})
m_is_enqueued_sp, m_is_complete_sp, m_child_tasks_sp,
m_is_running_sp})
child.reset();
}
}
Expand Down Expand Up @@ -978,6 +982,7 @@ class TaskSyntheticFrontEnd : public SyntheticChildrenFrontEnd {
ValueObjectSP m_is_status_record_locked_sp;
ValueObjectSP m_is_escalated_sp;
ValueObjectSP m_is_enqueued_sp;
ValueObjectSP m_is_complete_sp;
ValueObjectSP m_child_tasks_sp;
ValueObjectSP m_is_running_sp;
};
Expand Down Expand Up @@ -1647,6 +1652,7 @@ bool lldb_private::formatters::swift::TaskPriority_SummaryProvider(
}

static const std::pair<StringRef, StringRef> TASK_FLAGS[] = {
{"isComplete", "complete"},
{"isRunning", "running"},
{"isCancelled", "cancelled"},
{"isEscalated", "escalated"},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ class TargetReflectionContext : public ReflectionContextInterface {
result.hasIsRunning = task_info.HasIsRunning;
result.isRunning = task_info.IsRunning;
result.isEnqueued = task_info.IsEnqueued;
result.isComplete = task_info.IsComplete;
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 @@ -168,6 +168,7 @@ class ReflectionContextInterface {
bool hasIsRunning = false;
bool isRunning = false;
bool isEnqueued = false;
bool isComplete = 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:complete"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@main struct Main {
static func main() async {
let task = Task { return 15 }
_ = await task.value
print("break here")
}
}