What Is Gcov?

What Is Gcov?

Gcov is a code coverage analysis tool provided with the GNU Compiler Collection (GCC). It measures how often each line of code, decision, and branch is executed when a program runs.

Gcov helps developers and testers understand which parts of the source code were executed during testing and which parts were not.

To do this, Gcov works by compiling the software with instrumentation enabled. This instrumentation inserts counters into the executable that record execution data during a test run.

After execution, Gcov generates coverage reports showing:

  • Line coverage

  • Branch coverage

  • Function coverage

In functional safety projects, this information is used to demonstrate that testing has exercised the software logic thoroughly and systematically.

Why Is Code Coverage Important in ISO 26262?

Why Is Code Coverage Important in ISO 26262?

Structural code coverage is a mandatory verification activity in ISO 26262.

ISO 26262 uses code coverage metrics to judge whether software testing is sufficiently complete to uncover systematic faults.

According to ISO 26262‑6, the required coverage depth increases with the Automotive Safety Integrity Level (ASIL):

  • Lower ASILs may accept statement or line coverage

  • Higher ASILs (ASIL C and ASIL D) require branch coverage or MC/DC

Structural coverage provides objective evidence that:

  • All implemented logic has been executed

  • No hidden or dormant code paths remain untested

  • No additional functionality without requirements

Why Must Gcov Be Tool-Qualified Under ISO 26262?

Why Must Gcov Be Tool-Qualified Under ISO 26262?

If Gcov incorrectly reports complete coverage, engineers may falsely assume that safety-critical code has been tested, which can lead to undetected systematic faults.

What Are the Main Challenges of Using Gcov in Safety Systems?

What Are the Main Challenges of Using Gcov in Safety Systems?

The primary challenge is the probe effect caused by instrumentation.

Instrumentation with Gcov:

  • Increases memory usage

  • Alters execution timing and can affect real-time behavior

Engineers must ensure that all tests pass with instrumentation enabled and with instrumentation disabled.

References

References

FAQ

FAQ

No, ISO 26262 does not mandate specific tools, but Gcov is one commonly used option to achieve the required coverage metrics.

GCC Gcov only supports branch coverage but does not support MC/DC coverage. Therefore, for code that uses multiple conditions, GCC Gcov alone is not sufficient.

No. Instrumentation is removed before the production binary is built.

Incorrect coverage results, which can lead to false confidence in test completeness.

Stay informed

We’ll occasionally use your email address to share updates on upcoming webinars, events, and the latest news about our products and services.

External content - Hubspot

At this point you will find content from a third-party provider that you can display with one click.

By loading the form, personal data may be transmitted to the third-party provider. You can find more information in our privacy policy.