gpt4 book ai didi

swift - 使用 Swift 和 lldb 设置符号断点

转载 作者:搜寻专家 更新时间:2023-10-31 08:25:23 25 4
gpt4 key购买 nike

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

swift 呢?

最佳答案

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

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

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

请注意,在这种情况下,您需要打破 ObjC 符号而不是它在 Swift 中出现的方式,因为 swift 侧实际上只是 objc 的垫片,并没有真正的 swift 侧符号可以 Hook 。

关于swift - 使用 Swift 和 lldb 设置符号断点,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39858180/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com