请参阅http://alxsrg.com/?p=180http://root42.blogspot.ru/2011/02/valgrind-checking-of-ios-programs.html和http://landonf.bikemonkey.org/code/iphone/iPhone_Simulator_Valgrind.20081224.html。
我在某些情况下尝试过,但都失败了。
我所尝试的只是:
- 山狮+xcode 4.6/4.6+手动编译的valgrind+SDK5.1从旧版本的xcode中提取
- lion(10.7.5)vmware中的来宾操作系统(主机为山狮)+xcode4.3.2/4.5.2+SDK5.1/SDK5.0
- 狮子(10.7)+xcode4.2.1+SDK5.0
execl失败,堆栈为null指令(0x00000000)。
而我试着在命令行中使用valgrind,效果很好。
ps,代码在模拟器中产生valgrind:
#define VALGRIND "/opt/local/bin/valgrind"
int main(int argc, char *argv[]) {
#ifdef VALGRIND_REXEC
/* Using the valgrind build config, rexec ourself
* in valgrind */
if (argc < 2 || (argc >= 2 && strcmp(argv[1], "-valgrind") != 0)) {
execl(VALGRIND, VALGRIND, "--leak-check=full", argv[0], "-valgrind",
NULL);
}
#endif
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"PeepsAppDelegate");
[pool release];
return retVal;
}
我已经完成了这项工作,但我不得不从Valgrind中破解crud,因为LLVM发出的一些SSE4指令当时在Valgrind的模拟器下不受支持。如果你还感兴趣的话,我相信我在某个地方还有这个版本。哦,还有,你需要禁用任何和所有的音频或视频代码,因为你的音频线程会超时(Valgrind就是这么慢),模拟器会退出。