8

I'm attempting to profile my code using the iPhone simulator. I've enabled Generate Test Coverage File and Instrument Program Flow and added -lgcov to the linker flags. According to everything I've read that should be all I need to do in terms of setup.

Update: Generate Test Coverage File triggers the -ftest-coverage flag and Instrument Program Flow triggers the -fprofile-arcs flag. I've checked the build logs and they are being set when compiling.

Executing the program I can see the .gcno files appearing along side the .o compiled code in the build/.build/Debug-iphonesimulator/.build/Objects-normal/i386 directory.

But when I run the app in the simulator I do not get any *.gcda files appearing.

My understanding is that these files contain the data from the instrumentation. But I cannot find them anywhere on the computer.

I know they can be produced and appear along side the *.gcno files because I have an old trashed buil directory which does have them. I just cannot figure out what I have to do to get them to appear and record the run.

Any help appreciated.

drekka
  • 20,957
  • 14
  • 79
  • 135
  • Are you by any chance trying to find and get rid of "bottlenecks"? If so, [consider random-pausing](http://stackoverflow.com/questions/926266/performance-optimization-strategies-of-last-resort/927773#927773). – Mike Dunlavey Jan 16 '11 at 17:37
  • No. My main interest is in seeing how much of the application is covered by unit tests and helping me to pin point areas I would like to add more testing to. Coming from a java/agile background, unit testing is something I like to do :) – drekka Jan 17 '11 at 02:34

2 Answers2

1

This link may have the answer, basically gcda files are not generated until your app exits properly. It gives two possible solutions:

  • completely quit the simulator
  • add this to your plist (but not for release builds):

    <key>UIApplicationExitsOnSuspend</key>
    <true/>
    
ergosys
  • 47,835
  • 5
  • 49
  • 70
  • Thanks. I tried both of those solutions. Fully shutting down the simulator and then adding that line to the plist. Neither worked. – drekka Jan 17 '11 at 12:14
  • Just tried removing the prefix header. Didn't fix the issue. Even when I exited the simulator as well. – drekka Jan 17 '11 at 12:27
  • I think the problem is building with wrong settings. He is getting gcno files which appear with `GCC -ftest-coverage` option, he need to build with `GCC -fprofile-arcs` option to get the gcda files. – Madhup Singh Yadav Jan 21 '11 at 10:17
  • @Madhup - Sorry, I'm definitely building with -fprofile-arcs. – drekka Jan 22 '11 at 07:10
1

I hope this link would give you some idea. Exploring the link I found

The .gcno file is generated when the source file is compiled with the GCC -ftest-coverage option. It contains information to reconstruct the basic block graphs and assign source line numbers to blocks.

The .gcda file is generated when a program containing object files built with the GCC -fprofile-arcs option is executed. A separate .gcda file is created for each object file compiled with this option. It contains arc transition counts, and some summary information.

So may be you are building with some wrong settings. The information is mentioned on http://gcc.gnu.org/onlinedocs/gcc/Gcov-Data-Files.html#Gcov-Data-Files

Community
  • 1
  • 1
Madhup Singh Yadav
  • 8,110
  • 7
  • 51
  • 84