加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

使用Swift和lldb设置符号断点

发布时间:2020-12-14 04:37:49 所属栏目:百科 来源:网络整理
导读:在使用 Swift时如何在lldb中设置符号断点?例如,有时我使用: (lldb) b set -F '-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]' 但这不再有效: Breakpoint 2: no locations (pending). WARNING: Unable to resolve breakpoint to any actu
在使用 Swift时如何在lldb中设置符号断点?例如,有时我使用:

(lldb) b set -F '-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]'

但这不再有效:

Breakpoint 2: no locations (pending). WARNING: Unable to resolve
breakpoint to any actual locations.

我也试过了

(lldb) b set -F 'UIView.updateConstraintsIfNeeded()'
(lldb) b set -F 'UIView.updateConstraintsIfNeeded'

但没有爱.我想这个问题归结为lldb在使用Swift时认为是“完全限定的函数名”.文档说:

-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.

斯威夫特怎么样?

解决方法

当lldb为任何更高级的匹配断点(包括-F)设置断点时,它需要知道目标语言,因为它的匹配类型取决于它.默认情况下,lldb选择当前帧的语言,但您可以覆盖它.因此,例如,当您在Swift框架中停止时,要打破ObjC符号,请执行以下操作:

(lldb) break set -F '-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded]' -L objc
Breakpoint 3: where = UIKit`-[UIView(AdditionalLayoutSupport) updateConstraintsIfNeeded],address = 0x0000000100963acc

或者您可以使用-n break选项,该选项不会尝试理解它匹配的符号,而只是在符号名称中对该字符串进行广泛搜索.

注意,在这种情况下,你需要打破ObjC符号,而不是它在Swift中出现的方式,因为快速的一侧实际上只是一个垫片进入objc,并没有真正的快速侧符号可以挂钩.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读