sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget"/translations/zh_CN/dev-tools/gcovmodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/zh_TW/dev-tools/gcovmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/it_IT/dev-tools/gcovmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/ja_JP/dev-tools/gcovmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/ko_KR/dev-tools/gcovmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hPortuguese (Brazilian)}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/pt_BR/dev-tools/gcovmodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget"/translations/sp_SP/dev-tools/gcovmodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(h Using gcov with the Linux kernelh]h Using gcov with the Linux kernel}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhubah}(h]h ]h"]h$]h&]uh1j3hj,ubeh}(h]h ]h"]h$]h&]uh1jhhhKhj)ubj)}(hkfrom the build tree: - all C source files + headers - all .gcda and .gcno files - all links to directories h](j$)}(hfrom the build tree:h]hfrom the build tree:}(hjrhhhNhNubah}(h]h ]h"]h$]h&]uh1j#hhhKhjnubj4)}(hhh]jL)}(hhh](jQ)}(hall C source files + headersh]h)}(hjh]hall C source files + headers}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jPhjubjQ)}(hall .gcda and .gcno filesh]h)}(hjh]hall .gcda and .gcno files}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jPhjubjQ)}(hall links to directories h]h)}(hall links to directoriesh]hall links to directories}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jPhjubeh}(h]h ]h"]h$]h&]jjuh1jKhhhKhjubah}(h]h ]h"]h$]h&]uh1j3hjnubeh}(h]h ]h"]h$]h&]uh1jhhhKhj)ubeh}(h]h ]h"]h$]h&]uh1jhjubh)}(hXIt is important to note that these files need to be placed into the exact same file system location on the test machine as on the build machine. If any of the path components is symbolic link, the actual directory needs to be used instead (due to make's CURDIR handling).h]hXIt is important to note that these files need to be placed into the exact same file system location on the test machine as on the build machine. If any of the path components is symbolic link, the actual directory needs to be used instead (due to make’s CURDIR handling).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1jPhjhhhhhNubah}(h]jah ]h"] gcov-testah$]h&]enumtype loweralphaprefixhsuffix)uh1jhjhhhhhKexpect_referenced_by_name}jjsexpect_referenced_by_id}jjsubj)}(h.. _gcov-build:h]h}(h]h ]h"]h$]h&]j gcov-builduh1jhKhjhhhhubj)}(hhh]jQ)}(hXgcov is run on the BUILD machine The following files need to be copied after each test case from test to build machine: from the gcov directory in sysfs: - all .gcda files - all links to .gcno files These files can be copied to any location on the build machine. gcov must then be called with the -o option pointing to that directory. Example directory setup on the build machine:: /tmp/linux: kernel source tree /tmp/out: kernel build directory as specified by make O= /tmp/coverage: location of the files copied from the test machine [user@build] cd /tmp/out [user@build] gcov -o /tmp/coverage/tmp/out/init main.c h](h)}(h gcov is run on the BUILD machineh]h gcov is run on the BUILD machine}(hj hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hXcThe following files need to be copied after each test case from test to build machine: from the gcov directory in sysfs: - all .gcda files - all links to .gcno files These files can be copied to any location on the build machine. gcov must then be called with the -o option pointing to that directory. Example directory setup on the build machine:: /tmp/linux: kernel source tree /tmp/out: kernel build directory as specified by make O= /tmp/coverage: location of the files copied from the test machine [user@build] cd /tmp/out [user@build] gcov -o /tmp/coverage/tmp/out/init main.c h](h)}(hVThe following files need to be copied after each test case from test to build machine:h]hVThe following files need to be copied after each test case from test to build machine:}(hj2hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj.ubj)}(hhh]j)}(hOfrom the gcov directory in sysfs: - all .gcda files - all links to .gcno files h](j$)}(h!from the gcov directory in sysfs:h]h!from the gcov directory in sysfs:}(hjGhhhNhNubah}(h]h ]h"]h$]h&]uh1j#hhhKhjCubj4)}(hhh]jL)}(hhh](jQ)}(hall .gcda filesh]h)}(hj]h]hall .gcda files}(hj_hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj[ubah}(h]h ]h"]h$]h&]uh1jPhjXubjQ)}(hall links to .gcno files h]h)}(hall links to .gcno filesh]hall links to .gcno files}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjrubah}(h]h ]h"]h$]h&]uh1jPhjXubeh}(h]h ]h"]h$]h&]jjuh1jKhhhKhjUubah}(h]h ]h"]h$]h&]uh1j3hjCubeh}(h]h ]h"]h$]h&]uh1jhhhKhj@ubah}(h]h ]h"]h$]h&]uh1jhj.ubh)}(hThese files can be copied to any location on the build machine. gcov must then be called with the -o option pointing to that directory.h]hThese files can be copied to any location on the build machine. gcov must then be called with the -o option pointing to that directory.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj.ubh)}(h.Example directory setup on the build machine::h]h-Example directory setup on the build machine:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj.ubj )}(h/tmp/linux: kernel source tree /tmp/out: kernel build directory as specified by make O= /tmp/coverage: location of the files copied from the test machine [user@build] cd /tmp/out [user@build] gcov -o /tmp/coverage/tmp/out/init main.ch]h/tmp/linux: kernel source tree /tmp/out: kernel build directory as specified by make O= /tmp/coverage: location of the files copied from the test machine [user@build] cd /tmp/out [user@build] gcov -o /tmp/coverage/tmp/out/init main.c}hjsbah}(h]h ]h"]h$]h&]jjuh1jhhhKhj.ubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1jPhjhhhhhNubah}(h]jah ]h"] gcov-buildah$]h&]jjjhjj startKuh1jhjhhhhhKj }jjsj }jjsubeh}(h]!separated-build-and-test-machinesah ]h"]!separated build and test machinesah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hNote on compilersh]hNote on compilers}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hGCC and LLVM gcov tools are not necessarily compatible. Use gcov_ to work with GCC-generated .gcno and .gcda files, and use llvm-cov_ for Clang.h](h.. _llvm-cov: https://llvm.org/docs/CommandGuide/llvm-cov.htmlh]h}(h]llvm-covah ]h"]llvm-covah$]h&]hj'uh1jhKhjhhhhjKubh)}(hBuild differences between GCC and Clang gcov are handled by Kconfig. It automatically selects the appropriate gcov format depending on the detected toolchain.h]hBuild differences between GCC and Clang gcov are handled by Kconfig. It automatically selects the appropriate gcov format depending on the detected toolchain.}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]note-on-compilersah ]h"]note on compilersah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hTroubleshootingh]hTroubleshooting}(hjdhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjahhhhhKubj)}(hhh](j)}(h/Problem Compilation aborts during linker step. h](j$)}(hProblemh]hProblem}(hjyhhhNhNubah}(h]h ]h"]h$]h&]uh1j#hhhKhjuubj4)}(hhh]h)}(h&Compilation aborts during linker step.h]h&Compilation aborts during linker step.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j3hjuubeh}(h]h ]h"]h$]h&]uh1jhhhKhjrubj)}(hCause Profiling flags are specified for source files which are not linked to the main kernel or which are linked by a custom linker procedure. h](j$)}(hCauseh]hCause}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j#hhhKhjubj4)}(hhh]h)}(hProfiling flags are specified for source files which are not linked to the main kernel or which are linked by a custom linker procedure.h]hProfiling flags are specified for source files which are not linked to the main kernel or which are linked by a custom linker procedure.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j3hjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjrhhubj)}(hSolution Exclude affected source files from profiling by specifying ``GCOV_PROFILE := n`` or ``GCOV_PROFILE_basename.o := n`` in the corresponding Makefile. h](j$)}(hSolutionh]hSolution}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1j#hhhKhjubj4)}(hhh]h)}(hExclude affected source files from profiling by specifying ``GCOV_PROFILE := n`` or ``GCOV_PROFILE_basename.o := n`` in the corresponding Makefile.h](h;Exclude affected source files from profiling by specifying }(hjhhhNhNubh)}(h``GCOV_PROFILE := n``h]hGCOV_PROFILE := n}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh or }(hjhhhNhNubh)}(h ``GCOV_PROFILE_basename.o := n``h]hGCOV_PROFILE_basename.o := n}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubh in the corresponding Makefile.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j3hjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjrhhubj)}(h`):h](hFSample script to gather coverage meta files on the build machine (see }(hj hhhNhNubh)}(h7:ref:`Separated build and test machines a. `h]hinline)}(hj h]h$Separated build and test machines a.}(hj hhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1j hj ubah}(h]h ]h"]h$]h&]refdocdev-tools/gcov refdomainj! reftyperef refexplicitrefwarn reftarget gcov-testuh1hhhhKhj ubh):}(hj hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj )}(hXg#!/bin/bash KSRC=$1 KOBJ=$2 DEST=$3 if [ -z "$KSRC" ] || [ -z "$KOBJ" ] || [ -z "$DEST" ]; then echo "Usage: $0 " >&2 exit 1 fi KSRC=$(cd $KSRC; printf "all:\n\t@echo \${CURDIR}\n" | make -f -) KOBJ=$(cd $KOBJ; printf "all:\n\t@echo \${CURDIR}\n" | make -f -) find $KSRC $KOBJ \( -name '*.gcno' -o -name '*.[ch]' -o -type l \) -a \ -perm /u+r,g+r | tar cfz $DEST -P -T - if [ $? -eq 0 ] ; then echo "$DEST successfully created, copy to test system and unpack with:" echo " tar xfz $DEST -P" else echo "Could not create file $DEST" fih]hXg#!/bin/bash KSRC=$1 KOBJ=$2 DEST=$3 if [ -z "$KSRC" ] || [ -z "$KOBJ" ] || [ -z "$DEST" ]; then echo "Usage: $0 " >&2 exit 1 fi KSRC=$(cd $KSRC; printf "all:\n\t@echo \${CURDIR}\n" | make -f -) KOBJ=$(cd $KOBJ; printf "all:\n\t@echo \${CURDIR}\n" | make -f -) find $KSRC $KOBJ \( -name '*.gcno' -o -name '*.[ch]' -o -type l \) -a \ -perm /u+r,g+r | tar cfz $DEST -P -T - if [ $? -eq 0 ] ; then echo "$DEST successfully created, copy to test system and unpack with:" echo " tar xfz $DEST -P" else echo "Could not create file $DEST" fi}hj? sbah}(h]h ]h"]h$]h&]jjforcelanguageshhighlight_args}uh1jhhhKhjhhubeh}(h]appendix-a-gather-on-build-shah ]h"]appendix a: gather_on_build.shah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hAppendix B: gather_on_test.shh]hAppendix B: gather_on_test.sh}(hj] hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjZ hhhhhMubh)}(hSample script to gather coverage data files on the test machine (see :ref:`Separated build and test machines b. `):h](hESample script to gather coverage data files on the test machine (see }(hjk hhhNhNubh)}(h8:ref:`Separated build and test machines b. `h]j )}(hju h]h$Separated build and test machines b.}(hjw hhhNhNubah}(h]h ](j stdstd-refeh"]h$]h&]uh1j hjs ubah}(h]h ]h"]h$]h&]refdocj- refdomainj reftyperef refexplicitrefwarnj3 gcov-builduh1hhhhMhjk ubh):}(hjk hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjZ hhubj )}(hX#!/bin/bash -e DEST=$1 GCDA=/sys/kernel/debug/gcov if [ -z "$DEST" ] ; then echo "Usage: $0 " >&2 exit 1 fi TEMPDIR=$(mktemp -d) echo Collecting data.. find $GCDA -type d -exec mkdir -p $TEMPDIR/\{\} \; find $GCDA -name '*.gcda' -exec sh -c 'cat < $0 > '$TEMPDIR'/$0' {} \; find $GCDA -name '*.gcno' -exec sh -c 'cp -d $0 '$TEMPDIR'/$0' {} \; tar czf $DEST -C $TEMPDIR sys rm -rf $TEMPDIR echo "$DEST successfully created, copy to build system and unpack with:" echo " tar xfz $DEST"h]hX#!/bin/bash -e DEST=$1 GCDA=/sys/kernel/debug/gcov if [ -z "$DEST" ] ; then echo "Usage: $0 " >&2 exit 1 fi TEMPDIR=$(mktemp -d) echo Collecting data.. find $GCDA -type d -exec mkdir -p $TEMPDIR/\{\} \; find $GCDA -name '*.gcda' -exec sh -c 'cat < $0 > '$TEMPDIR'/$0' {} \; find $GCDA -name '*.gcno' -exec sh -c 'cp -d $0 '$TEMPDIR'/$0' {} \; tar czf $DEST -C $TEMPDIR sys rm -rf $TEMPDIR echo "$DEST successfully created, copy to build system and unpack with:" echo " tar xfz $DEST"}hj sbah}(h]h ]h"]h$]h&]jjjM jN shjP }uh1jhhhMhjZ hhubeh}(h]appendix-b-gather-on-test-shah ]h"]appendix b: gather_on_test.shah$]h&]uh1hhhhhhhhMubeh}(h] using-gcov-with-the-linux-kernelah ]h"] using gcov with the linux kernelah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerj error_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourcehʌ _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}(gcov](hjelcov]j"allvm-cov]jaurefids}(j]jaj]jaunameids}(j j jjjjj3j0jjj]jZjj|jjjjjjjjj^j[jHjEjjjW jT j j u nametypes}(j jjj3jj]jjjjjj^jHjjW j uh}(j hjjjjj0jjj6jZjj|j`jjjjjjjjj[jj8j2jEj?jjajT jj jZ u footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}j KsRparse_messages](hsystem_message)}(hhh]h)}(h:Enumerated list start value not ordinal-1: "b" (ordinal 2)h]h>Enumerated list start value not ordinal-1: “b” (ordinal 2)}(hjO hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjL ubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehʌlineKuh1jJ hjhhhhhKubjK )}(hhh]h)}(h'Duplicate explicit target name: "gcov".h]h+Duplicate explicit target name: “gcov”.}(hjk hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjh ubah}(h]h ]h"]h$]h&]j8alevelKtypeje lineKsourcehuh1jJ hjhhhhhKubetransform_messages](jK )}(hhh]h)}(hhh]h/Hyperlink target "gcov-test" is not referenced.}hj sbah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]levelKtypeje sourcehʌlineKuh1jJ ubjK )}(hhh]h)}(hhh]h0Hyperlink target "gcov-build" is not referenced.}hj sbah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]levelKtypeje sourcehʌlineKuh1jJ ube transformerN include_log] decorationNhhub.