GCOV(1) GNU GCOV(1) (NAME) arm-none-eabi-gcov - (Coverage) ARM (SYNOPSIS) gcov [-v|--version] [-h|--help] [-a|--all-blocks] [-b|--branch-probabilities] [-c|--branch-counts] [-g|--conditions] [-e|--prime-paths] [--prime-paths-lines[=type]] [--prime-paths-source[=type]] [-d|--display-progress] [-f|--function-summaries] [--include regex] [--exclude regex] [-j|--json-format] [-H|--human-readable] [-k|--use-colors] [-l|--long-file-names] [-m|--demangled-names] [-M|--filter-on-demangled] [-n|--no-output] [-o|--object-directory directory|file] [-p|--preserve-paths] [-q|--use-hotness-colors] [-r|--relative-only] [-s|--source-prefix directory] [-t|--stdout] [-u|--unconditional-branches] [-x|--hash-filenames] files (DESCRIPTION) gcov . GCC . gcov . gcov gprof . . gcov gprof : * * * . gcov . . . . gcov << >> (hot spots) . gcov ( ) . --- . (inline) . gcov sourcefile.gcov sourcefile.c . gprof . gprof gcov . gcov GCC . . (OPTIONS) -a --all-blocks . gcov . . -b --branch-probabilities . . -u . -c --branch-counts . -g --conditions . ( / MC/DC). -fcondition-coverage . -e --prime-paths . . . ( ) (prime path) . . --prime-paths-lines --prime-paths-source . --json-format . -fpath-coverage . --prime-paths-lines [=type] . . . type : * uncovered - (). . * covered - (). * both - . covered uncovered . --prime-paths-lines : paths covered 12 of 15 path 2 not covered: lines 8 8(false) 11(true) 11 13(true) 13(true) 14 17 path 3 not covered: lines 8 8(false) 11(true) 11 13(true) 13(false) 16 17 path 4 not covered: lines 8 8(false) 11(true) 11 13(false) 16 17 false "false" . --prime-paths-source [=type] . . . type : * uncovered - (). . * covered - (). * both - . covered uncovered . --prime-paths-source : path 10 not covered: BB 3: 8: for (i = 0; i < 10; i++) BB 3: 9: total += i; BB 4: (false) 8: for (i = 0; i < 10; i++) BB 5: (true) 11: int v = total > 100 ? 1 : 2; BB 6: 11: int v = total > 100 ? 1 : 2; BB 8: (false) 13: if (total != 45 && v == 1) BB 11: 16: printf ("Success\n"); BB 12: 17: return 0; (BB) ( -w ). (true/false) . . . . -d --display-progress . -f --function-summaries . --include regex regex . gcov regex . --exclude . include exclude . gcov --include . --exclude regex regex . gcov regex . --include . include exclude . gcov --exclude . -h --help gcov ( ) . -j --json-format gcov JSON . JSON gzip .gcov.json.gz . JSON : { "current_working_directory": "foo/bar", "data_file": "a.out", "format_version": "2", "gcc_version": "11.1.1 20210510" "files": ["$file"] } : * current_working_directory: * data_file: (GCDA) * format_version: 2: * calls: * gcc_version: GCC file : { "file": "a.c", "functions": ["$function"], "lines": ["$line"] } file : * file_name: function : { "blocks": 2, "blocks_executed": 2, "demangled_name": "foo", "end_column": 1, "end_line": 4, "execution_count": 1, "name": "foo", "start_column": 5, "start_line": 1 } function : * blocks: * blocks_executed: * demangled_name: (demangled) * end_column: * end_line: * execution_count: * name: * start_column: * start_line: . start_line start_column . line : { "block_ids": ["$block_id"], "branches": ["$branch"], "calls": ["$call"], "count": 2, "conditions": ["$condition"], "line_number": 15, "unexecuted_block": false, "function_name": "foo", } -b . line : * block_ids: * count: * line_number: * unexecuted_block: ( ) * function_name: line ( ) branch : { "count": 11, "destination_block_id": 17, "fallthrough": true, "source_block_id": 13, "throw": false } branch : * count: * fallthrough: (fall through) true * throw: true * isource_block_id: * destination_block_id: call : { "destination_block_id": 1, "returned": 11, "source_block_id": 13 } call : * returned: ( line::count ) * isource_block_id: * destination_block_id: condition : { "count": 4, "covered": 2, "not_covered_false": [], "not_covered_true": [0, 1], } condition : * count: * covered: * not_covered_true: true * not_covered_false: false -H --human-readable ( 24.6k). -k --use-colors . . -a . -l --long-file-names (included). x.h a.c gcov a.c x.h.gcov a.c##x.h.gcov . x.h . -p . -m --demangled-names (demangled) . (mangled) . -M --filter-on-demangled --include --exclude (demangled). --demangled-names . -n --no-output gcov . -o directory|file --object-directory directory --object-file file gcov . .gcno .gcda . . . -p --preserve-paths .gcov . . / # . .. ^ . . -q --use-hotness-colors perf (). . -r --relative-only ( ). . -s directory --source-prefix directory . . . -t --stdout . -u --unconditional-branches . . -v --version gcov ( ) . -w --verbose (arcs). -x --hash-filenames --preserve-paths gcov . . source-file##md5.gcov source-file md5 . --preserve-paths . gcov . . gcov mangledname.gcov . . .gcov ( ) . mangledname -l -p . . gcov . . .gcov : . : :: . execution_count - . ++C ##### ===== . -a $$$$$ %%%%% . execution_count * -k (magenta) . Ada . GCC -- (inline) . - . -fkeep-inline-functions -fkeep-static-functions gcov execution_count . line_number . : -:0:: gcov --- . tag . : information . 0% 100% 0% 100% . 0% 100% . gcov GCC --coverage . gcov ( ) gcov . . . -fprofile-arcs .gcda . gcov . tmp.cpp gcov : $ g++ --coverage tmp.cpp -c $ g++ --coverage tmp.o $ a.out $ gcov tmp.cpp -m File 'tmp.cpp' Lines executed:92.86% of 14 Creating 'tmp.cpp.gcov' tmp.cpp.gcov gcov . : -: 0:Source:tmp.cpp -: 0:Working directory:/home/gcc/testcase -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include -: 2: -: 3:template -: 4:class Foo -: 5:{ -: 6: public: 1*: 7: Foo(): b (1000) {} ------------------ Foo::Foo(): #####: 7: Foo(): b (1000) {} ------------------ Foo::Foo(): 1: 7: Foo(): b (1000) {} ------------------ 2*: 8: void inc () { b++; } ------------------ Foo::inc(): #####: 8: void inc () { b++; } ------------------ Foo::inc(): 2: 8: void inc () { b++; } ------------------ -: 9: -: 10: private: -: 11: int b; -: 12:}; -: 13: -: 14:template class Foo; -: 15:template class Foo; -: 16: -: 17:int 1: 18:main (void) -: 19:{ -: 20: int i, total; 1: 21: Foo counter; -: 22: 1: 23: counter.inc(); 1: 24: counter.inc(); 1: 25: total = 0; -: 26: 11: 27: for (i = 0; i < 10; i++) 10: 28: total += i; -: 29: 1*: 30: int v = total > 100 ? 1 : 2; -: 31: 1: 32: if (total != 45) #####: 33: printf ("Failure\n"); -: 34: else 1: 35: printf ("Success\n"); 1: 36: return 0; -: 37:} . Foo . . -a : -: 0:Source:tmp.cpp -: 0:Working directory:/home/gcc/testcase -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include -: 2: -: 3:template -: 4:class Foo -: 5:{ -: 6: public: 1*: 7: Foo(): b (1000) {} ------------------ Foo::Foo(): #####: 7: Foo(): b (1000) {} ------------------ Foo::Foo(): 1: 7: Foo(): b (1000) {} ------------------ 2*: 8: void inc () { b++; } ------------------ Foo::inc(): #####: 8: void inc () { b++; } ------------------ Foo::inc(): 2: 8: void inc () { b++; } ------------------ -: 9: -: 10: private: -: 11: int b; -: 12:}; -: 13: -: 14:template class Foo; -: 15:template class Foo; -: 16: -: 17:int 1: 18:main (void) -: 19:{ -: 20: int i, total; 1: 21: Foo counter; 1: 21-block 0 -: 22: 1: 23: counter.inc(); 1: 23-block 0 1: 24: counter.inc(); 1: 24-block 0 1: 25: total = 0; -: 26: 11: 27: for (i = 0; i < 10; i++) 1: 27-block 0 11: 27-block 1 10: 28: total += i; 10: 28-block 0 -: 29: 1*: 30: int v = total > 100 ? 1 : 2; 1: 30-block 0 %%%%%: 30-block 1 1: 30-block 2 -: 31: 1: 32: if (total != 45) 1: 32-block 0 #####: 33: printf ("Failure\n"); %%%%%: 33-block 0 -: 34: else 1: 35: printf ("Success\n"); 1: 35-block 0 1: 36: return 0; 1: 36-block 0 -: 37:} -- . . . -b . GCC (instrument) . . -b : -: 0:Source:tmp.cpp -: 0:Working directory:/home/gcc/testcase -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 -: 0:Programs:1 -: 1:#include -: 2: -: 3:template -: 4:class Foo -: 5:{ -: 6: public: 1*: 7: Foo(): b (1000) {} ------------------ Foo::Foo(): function Foo::Foo() called 0 returned 0% blocks executed 0% #####: 7: Foo(): b (1000) {} ------------------ Foo::Foo(): function Foo::Foo() called 1 returned 100% blocks executed 100% 1: 7: Foo(): b (1000) {} ------------------ 2*: 8: void inc () { b++; } ------------------ Foo::inc(): function Foo::inc() called 0 returned 0% blocks executed 0% #####: 8: void inc () { b++; } ------------------ Foo::inc(): function Foo::inc() called 2 returned 100% blocks executed 100% 2: 8: void inc () { b++; } ------------------ -: 9: -: 10: private: -: 11: int b; -: 12:}; -: 13: -: 14:template class Foo; -: 15:template class Foo; -: 16: -: 17:int function main called 1 returned 100% blocks executed 81% 1: 18:main (void) -: 19:{ -: 20: int i, total; 1: 21: Foo counter; call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% (throw) -: 22: 1: 23: counter.inc(); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% (throw) 1: 24: counter.inc(); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% (throw) 1: 25: total = 0; -: 26: 11: 27: for (i = 0; i < 10; i++) branch 0 taken 91% (fallthrough) branch 1 taken 9% 10: 28: total += i; -: 29: 1*: 30: int v = total > 100 ? 1 : 2; branch 0 taken 0% (fallthrough) branch 1 taken 100% -: 31: 1: 32: if (total != 45) branch 0 taken 0% (fallthrough) branch 1 taken 100% #####: 33: printf ("Failure\n"); call 0 never executed branch 1 never executed branch 2 never executed -: 34: else 1: 35: printf ("Success\n"); call 0 returned 100% branch 1 taken 100% (fallthrough) branch 2 taken 0% (throw) 1: 36: return 0; -: 37:} . . . . . . . "never executed" . . 100% "exit" "longjmp" . -g : $ gcov -t -m -g tmp -: 0:Source:tmp.cpp -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 -: 1:#include -: 2: -: 3:int 1: 4:main (void) -: 5:{ -: 6: int i, total; 1: 7: total = 0; -: 8: 11: 9: for (i = 0; i < 10; i++) condition outcomes covered 2/2 10: 10: total += i; -: 11: 1*: 12: int v = total > 100 ? 1 : 2; condition outcomes covered 1/2 condition 0 not covered (true) -: 13: 1*: 14: if (total != 45 && v == 1) condition outcomes covered 1/4 condition 0 not covered (true) condition 1 not covered (true false) #####: 15: printf ("Failure\n"); -: 16: else 1: 17: printf ("Success\n"); 1: 18: return 0; -: 19:} . -- . "a || (b && c)" a b c . MC/DC ( / ) . true a . a -- a b . $ gcov -t -m -g tmp -: 0:Source:tmp.c -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 -: 1:#include -: 2: 1: 3:int main() -: 4:{ 1: 5: int a = 1; 1: 6: int b = 0; -: 7: 1: 8: if (a && b) condition outcomes covered 1/4 condition 0 not covered (true false) condition 1 not covered (true) #####: 9: printf ("Success!\n"); -: 10: else 1: 11: printf ("Failure!\n"); -: 12:} --coverage -fpath-coverage -e : $ gcov -t -e tmp -: 0:Source:tmp.cpp -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 -: 1:#include -: 2: paths covered 4 of 15 1: 3:int main () -: 4:{ -: 5: int i, total; 1: 6: total = 0; -: 7: 11: 8: for (i = 0; i < 10; i++) 10: 9: total += i; -: 10: 1*: 11: int v = total > 100 ? 1 : 2; -: 12: 1*: 13: if (total != 45 && v == 1) #####: 14: printf ("Failure\n"); -: 15: else 1: 16: printf ("Success\n"); 1: 17: return 0; -: 18:} . --prime-paths-source . $ gcov -t --prime-paths-source tmp -: 0:Source:tmp.cpp -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 -: 1:#include -: 2: paths covered 4 of 15 path 1: BB 2: 3:int main () BB 2: 6: total = 0; BB 2: 8: for (i = 0; i < 10; i++) BB 4: (false) 8: for (i = 0; i < 10; i++) BB 5: (true) 11: int v = total > 100 ? 1 : 2; BB 6: 11: int v = total > 100 ? 1 : 2; BB 8: (true) 13: if (total != 45 && v == 1) BB 9: (true) 13: if (total != 45 && v == 1) BB 10: 14: printf ("Failure\n"); BB 12: 17: return 0; gcov . (BB) . . . . "for" . . --include --exclude . --prime-paths-lines : -: 0:Source:tmp.cpp -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 -: 1:#include -: 2: paths covered 4 of 15 path 1 not covered: lines 8 8(false) 11(true) 11 13(true) 13(true) 14 17 path 2 not covered: lines 8 8(false) 11(true) 11 13(true) 13(false) 16 17 path 3 not covered: lines 8 8(false) 11(true) 11 13(false) 16 17 path 4 not covered: lines 8 8(false) 11(false) 11 13(true) 13(true) 14 17 path 5 not covered: lines 8 8(false) 11(false) 11 13(true) 13(false) 16 17 path 6 not covered: lines 8 8(false) 11(false) 11 13(false) 16 17 path 8 not covered: lines 9 8(false) 11(true) 11 13(true) 13(true) 14 17 path 9 not covered: lines 9 8(false) 11(true) 11 13(true) 13(false) 16 17 path 10 not covered: lines 9 8(false) 11(true) 11 13(false) 16 17 path 11 not covered: lines 9 8(false) 11(false) 11 13(true) 13(true) 14 17 path 12 not covered: lines 9 8(false) 11(false) 11 13(true) 13(false) 16 17 1: 3:int main () -: 4:{ --prime-paths-source . . . .gcda ( ) . . . .gcda . -fprofile-arcs .gcda ( ) . . --include --exclude . --stdout gcov gcov . $ gcov -m --stdout --include inc tmp -: 0:Source:tmp.cpp -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 2*: 8: void inc () { b++; } ------------------ Foo::inc(): #####: 8: void inc () { b++; } ------------------ Foo::inc(): 2: 8: void inc () { b++; } ------------------ gcov (mangled) -M . (demangled) . "int" "Foo" mangled demangled: $ gcov -t -m -M tmp --include 'Foo' -: 0:Source:tmp.cpp -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 1: 7: Foo(): b (1000) {} 2: 8: void inc () { b++; } $ gcov -t -m tmp --include 'FooIi' -: 0:Source:tmp.cpp -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 1: 7: Foo(): b (1000) {} 2: 8: void inc () { b++; } --include --exclude ( grep -E) "in.?" "inc" "main" . -M "int" "Foo" . --include --exclude . "main" "int" "inc" "Foo": $ gcov -t -m -M --include in --exclude Foo --include '::inc' tmp -: 0:Source:tmp.cpp -: 0:Graph:tmp.gcno -: 0:Data:tmp.gcda -: 0:Runs:1 2: 8: void inc () { b++; } 1: 18:main (void) -: 19:{ -: 20: int i, total; 1: 21: Foo counter; -: 22: 1: 23: counter.inc(); 1: 24: counter.inc(); 1: 25: total = 0; -: 26: 11: 27: for (i = 0; i < 10; i++) 10: 28: total += i; -: 29: 1*: 30: int v = total > 100 ? 1 : 2; -: 31: 1: 32: if (total != 45) #####: 33: printf ("Failure\n"); -: 34: else 1: 35: printf ("Success\n"); 1: 36: return 0; gcov GCC gcov GCC --coverage . GCC . . : if (a != b) c = 1; else c = 0; . gcov . gcov : 100: 12:if (a != b) 100: 13: c = 1; 100: 14:else 100: 15: c = 0; . . . (inlineable) . . (out of line) . fileA.o fileB.o . fileA.o fileB.o . . . . . . "__gcov_reset" "__gcov_dump" . "__gcov_reset(void)" "__gcov_dump(void)" .gcda . "__gcov_dump" . "__gcov_dump" "atexit" . dlopen -Wl,--dynamic-list-data . . GCOV_ERROR_FILE . GCOV_EXIT_AT_ERROR . . (SEE ALSO) gpl(7) gfdl(7) fsf-funding(7) gcc(1) Info gcc. (COPYRIGHT) Copyright (c) 1996-2026 Free Software Foundation, Inc. / (GNU Free Documentation License) 1.3 << >> << >> () ( ) () ( ). gfdl(7) . () FSF : A GNU Manual () FSF : You have freedom to copy and modify this GNU Manual, like GNU software. Copies published by the Free Software Foundation raise funds for GNU development. gcc-16.2.0 2026-08-07 GCOV(1)