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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top