https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100751
--- Comment #23 from Martin Liška <marxin at gcc dot gnu.org> --- > So, for either a one time call of __gcov_dump (though we may attempt to call > __gcov_dump many times) or at the exit of the program execution, the merge > of profile happens due to which __gcov_reset doesn't get reflected at all. > Am I right ? Oh, I actually wrongly updated the documentation. When __gcov_reset is called, run-time counters are reset to zero AND __gcov_dump can be called again (or profile will be saved at exit). Slightly modified test-case does now: $ cat sample-prog.c #include <stdio.h> #include <ctype.h> #include <unistd.h> extern void __gcov_reset(void); extern void __gcov_flush(void); extern void __gcov_dump( void); int main() { unsigned char c; int count=0; c = 'g'; do { printf ("c: '%c'\n", c); if(c == 'g'){ __gcov_dump(); printf("__gcov_dump() invoked!\n"); c = 'r'; } else if(c == 'r'){ __gcov_reset(); printf("__gcov_reset() invoked!\n"); c = 'f'; } if(count == 2) c = 'g'; else if (count > 10) c = 'e'; count++; }while(c != 'e'); return 0; } $ gcc sample-prog.c --coverage -g && ./a.out && gcov -t sample-prog.c c: 'g' __gcov_dump() invoked! c: 'r' __gcov_reset() invoked! c: 'f' c: 'g' __gcov_dump() invoked! c: 'r' __gcov_reset() invoked! c: 'f' c: 'f' c: 'f' c: 'f' c: 'f' c: 'f' c: 'f' -: 0:Source:sample-prog.c -: 0:Graph:sample-prog.gcno -: 0:Data:sample-prog.gcda -: 0:Runs:1 -: 1:#include <stdio.h> -: 2:#include <ctype.h> -: 3:#include <unistd.h> -: 4: -: 5:extern void __gcov_reset(void); -: 6:extern void __gcov_flush(void); -: 7:extern void __gcov_dump( void); -: 8: 1: 9:int main() -: 10:{ -: 11: unsigned char c; 1: 12: int count=0; 1: 13: c = 'g'; -: 14: -: 15: do { 10: 16: printf ("c: '%c'\n", c); -: 17: 10: 18: if(c == 'g'){ 2: 19: __gcov_dump(); #####: 20: printf("__gcov_dump() invoked!\n"); #####: 21: c = 'r'; -: 22: } 8: 23: else if(c == 'r'){ #####: 24: __gcov_reset(); 2: 25: printf("__gcov_reset() invoked!\n"); 2: 26: c = 'f'; -: 27: } 10: 28: if(count == 2) 1: 29: c = 'g'; 9: 30: else if (count > 10) 1: 31: c = 'e'; 10: 32: count++; 10: 33: }while(c != 'e'); -: 34: 1: 35: return 0; -: 36:} Which should be correct in my oppinion.