Ray*_*Fix 4 debugging xcode objective-c lldb
我在我的代码中停在(lldb)提示符的断点处.我可以在控制台上发送消息对象并打印它们的值.
(lldb) p [self computePI]
(float) $1 = 3.0
Run Code Online (Sandbox Code Playgroud)
哇!这一点出了点问题.我希望能够进入computePI作为确定哪些变量搞砸的捷径.但是,如果我在该选择器上放置一个断点并再试一次,我得到:
(lldb) p [self computePI]
error: Execution was interrupted, reason: breakpoint 5.1.
The process has been returned to the state before execution.
Run Code Online (Sandbox Code Playgroud)
如果我能够以某种方式进入computePI,那将是一个真正的节省时间.这可能吗?我一直在看http://lldb.llvm.org并没有看到任何东西.谢谢你的帮助.
更新: 根据Jason Molenda的回答,我使用以下方便的别名更新了我的〜/ .lldbinit文件:
command alias nup expr -u 0 --
command alias nupo expr -u 0 -o --
Run Code Online (Sandbox Code Playgroud)
这让我用nup(代替p)和nupo(代替po).
该p命令实际上是别名expr --.其中一个选项expr是- -u或者--unwind-on-error- 在这种情况下断点被视为"错误"(可能被认为是一个错误本身 - 它是有争议的,有一些用例,这对于这种行为是非直观的.)
无论如何,你应该能够做到
(lldb) expr -u false -- [self computePI]
Run Code Online (Sandbox Code Playgroud)
它将在断点处停止.在--这里指示expr,它应该停止做选项解析和其后的内容是评价一个表达式.