Hi,

I wanted to use gcov on Android but I wasn't able to find any success
stories. so I decided to experiment a bit and managed to get it
working. Here are short instructions on how to use it:
1) Compile your C/C++ code using '-fprofile-arcs -ftest-coverage'
2) Link the code with libgcov and libgcc

If you would try to run your app on Android right now, you won't get
any coverage data. This is because it tries to write this information
to the directory containing the object files of your app which I call
'build_dir'. Obviously you don't have access to the files, so:
3) Add a line 'setenv("GCOV_PREFIX", "/sdcard/some_directory", 1)' and
'setenv("GCOV_STRIP_PATH", "1", 1)'
this causes the data to be written to '/sdcard/some_directory/
build_dir'. (Note: in my case I have a jni library which loads my
actual library and I had the setenv calls in the jni library. I'm not
sure if this works fine if you use only a single library)

4) Run your app and .gcda files will appear in /sdcard/some_directory/
build_dir.
5) Copy the gcda files to the build directory containing the gcno
files and run the arm-eabi-gcov binary shipped with the ndk.

Regards,
Roderick Colenbrander

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to