2011-07-20 50 views

回答

2
#define Debugger() { kill(getpid(), SIGINT) ; } 

然后,只需调用Debugger(),无论您想要放置断点。

,如果你想跟踪的堆栈你也可以引发一个异常:

[NSException raise:@"Exception Message" format:formatString]; 
+0

当您放置断点时,您会做什么? – Tyilo

6

我用的系统日志和尾巴。你需要Cydia的syslogdErica Utilities。然后在整个调整的地方NSLog(@"breakpoint 1 - %@", someObject);并运行调整。

tail -f /var/log/syslog 
+0

错字:'埃里卡公用事业'。 ,P – Matoe

1

Mobilesubstrate将您的dylib注入到目标进程中。使用GDB或LLDB调试目标进程也在调试您的扩展代码。 我将向您展示如何使用GDB调试Mobilesubstrate扩展。 下面是简单的MobileSubstrate有/标志扩展:

%hook SBApplicationController 
-(void)uninstallApplication:(id)application { 
    int i = 5; 
    i = i +7; 
    NSLog(@"Hey, we're hooking uninstallApplication: and number: %d", i); 
    %orig; // Call the original implementation of this method 
    return; 
} 
%end 

我编译和安装代码,然后在GDB连接到它:

yaron-shanis-iPhone:~ root# ps aux | grep -i springboard 
mobile  396 1.6 4.3 423920 21988 ?? Ss 2:19AM 0:05.23 /System/Library/CoreServices/SpringBoard.app/SpringBoard 
root  488 0.0 0.1 273024 364 s000 S+ 2:22AM 0:00.01 grep -i springboard 
yaron-shanis-iPhone:~ root# gdb -p 488 

你可以找到你的MobileSubstrate有扩展使用以下命令:

(gdb) info sharedlibrary 

此命令打印已加载模块的列表,找到您的扩展名:

test-debug-substrate.dylib   - 0x172c000   dyld Y Y /Library/MobileSubstrate/DynamicLibraries/test-debug-substrate.dylib at 0x172c000 (offset 0x172c000) 

您还可以找到标志uninstallApplication挂钩的地址:哪些输出该

(gdb) info functions uninstallApplication 

0x0172cef0 _logos_method$_ungrouped$SBApplicationController$uninstallApplication$(SBApplicationController*, objc_selector*, objc_object*) 

可以调试与断点和其他GDB的功能,您uninstallApplication钩子函数:

(gdb) b *0x0172cef0+36 

其中偏移量36是程序集opcod e在uninstallApplication钩子函数中将7添加到i变量中。只要您愿意,您可以继续从这里调试您的Mobilesubstrate扩展。