]> git.ipfire.org Git - thirdparty/gcc.git/commit
gcov: branch, conds, calls in function summaries
authorJørgen Kvalsvik <j@lambda.is>
Wed, 7 Aug 2024 15:33:31 +0000 (17:33 +0200)
committerJørgen Kvalsvik <j@lambda.is>
Wed, 26 Mar 2025 22:37:19 +0000 (23:37 +0100)
commit580664d1b66a5d98e5e87d9ff728566b309e89b1
treef7f704e7c2a7b94751680d150292fd8d4d4ccb47
parentb70bd691cfd77b4d7a453031599bb6f1d48aedf1
gcov: branch, conds, calls in function summaries

The gcov function summaries only output the covered lines, not the
branches and calls. Since the function summaries is an opt-in it
probably makes sense to also include branch coverage, calls, and
condition coverage.

$ gcc --coverage -fpath-coverage hello.c -o hello
$ ./hello

Before:
    $ gcov -f hello
    Function 'main'
    Lines executed:100.00% of 4

    Function 'fn'
    Lines executed:100.00% of 7

    File 'hello.c'
    Lines executed:100.00% of 11
    Creating 'hello.c.gcov'

After:
    $ gcov -f hello
    Function 'main'
    Lines executed:100.00% of 3
    No branches
    Calls executed:100.00% of 1

    Function 'fn'
    Lines executed:100.00% of 7
    Branches executed:100.00% of 4
    Taken at least once:50.00% of 4
    No calls

    File 'hello.c'
    Lines executed:100.00% of 10
    Creating 'hello.c.gcov'

    Lines executed:100.00% of 10

With conditions:
    $ gcov -fg hello
    Function 'main'
    Lines executed:100.00% of 3
    No branches
    Calls executed:100.00% of 1
    No conditions

    Function 'fn'
    Lines executed:100.00% of 7
    Branches executed:100.00% of 4
    Taken at least once:50.00% of 4
    Condition outcomes covered:100.00% of 8
    No calls

    File 'hello.c'
    Lines executed:100.00% of 10
    Creating 'hello.c.gcov'

    Lines executed:100.00% of 10

gcc/ChangeLog:

* gcov.cc (generate_results): Count branches, conditions.
(function_summary): Output branch, calls, condition count.
gcc/gcov.cc