How does one set a symbolic breakpoint in lldb when using Swift? For example, sometimes I use:
(lldb) b set -F '-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]'
But this no longer works:
Breakpoint 2: no locations (pending). WARNING: Unable to resolve breakpoint to any actual locations.
I've also tried
(lldb) b set -F 'UIView.updateConstraintsIfNeeded()'
(lldb) b set -F 'UIView.updateConstraintsIfNeeded'
But no love. I guess the question comes down to what lldb considers a "fully qualified function name" when using Swift. The docs say:
-F ( --fullname )
Set the breakpoint by fully qualified function names. For C++ this means namespaces and all arguments, and for Objective C this means a full function prototype with class and selector. Can be repeated multiple times to make one breakpoint for multiple names.
What about Swift?
When lldb is setting breakpoints any of the fancier matching breakpoints (including -F), it needs to know the target language since the kinds of matching it does depends on that. By default, lldb chooses the language of the current frame, but you can override that. So for instance to break on an ObjC symbol when you are stopped in a Swift frame, do:
(lldb) break set -F '-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]' -L objc
Breakpoint 3: where = UIKit`-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded], address = 0x0000000100963acc
Or you can use the -n
break option, which doesn't try to understand the symbols it matches, but just does a wide search for that string in the symbol names.
Note, in this case you need to break on the ObjC symbol not the way it appears in Swift, because the swift side is really just a shim into objc, and there isn't really a swift side symbol to hook onto.
In the lldb console, you can give a partial name and get automatic lookup using regex:
br set -r updateConstraintsIfNeeded\]
The result is:
Breakpoint 4: where = UIKit`-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]
In current versions of Xcode, you can also use a partial name in the "add a symbolic breakpoint" UI, because there is now code completion to assist you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With