Skip to content

Commit 0bfcd54

Browse files
committed
[lldb] Support breakpoints on specific property accessor blocks
1 parent 48a1f0f commit 0bfcd54

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

lldb/source/Plugins/Language/Swift/SwiftLanguage.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,25 @@ SwiftLanguage::GetMethodNameVariants(ConstString method_name) const {
138138
if (method_name.GetMangledCounterpart(counterpart))
139139
if (SwiftLanguageRuntime::IsSwiftMangledName(counterpart.GetStringRef()))
140140
variant_names.emplace_back(counterpart, eFunctionNameTypeFull);
141+
142+
// Properties can have multiple accessor blocks. This section of code supports
143+
// breakpoints on accessor blocks by name.
144+
//
145+
// By default, the name `A.B` is treated as a fully qualified name, where `B`
146+
// is the basename. However, some names can be interpretted in two ways, for
147+
// example `A.get`. First, it can refer to the name `get` (in module `A`, or
148+
// in type `A`). Second, it can refer the *getter* block for property `A`.
149+
// LLDB's baseline behavior handles the first case. The second case is
150+
// produced here as a variant name.
151+
for (StringRef suffix : {".get", ".set", ".willSet", ".didSet"})
152+
if (method_name.GetStringRef().ends_with(suffix)) {
153+
// The method name, complete with suffix, *is* the variant.
154+
variant_names.emplace_back(method_name, eFunctionNameTypeFull |
155+
eFunctionNameTypeBase |
156+
eFunctionNameTypeMethod);
157+
break;
158+
}
159+
141160
return variant_names;
142161
}
143162

0 commit comments

Comments
 (0)