Skip to content

[lldb][swift] Disable breakpoint filtering by default #10826

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
2 changes: 1 addition & 1 deletion lldb/source/Target/TargetProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,6 @@ let Definition = "thread" in {

let Definition = "language" in {
def EnableFilterForLineBreakpoints: Property<"enable-filter-for-line-breakpoints", "Boolean">,
DefaultTrue,
DefaultFalse,
Desc<"If true, allow Language plugins to filter locations when setting breakpoints by line number or regex.">;
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TestCase(lldbtest.TestBase):
def test(self):
"""Test step-in to async functions"""
self.build()
self.runCmd("settings set language.enable-filter-for-line-breakpoints true")
src = lldb.SBFileSpec('main.swift')
_, process, _, _ = lldbutil.run_to_source_breakpoint(self, 'await', src)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test(self):
target, process, thread, bkpt = lldbutil.run_to_source_breakpoint(
self, "BREAK HERE", source_file
)
bkpt.SetEnabled(False) # avoid hitting multiple locations in async breakpoints

expected_line_nums = [4] # print(x)
expected_line_nums += [5, 6, 7, 5, 6, 7, 5] # two runs over the loop
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def test(self):
self.build()
target, process, thread, main_bkpt = lldbutil.run_to_source_breakpoint(
self, 'main breakpoint', self.src)
main_bkpt.SetEnabled(False) # avoid hitting multiple locations in async breakpoints
self.run_fibo_tests(target, process)

@swiftTest
Expand All @@ -34,6 +35,7 @@ def test_actor(self):
self.build()
target, process, thread, main_bkpt = lldbutil.run_to_source_breakpoint(
self, 'main actor breakpoint', self.src)
main_bkpt.SetEnabled(False) # avoid hitting multiple locations in async breakpoints
self.run_fibo_tests(target, process)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ func ASYNC___5___() async -> Int {

@main struct Main {
static func main() async {
let result = await ASYNC___5___() // BREAK HERE
print("BREAK HERE")
let result = await ASYNC___5___()
print(result)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ class TestSwiftAsyncBreakpoints(lldbtest.TestBase):
def test(self):
"""Test async breakpoints"""
self.build()
self.runCmd("settings set language.enable-filter-for-line-breakpoints true")
filespec = lldb.SBFileSpec("main.swift")
target, process, thread, breakpoint1 = lldbutil.run_to_source_breakpoint(
self, "Breakpoint1", filespec
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
SWIFT_SOURCES := main.swift

include Makefile.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import lldb
from lldbsuite.test.decorators import *
import lldbsuite.test.lldbtest as lldbtest
import lldbsuite.test.lldbutil as lldbutil


class TestSwiftAsyncBreakpoints(lldbtest.TestBase):
@swiftTest
@skipIfLinux
def test(self):
"""Test async that async breakpoints are not filtered when the same
statement is present across multiple funclets"""
self.build()
filespec = lldb.SBFileSpec("main.swift")
target, process, thread, breakpoint1 = lldbutil.run_to_source_breakpoint(
self, "breakpoint_start", filespec
)
breakpoint = target.BreakpointCreateBySourceRegex("breakhere", filespec)
self.assertEquals(breakpoint.GetNumLocations(), 2)

process.Continue()
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonBreakpoint)
self.assertEquals(thread.GetStopDescription(128), "breakpoint 2.1")
self.expect("expr argument", substrs=["1"])

process.Continue()
self.assertStopReason(thread.GetStopReason(), lldb.eStopReasonBreakpoint)
self.assertEquals(thread.GetStopDescription(128), "breakpoint 2.2")
self.expect("expr argument", substrs=["2"])
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
enum MyError: Error {
case MyError1
case MyError2
}

func willthrow(_ arg: Int) async throws {
if arg == 1 { throw MyError.MyError1 } else { throw MyError.MyError2 }
}

func foo(_ argument: Int) async {
do {
switch argument {
case 1:
try await willthrow(1)
case 2:
try await willthrow(2)
default:
return
}
} catch {
print("breakhere")
}
}

print("breakpoint_start")
await foo(1)
await foo(2)
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def test_step_in_and_out(self):
self, "break here", lldb.SBFileSpec("main.swift")
)

# First, get to the await call.
thread.StepOver()

thread.StepInto()
stop_reason = thread.GetStopReason()
self.assertStopReason(stop_reason, lldb.eStopReasonPlanComplete)
Expand All @@ -48,11 +51,14 @@ def test_step_over(self):
self, "break here", lldb.SBFileSpec("main.swift")
)

# First, get to the await call.
thread.StepOver()

thread.StepOver()
stop_reason = thread.GetStopReason()
self.assertStopReason(stop_reason, lldb.eStopReasonPlanComplete)
frame0 = thread.frames[0]
self.assertIn("doMath", frame0.GetFunctionName())

line_entry = frame0.GetLineEntry()
self.assertEqual(14, line_entry.GetLine())
self.assertEqual(15, line_entry.GetLine())
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class SlowRandomNumberGenerator: RandomNumberGenerator {
}

func doMath<RNG: RandomNumberGenerator>(with rng: RNG) async {
let y = await rng.random(in: 101...200) // break here
print("break here")
let y = await rng.random(in: 101...200)
print("Y is \(y)")
}

Expand Down