Skip to content
Browse files

use Valgrind debugging.

  • Loading branch information...
1 parent 7d18080 commit 157b8ee92c95f6b999408dd823dcf25d9a655e4c laiso committed Aug 27, 2009
Showing with 33 additions and 0 deletions.
  1. +33 −0 main.m
View
33 main.m
@@ -7,6 +7,38 @@
//
#import <UIKit/UIKit.h>
+#import <unistd.h>
+
+#ifndef ENABLE_VALGRIND
+#define ENABLE_VALGRIND 1
+#endif
+
+#define VALGRIND_PATH "/usr/local/bin/valgrind"
+
+int main(int argc, char *argv[])
+{
+#if ENABLE_VALGRIND
+ // check if in the simulator
+ NSString *model = [[UIDevice currentDevice] model];
+ if ([model isEqualToString:@"iPhone Simulator"]) {
+
+ // execute myself with valgrind
+ if (argc < 2 || strcmp(argv[1], "--valgrind") != 0) {
+ execl(VALGRIND_PATH, VALGRIND_PATH, "--leak-check=full", argv[0], "--valgrind", NULL);
+ }
+ }
+#endif
+
+ NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
+ int retVal = UIApplicationMain(argc, argv, nil, nil);
+ [pool release];
+ return retVal;
+}
+
+
+
+/*
+#import <UIKit/UIKit.h>
int main(int argc, char *argv[]) {
@@ -15,3 +47,4 @@ int main(int argc, char *argv[]) {
[pool release];
return retVal;
}
+*/

0 comments on commit 157b8ee

Please sign in to comment.
Something went wrong with that request. Please try again.