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]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&]uh1j<hj9hhhhhNubj=)}(h@test improvement (how do I change my test to cover these lines?)h]h)}(hjWh]h@test improvement (how do I change my test to cover these lines?)}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjUubah}(h]h ]h"]h$]h&]uh1j<hj9hhhhhNubj=)}(h^minimizing kernel configurations (do I need this option if the associated code is never run?) h]h)}(h]minimizing kernel configurations (do I need this option if the associated code is never run?)h]h]minimizing kernel configurations (do I need this option if the associated code is never run?)}(hjphhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjlubah}(h]h ]h"]h$]h&]uh1j<hj9hhhhhNubeh}(h]h ]h"]h$]h&]bullet*uh1j7hhhKhhhhubhtarget)}(h6.. _gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.htmlh]h}(h]gcovah ]h"]gcovah$]h&]hhuh1jhKhhhhhh referencedKubj)}(h4.. _lcov: https://github.com/linux-test-project/lcovh]h}(h]lcovah ]h"]lcovah$]h&]hjuh1jhKhhhhhhjKubh)}(hhh](h)}(h Preparationh]h Preparation}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hConfigure the kernel with::h]hConfigure the kernel with:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hjhhubh)}(h&CONFIG_DEBUG_FS=y CONFIG_GCOV_KERNEL=yh]h&CONFIG_DEBUG_FS=y CONFIG_GCOV_KERNEL=y}hjsbah}(h]h ]h"]h$]h&]jjuh1hhhhK"hjhhubh)}(h0and to get coverage data for the entire kernel::h]h/and to get coverage data for the entire kernel:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK%hjhhubh)}(hCONFIG_GCOV_PROFILE_ALL=yh]hCONFIG_GCOV_PROFILE_ALL=y}hjsbah}(h]h ]h"]h$]h&]jjuh1hhhhK'hjhhubh)}(hNote that kernels compiled with profiling flags will be significantly larger and run slower. Also CONFIG_GCOV_PROFILE_ALL may not be supported on all architectures.h]hNote that kernels compiled with profiling flags will be significantly larger and run slower. Also CONFIG_GCOV_PROFILE_ALL may not be supported on all architectures.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK)hjhhubh)}(hJProfiling data will only become accessible once debugfs has been mounted::h]hIProfiling data will only become accessible once debugfs has been mounted:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK-hjhhubh)}(h'mount -t debugfs none /sys/kernel/debugh]h'mount -t debugfs none /sys/kernel/debug}hj sbah}(h]h ]h"]h$]h&]jjuh1hhhhK0hjhhubeh}(h] preparationah ]h"] preparationah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Customizationh]h Customization}(hj%hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj"hhhhhK4ubh)}(h}To enable profiling for specific files or directories, add a line similar to the following to the respective kernel Makefile:h]h}To enable profiling for specific files or directories, add a line similar to the following to the respective kernel Makefile:}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK6hj"hhubj8)}(hhh](j=)}(hBFor a single file (e.g. main.o):: GCOV_PROFILE_main.o := y h](h)}(h!For a single file (e.g. main.o)::h]h For a single file (e.g. main.o):}(hjHhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK9hjDubh)}(hGCOV_PROFILE_main.o := yh]hGCOV_PROFILE_main.o := y}hjVsbah}(h]h ]h"]h$]h&]jjuh1hhhhK;hjDubeh}(h]h ]h"]h$]h&]uh1j<hjAhhhhhNubj=)}(h:For all files in one directory:: GCOV_PROFILE := y h](h)}(h For all files in one directory::h]hFor all files in one directory:}(hjnhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK=hjjubh)}(hGCOV_PROFILE := yh]hGCOV_PROFILE := y}hj|sbah}(h]h ]h"]h$]h&]jjuh1hhhhK?hjjubeh}(h]h ]h"]h$]h&]uh1j<hjAhhhhhNubeh}(h]h ]h"]h$]h&]j-uh1j7hhhK9hj"hhubh)}(hZTo exclude files from being profiled even when CONFIG_GCOV_PROFILE_ALL is specified, use::h]hYTo exclude files from being profiled even when CONFIG_GCOV_PROFILE_ALL is specified, use:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKAhj"hhubh)}(hGCOV_PROFILE_main.o := nh]hGCOV_PROFILE_main.o := n}hjsbah}(h]h ]h"]h$]h&]jjuh1hhhhKDhj"hhubh)}(hand::h]hand:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKFhj"hhubh)}(hGCOV_PROFILE := nh]hGCOV_PROFILE := n}hjsbah}(h]h ]h"]h$]h&]jjuh1hhhhKHhj"hhubh)}(hwOnly files which are linked to the main kernel image or are compiled as kernel modules are supported by this mechanism.h]hwOnly files which are linked to the main kernel image or are compiled as kernel modules are supported by this mechanism.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKJhj"hhubeh}(h] customizationah ]h"] customizationah$]h&]uh1hhhhhhhhK4ubh)}(hhh](h)}(hModule specific configsh]hModule specific configs}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKOubh)}(h=Gcov kernel configs for specific modules are described below:h]h=Gcov kernel configs for specific modules are described below:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjhhubhdefinition_list)}(hhh]hdefinition_list_item)}(hCONFIG_GCOV_PROFILE_RDS: Enables GCOV profiling on RDS for checking which functions or lines are executed. This config is used by the rds selftest to generate coverage reports. If left unset the report is omitted. h](hterm)}(hCONFIG_GCOV_PROFILE_RDS:h]hCONFIG_GCOV_PROFILE_RDS:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKWhj ubh definition)}(hhh]h)}(hEnables GCOV profiling on RDS for checking which functions or lines are executed. This config is used by the rds selftest to generate coverage reports. If left unset the report is omitted.h]hEnables GCOV profiling on RDS for checking which functions or lines are executed. This config is used by the rds selftest to generate coverage reports. If left unset the report is omitted.}(hj$hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKThj!ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1j hhhKWhjubah}(h]h ]h"]h$]h&]uh1jhjhhhhhNubeh}(h]module-specific-configsah ]h"]module specific configsah$]h&]uh1hhhhhhhhKOubh)}(hhh](h)}(hFilesh]hFiles}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjLhhhhhKZubh)}(h?The gcov kernel support creates the following files in debugfs:h]h?The gcov kernel support creates the following files in debugfs:}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK\hjLhhubj)}(hhh](j )}(hH``/sys/kernel/debug/gcov`` Parent directory for all gcov-related files. h](j)}(h``/sys/kernel/debug/gcov``h]h)}(hjth]h/sys/kernel/debug/gcov}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjrubah}(h]h ]h"]h$]h&]uh1jhhhK_hjnubj )}(hhh]h)}(h,Parent directory for all gcov-related files.h]h,Parent directory for all gcov-related files.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK_hjubah}(h]h ]h"]h$]h&]uh1jhjnubeh}(h]h ]h"]h$]h&]uh1j hhhK_hjkubj )}(hf``/sys/kernel/debug/gcov/reset`` Global reset file: resets all coverage data to zero when written to. h](j)}(h ``/sys/kernel/debug/gcov/reset``h]h)}(hjh]h/sys/kernel/debug/gcov/reset}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhhhKchjubj )}(hhh]h)}(hDGlobal reset file: resets all coverage data to zero when written to.h]hDGlobal reset file: resets all coverage data to zero when written to.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKbhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hhhKchjkhhubj )}(h``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda`` The actual gcov data file as understood by the gcov tool. Resets file coverage data to zero when written to. h](j)}(h8``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda``h]h)}(hjh]h4/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhhhKghjubj )}(hhh]h)}(hlThe actual gcov data file as understood by the gcov tool. Resets file coverage data to zero when written to.h]hlThe actual gcov data file as understood by the gcov tool. Resets file coverage data to zero when written to.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKfhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hhhKghjkhhubj )}(h``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno`` Symbolic link to a static data file required by the gcov tool. This file is generated by gcc when compiling with option ``-ftest-coverage``. h](j)}(h8``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno``h]h)}(hjh]h4/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]uh1jhhhKmhjubj )}(hhh]h)}(hSymbolic link to a static data file required by the gcov tool. This file is generated by gcc when compiling with option ``-ftest-coverage``.h](hxSymbolic link to a static data file required by the gcov tool. This file is generated by gcc when compiling with option }(hj4hhhNhNubh)}(h``-ftest-coverage``h]h-ftest-coverage}(hj<hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj4ubh.}(hj4hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKjhj1ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hhhKmhjkhhubeh}(h]h ]h"]h$]h&]uh1jhjLhhhhhNubeh}(h]filesah ]h"]filesah$]h&]uh1hhhhhhhhKZubh)}(hhh](h)}(hModulesh]hModules}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjnhhhhhKpubh)}(hXKernel modules may contain cleanup code which is only run during module unload time. The gcov mechanism provides a means to collect coverage data for such code by keeping a copy of the data associated with the unloaded module. This data remains available through debugfs. Once the module is loaded again, the associated coverage counters are initialized with the data from its previous instantiation.h]hXKernel modules may contain cleanup code which is only run during module unload time. The gcov mechanism provides a means to collect coverage data for such code by keeping a copy of the data associated with the unloaded module. This data remains available through debugfs. Once the module is loaded again, the associated coverage counters are initialized with the data from its previous instantiation.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKrhjnhhubh)}(hRThis behavior can be deactivated by specifying the gcov_persist kernel parameter::h]hQThis behavior can be deactivated by specifying the gcov_persist kernel parameter:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKyhjnhhubh)}(hgcov_persist=0h]hgcov_persist=0}hjsbah}(h]h ]h"]h$]h&]jjuh1hhhhK|hjnhhubh)}(hAt run-time, a user can also choose to discard data for an unloaded module by writing to its data file or the global reset file.h]hAt run-time, a user can also choose to discard data for an unloaded module by writing to its data file or the global reset file.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK~hjnhhubeh}(h]modulesah ]h"]modulesah$]h&]uh1hhhhhhhhKpubh)}(hhh](h)}(h!Separated build and test machinesh]h!Separated build and test machines}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hXThe gcov kernel profiling infrastructure is designed to work out-of-the box for setups where kernels are built and run on the same machine. In cases where the kernel runs on a separate machine, special preparations must be made, depending on where the gcov tool is used:h]hXThe gcov kernel profiling infrastructure is designed to work out-of-the box for setups where kernels are built and run on the same machine. In cases where the kernel runs on a separate machine, special preparations must be made, depending on where the gcov tool is used:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubj)}(h.. _gcov-test:h]h}(h]h ]h"]h$]h&]refid gcov-testuh1jhKhjhhhhubhenumerated_list)}(hhh]j=)}(hXgcov is run on the TEST machine The gcov tool version on the test machine must be compatible with the gcc version used for kernel build. Also the following files need to be copied from build to test machine: from the source tree: - all C source files + headers from the build tree: - all C source files + headers - all .gcda and .gcno files - all links to directories It 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](h)}(hgcov is run on the TEST machineh]hgcov is run on the TEST machine}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh block_quote)}(hXkThe gcov tool version on the test machine must be compatible with the gcc version used for kernel build. Also the following files need to be copied from build to test machine: from the source tree: - all C source files + headers from the build tree: - all C source files + headers - all .gcda and .gcno files - all links to directories It 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](h)}(hThe gcov tool version on the test machine must be compatible with the gcc version used for kernel build. Also the following files need to be copied from build to test machine:h]hThe gcov tool version on the test machine must be compatible with the gcc version used for kernel build. Also the following files need to be copied from build to test machine:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(hhh](j )}(h5from the source tree: - all C source files + headers h](j)}(hfrom the source tree:h]hfrom the source tree:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjubj )}(hhh]j8)}(hhh]j=)}(hall C source files + headers h]h)}(hall C source files + headersh]hall C source files + headers}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj0ubah}(h]h ]h"]h$]h&]uh1j<hj-ubah}(h]h ]h"]h$]h&]jjuh1j7hhhKhj*ubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hhhKhjubj )}(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:}(hj^hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjZubj )}(hhh]j8)}(hhh](j=)}(hall C source files + headersh]h)}(hjth]hall C source files + headers}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjrubah}(h]h ]h"]h$]h&]uh1j<hjoubj=)}(hall .gcda and .gcno filesh]h)}(hjh]hall .gcda and .gcno files}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1j<hjoubj=)}(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&]uh1j<hjoubeh}(h]h ]h"]h$]h&]jjuh1j7hhhKhjlubah}(h]h ]h"]h$]h&]uh1jhjZubeh}(h]h ]h"]h$]h&]uh1j hhhKhjubeh}(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&]uh1j<hjhhhhhNubah}(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]j=)}(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:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubj)}(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:}(hj3hhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhj/ubj )}(hhh]j8)}(hhh](j=)}(hall .gcda filesh]h)}(hjIh]hall .gcda files}(hjKhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjGubah}(h]h ]h"]h$]h&]uh1j<hjDubj=)}(hall links to .gcno files h]h)}(hall links to .gcno filesh]hall links to .gcno files}(hjbhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj^ubah}(h]h ]h"]h$]h&]uh1j<hjDubeh}(h]h ]h"]h$]h&]jjuh1j7hhhKhjAubah}(h]h ]h"]h$]h&]uh1jhj/ubeh}(h]h ]h"]h$]h&]uh1j hhhKhj,ubah}(h]h ]h"]h$]h&]uh1jhjubh)}(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&]uh1hhhhKhjubh)}(h.Example directory setup on the build machine::h]h-Example directory setup on the build machine:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubh)}(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&]jjuh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1jhhhKhjubeh}(h]h ]h"]h$]h&]uh1j<hjhhhhhNubah}(h]jah ]h"] gcov-buildah$]h&]jjjhjjstartKuh1jhjhhhhhKj}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&]hjuh1jhKhjhhhhjKubh)}(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.}(hj7hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h]note-on-compilersah ]h"]note on compilersah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(hTroubleshootingh]hTroubleshooting}(hjPhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjMhhhhhKubj)}(hhh](j )}(h/Problem Compilation aborts during linker step. h](j)}(hProblemh]hProblem}(hjehhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKhjaubj )}(hhh]h)}(h&Compilation aborts during linker step.h]h&Compilation aborts during linker step.}(hjvhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjsubah}(h]h ]h"]h$]h&]uh1jhjaubeh}(h]h ]h"]h$]h&]uh1j hhhKhj^ubj )}(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&]uh1jhhhKhjubj )}(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&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hhhKhj^hhubj )}(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&]uh1jhhhKhjubj )}(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&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j hhhKhj^hhubj )}(h`):h](hFSample script to gather coverage meta files on the build machine (see }(hjhhhNhNubh)}(h7:ref:`Separated build and test machines a. `h]hinline)}(hjh]h$Separated build and test machines a.}(hj hhhNhNubah}(h]h ](xrefstdstd-refeh"]h$]h&]uh1j hjubah}(h]h ]h"]h$]h&]refdocdev-tools/gcov refdomainj reftyperef refexplicitrefwarn reftarget gcov-testuh1hhhhKhjubh):}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(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}uh1hhhhKhjhhubeh}(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}(hjI hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjF 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 }(hjW hhhNhNubh)}(h8:ref:`Separated build and test machines b. `h]j )}(hja h]h$Separated build and test machines b.}(hjc hhhNhNubah}(h]h ](j stdstd-refeh"]h$]h&]uh1j hj_ ubah}(h]h ]h"]h$]h&]refdocj refdomainjm reftyperef refexplicitrefwarnj gcov-builduh1hhhhMhjW ubh):}(hjW hhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhMhjF hhubh)}(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&]jjj9 j: shj< }uh1hhhhMhjF 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]jallvm-cov]jaurefids}(j]jaj]jaunameids}(j j jjjjjjjjjIjFjkjhjjjjjjjjjJjGj4j1jjjC j@ j j u nametypes}(j jjjjjIjkjjjjjJj4jjC j uh}(j hjjjjjjjj"jFjjhjLjjnjjjjjjjGjj$jj1j+jjMj@ jj jF 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)}(hj; hhhNhNubah}(h]h ]h"]h$]h&]uh1hhj8 ubah}(h]h ]h"]h$]h&]levelKtypeINFOsourcehlineKuh1j6 hjhhhhhKubj7 )}(hhh]h)}(h'Duplicate explicit target name: "gcov".h]h+Duplicate explicit target name: “gcov”.}(hjW hhhNhNubah}(h]h ]h"]h$]h&]uh1hhjT ubah}(h]h ]h"]h$]h&]j$alevelKtypejQ lineKsourcehuh1j6 hjhhhhhKubetransform_messages](j7 )}(hhh]h)}(hhh]h/Hyperlink target "gcov-test" is not referenced.}hjt sbah}(h]h ]h"]h$]h&]uh1hhjq ubah}(h]h ]h"]h$]h&]levelKtypejQ sourcehlineKuh1j6 ubj7 )}(hhh]h)}(hhh]h0Hyperlink target "gcov-build" is not referenced.}hj sbah}(h]h ]h"]h$]h&]uh1hhj ubah}(h]h ]h"]h$]h&]levelKtypejQ sourcehlineKuh1j6 ube transformerN include_log] decorationNhhub.