forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 341
[lldb] Support breakpoints on specific property accessor blocks #8546
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
adrian-prantl
merged 5 commits into
swift/release/6.0
from
dl/lldb-Support-breakpoints-on-specific-property-accessor-blocks
Apr 15, 2024
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0bfcd54
[lldb] Support breakpoints on specific property accessor blocks
kastiglione 3d18cab
Add tests
kastiglione 953b22e
fix typo
kastiglione 2c621a1
Test false positives
kastiglione 0f35b80
Follow swift test naming convention; add test method docstring
kastiglione File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
lldb/test/API/functionalities/breakpoint/swift_property_accessors/Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
|
||
SWIFT_SOURCES := main.swift | ||
|
||
include Makefile.rules |
28 changes: 28 additions & 0 deletions
28
...nctionalities/breakpoint/swift_property_accessors/TestSwiftPropertyAccessorBreakpoints.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import lldb | ||
from lldbsuite.test.lldbtest import * | ||
from lldbsuite.test.decorators import * | ||
|
||
|
||
class TestCase(TestBase): | ||
@swiftTest | ||
def test(self): | ||
"""Test that a breakpoint on a property accessor can be set by name.""" | ||
self.build() | ||
exe = self.getBuildArtifact("a.out") | ||
target = self.dbg.CreateTarget(exe) | ||
for name in ( | ||
"read_only.get", | ||
"read_write.get", | ||
"read_write.set", | ||
"observed.willset", | ||
"observed.didset", | ||
): | ||
bp = target.BreakpointCreateByName(name, "a.out") | ||
self.assertEqual(bp.num_locations, 1, f"{name} breakpoint failed") | ||
|
||
# Setting a breakpoint on the name "get" should not create a breakpoint | ||
# matching property getters. The other accerssor suffixes should also | ||
# not succeed as bare names. | ||
for name in ("get", "set", "willset", "didset"): | ||
bp = target.BreakpointCreateByName(name, "a.out") | ||
self.assertEqual(bp.num_locations, 0, f"{name} breakpoint unexpected") |
13 changes: 13 additions & 0 deletions
13
lldb/test/API/functionalities/breakpoint/swift_property_accessors/main.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
struct Thing { | ||
var read_only: Int { 22 + 15 } | ||
|
||
var read_write: Int { | ||
get { 23 + 41 } | ||
set { print("nothing") } | ||
} | ||
|
||
var observed: Int { | ||
willSet { print("willSet") } | ||
didSet { print("didSet") } | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is accessor "block" a term of art? I would have expected this to be called an "accessor method" or just an "accessor".
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the documentation of the swift grammar calls them blocks, see "variable-declaration" in https://docs.swift.org/swift-book/documentation/the-swift-programming-language/summaryofthegrammar#Declarations
I'm fine with removing the word block though.