Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPhone: Cannot get simulator to generate .gcda profiling data files

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.

like image 863
drekka Avatar asked Jan 13 '11 13:01

drekka


2 Answers

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

like image 58
Madhup Singh Yadav Avatar answered Sep 20 '22 08:09

Madhup Singh Yadav


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/>
    
like image 43
ergosys Avatar answered Sep 23 '22 08:09

ergosys