将 LLDB 命令加载到 XCode

Load LLDB commands into XCode

是否有人将命令加载到 LLDB 以用于 XCode 应用程序的调试会话。 我在 XCode 6.1.1 和 iOS 8.x

我什么都不知道 Python,所以我非常希望避免涉及 Python。 我想从文件中加载我手动输入的这些东西,这样我就不必每次重新运行调试会话时都一遍又一遍地输入它...

(lldb) breakpoint set --func-regex "SomeClass"
Breakpoint 10: 48 locations.
(lldb) breakpoint set --func-regex "AnotherClass"
Breakpoint 11: 15 locations.
(lldb) breakpoint set --func-regex "ThisClass"
Breakpoint 12: 15 locations.
(lldb) breakpoint set --func-regex "ThatClass"
Breakpoint 13: 57 locations.
(lldb) breakpoint set --func-regex "OurClass"
Breakpoint 14: 98 locations.
(lldb) breakpoint set --func-regex "YourClass"
Breakpoint 15: 22 locations.
(lldb) breakpoint set --func-regex "HerClass"
Breakpoint 16: 17 locations.
(lldb) breakpoint set --func-regex "HisClass"
Breakpoint 17: 46 locations.
(lldb) breakpoint set --func-regex "TheyreClass"
Breakpoint 18: 63 locations.

(lldb) breakpoint command add 10
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
(lldb) breakpoint command add 11
Enter your debugger command(s).  Type 'DONE' to end.
> frame info; continue; DONE
> DONE
(lldb) breakpoint command delete 11
(lldb) breakpoint command add 11
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
(lldb) breakpoint command add 12
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
(lldb) breakpoint command add 13
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
(lldb) breakpoint command add 14
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
(lldb) breakpoint command add 15
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
(lldb) breakpoint command add 16
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
(lldb) breakpoint command add 17
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
(lldb) breakpoint command add 18
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE

谢谢

一种方法是在应用程序的 main() 函数上设置断点,并通过 Xcode UI 将其绑定以执行形式为

command source <myMagicFile>

然后自动继续

该文件随后将包含您要执行的命令,并且由于断点位于 main() 上,因此每次您开始调试应用程序时都会加载您的文件并执行命令

作为提示,添加每个断点然后直接执行断点命令添加可能更安全。断点命令添加将自动引用您创建的最后一个断点,因此您不必依赖断点 ID

例如:

breakpoint set --func-regex "SomeClass"
breakpoint command add
Enter your debugger command(s).  Type 'DONE' to end.
> frame info
> continue
> DONE
breakpoint set --func-regex "AnotherClass"

[...]