如何调试 MobileSubstrate 调整?
调试 MobileSubstrate 扩展的最佳方法是什么,即放置断点等?有办法在 Xcode 中做到这一点吗? GNU 调试器?
What is the best way to debug MobileSubstrate extensions, i.e. placing breakpoints etc.? Is there away to do this in Xcode? GNU Debugger?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用系统日志和尾部。您需要 Cydia 的
syslogd
和Erica Utilities
。然后在整个调整过程中放置NSLog(@"breakpoint 1 - %@", someObject);
并运行调整。I use the syslog and tail. You'll need
syslogd
andErica Utilities
from Cydia. Then throughout your tweak placeNSLog(@"breakpoint 1 - %@", someObject);
and run the tweak.然后,您只需在要放置断点的位置调用 Debugger() 即可。
如果你想跟踪堆栈,你也可以引发异常:
Then you just call Debugger() wherever you want to place a breakpoint.
You can also raise an exception if you want to trace the stack:
Mobilesubstrate 将您的 dylib 注入目标进程。使用 GDB 或 LLDB 调试目标进程也是在调试扩展代码。
我将向您展示如何使用 GDB 调试 Mobilesubstrate 扩展。
这是简单的 Mobilesubstrate/Logos 扩展:
我编译并安装代码,然后将 gdb 附加到它:
您可以使用以下命令找到您的 Mobilesubstrate 扩展:
此命令打印已加载模块的列表,找到您的扩展:
您还可以找到Logos uninstallApplication 钩子的地址:
输出如下:
您可以使用断点和其他 gdb 功能调试 uninstallApplication 钩子函数:
其中偏移量 36 是在 uninstallApplication 钩子函数中将 7 添加到 i 变量的汇编操作码。您可以根据需要继续从此处调试您的 Mobilesubstrate 扩展。
Mobilesubstrate injects your dylib into the target process. Debugging the target process using GDB or LLDB is also debugging your extension code.
I will show you how to debug Mobilesubstrate extension using GDB.
Here is simple Mobilesubstrate/Logos extension:
I compile and install the code, and then attaching gdb to it:
You can find your Mobilesubstrate extension with the command:
This command print a list of loaded modules, find your extension:
You can also find the address of Logos uninstallApplication hook:
Which outputs this:
You can debug your uninstallApplication hook function with breakpoints and other gdb features:
Where the offset 36 is the assembly opcode that adding of 7 to the i variable in uninstallApplication hook function. You can continue to debug your Mobilesubstrate extension from here as you wish.