Skip to content

[lldb] Create "task" alias for "language swift task" #10275

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 4 commits into
base: stable/20240723
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
6 changes: 6 additions & 0 deletions lldb/source/Interpreter/CommandInterpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,12 @@ void CommandInterpreter::Initialize() {
#endif
}

#ifdef LLDB_ENABLE_SWIFT
cmd_obj_sp = GetCommandSPExact("language swift task");
if (cmd_obj_sp)
AddAlias("task", cmd_obj_sp);
#endif

cmd_obj_sp = GetCommandSPExact("platform shell");
if (cmd_obj_sp) {
CommandAlias *shell_alias = AddAlias("shell", cmd_obj_sp, " --host --");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ def test_abbrevs2(self):
("disp", "_regexp-display"), # a.k.a., 'display'
("di", "disassemble"),
("dis", "disassemble"),
("ta st a", "target stop-hook add"),
("tar st a", "target stop-hook add"),
("fr v", "frame variable"),
("f 1", "frame select 1"),
("ta st li", "target stop-hook list"),
("tar st li", "target stop-hook list"),
]

for short_val, long_val in abbrevs:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def test_backtrace_task_address(self):

def do_backtrace(self, arg):
self.expect(
f"language swift task backtrace {arg}",
f"task backtrace {arg}",
substrs=[
".sleep(",
"`second() at main.swift:6",
Expand Down
4 changes: 2 additions & 2 deletions lldb/test/API/lang/swift/async/tasks/TestSwiftTaskSelect.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_backtrace_selected_task_address(self):
self.do_backtrace_selected_task(task_addr)

def do_backtrace_selected_task(self, arg):
self.runCmd(f"language swift task select {arg}")
self.runCmd(f"task select {arg}")
self.expect(
"thread backtrace",
substrs=[
Expand Down Expand Up @@ -53,7 +53,7 @@ def test_navigate_stack_of_selected_task_address(self):
self.do_test_navigate_selected_task_stack(process, task_addr)

def do_test_navigate_selected_task_stack(self, process, arg):
self.runCmd(f"language swift task select {arg}")
self.runCmd(f"task select {arg}")
thread = process.GetSelectedThread()

self.assertIn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def test_compare_printed_task_variable_to_task_info(self):
)
self.runCmd("frame variable task")
frame_variable_output = self.res.GetOutput()
self.runCmd("language swift task info")
self.runCmd("task info")
task_info_output = self.res.GetOutput()
self.assertEqual(_tail(task_info_output), _tail(frame_variable_output))

Expand All @@ -41,6 +41,6 @@ def test_compare_printed_task_variable_to_task_info_with_address(self):

self.runCmd("frame variable task")
frame_variable_output = self.res.GetOutput()
self.runCmd(f"language swift task info {task_addr}")
self.runCmd(f"task info {task_addr}")
task_info_output = self.res.GetOutput()
self.assertEqual(_tail(task_info_output), _tail(frame_variable_output))
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,15 @@ def test_dwarf_importer(self):
lldbutil.check_variable(self,
target.FindFirstGlobalVariable("point"),
typename='bridging-header.h.Point', num_children=2)
self.expect("ta v -d no-dyn point", substrs=["x = 1", "y = 2"])
self.expect("ta v -d no-dyn swiftStructCMember",
substrs=[
# FIXME: This doesn't even work with the original bridging header!
#"point", "x = 3", "y = 4",
"swift struct c member"])
self.expect("tar v -d no-dyn point", substrs=["x = 1", "y = 2"])
self.expect(
"tar v -d no-dyn swiftStructCMember",
substrs=[
# FIXME: This doesn't even work with the original bridging header!
# "point", "x = 3", "y = 4",
"swift struct c member"
],
)
process.Clear()
target.Clear()
lldb.SBDebugger.MemoryPressureDetected()
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def test(self):
if self.TraceOn():
self.runCmd("f")
self.runCmd("bt")
self.runCmd("ta v global")
self.runCmd("tar v global")

self.assertEqual(
process.GetSelectedThread().GetStopReason(), lldb.eStopReasonException
Expand All @@ -46,7 +46,7 @@ def test(self):
if self.TraceOn():
self.runCmd("f")
self.runCmd("bt")
self.runCmd("ta v global")
self.runCmd("tar v global")

self.assertEqual(
process.GetSelectedThread().GetStopReason(), lldb.eStopReasonException
Expand All @@ -61,7 +61,7 @@ def test(self):
if self.TraceOn():
self.runCmd("f")
self.runCmd("bt")
self.runCmd("ta v global")
self.runCmd("tar v global")

self.assertEqual(
process.GetSelectedThread().GetStopReason(), lldb.eStopReasonException
Expand Down