Question

Does gcc define a macro of some sort when the flag -fprofile-generate is specified? Basically, I want to disable multithreading when I'm profiling--it seems to have a way of corrupting the .gcda files.

Was it helpful?

Solution

This unanswered question is quite old, but I was having similar issues, so I hope this can be useful to someone.

You should try enabling the -fprofile-correction GCC compiler flag when using the profile information generated by a multi-threaded application. According to the GCC documentation relative to this flag:

Profiles collected using an instrumented binary for multi-threaded programs may be inconsistent due to missed counter updates. When this option is specified, GCC uses heuristics to correct or smooth out such inconsistencies. By default, GCC emits an error message when an inconsistent profile is detected.

It will get rid of the errors indicating that the .gcda files are corrupted by correcting inconsistent profile values due to multi-threading.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top