Q:

disable gcov coverage at run-time

I'm writing some Test in C++ and I'm using gcov (actually lcov but I think it's beside the point) to get informations about coverage.
Is there any way to disable the information record at run-time?
E.G. :
bool myTest() {
    ObjectToTest obj;

    /* Enable gcov... */

    obj.FunctionToTest();

    /* ...Disable gcov */

    if(obj.GetStatus() != WHATEVER)
        return false;
    else
        return true;
}

In this case I would like gcov to display as "covered" just FunctionToTest but leave ObjectToTest constructor and GetStatus "uncovered".
Thanks in advance!

A:

No, in case of gcov we don't have any such option. 
I have seen such options in some coverage tools like clover, which works by instrumenting source code directly though.
Beside a solution to your problem will be to write that part of code into a different source file and then call it inside your desired source file by including it.
I am suggesting this because when you generate coverage report later using LCOV or GCOVR they both provide the option to exclude specified files from coverage report by passing them to certain switches.  
LCOV:  
-r tracefile pattern
   --remove tracefile pattern
          Remove data from tracefile.

GCOVR:  
-e EXCLUDE, --exclude=EXCLUDE
                    Exclude data files that match this regular expression

