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

天涯浪子 提交于 2019-12-08 16:53:38

问题


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.


回答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




回答2:


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/>
    


来源:https://stackoverflow.com/questions/4680652/iphone-cannot-get-simulator-to-generate-gcda-profiling-data-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!