Alexander Sergeev's blog

Valgrind and iOS

I’m working in Mail.ru now. My primary task is to fix memory management and concurrency problems in a complicated project written by a team of six people.

I had a nice experience using Valgrind tool on Linux system, so I started to investigate to possibility of using Valgrind with iOS.

The results are:

  • Valgrind works only on Mac OS X 10.7 Lion (Mac OS X 10.8 Mountain Lion is not supported yet).
  • Valgrind works only in simulator. There is no way to run it on a iPhone/iPad device.
  • Valgrind works only with iOS 5.0. iOS 6.0 is not supported.

In order to run valgrind you should:

  1. Get an Mac OS X 10.7 Lion. Fortunately, we have an old MacBook Pro with OS X 10.7 for testing purpose.
  2. Install XCode. XCode 4.5.2 works fine.
  3. Obtain a copy of valgrind‘s source from http://valgrind.org/downloads/. I took the svn version, but mac ports version works as well.
  4. I used this trick  to launch an application under valgrind in the simulator. I didn’t need to tack memory leaks, so I’m using –leack-check=no and –dsynutil=yes options.

This solution works fine for Mac OS X applications, too; however, make sure you are using Mac OS X 10.7. Looks like there is a difference in the threading model between Darwin 11 and Darwin 12; valgrind error message says:


valgrind: m_syswrap/syswrap-amd64-darwin.c:460 (void wqthread_hijack(Addr, Addr, Addr, Addr, Int, Addr)): Assertion 'VG_(is_valid_tid)(tid)' failed.

 

Share

Category: IT

Tagged: ,

Leave a Reply

You must be logged in to post a comment.




Forgot?
Register
Facebook login by WP-FB-AutoConnect