Add translations to dev-tools gcov Signed-off-by: Bernard Zhao <bern...@vivo.com> --- .../translations/zh_CN/dev-tools/gcov.rst | 274 ++++++++++++++++++ 1 file changed, 274 insertions(+) create mode 100644 Documentation/translations/zh_CN/dev-tools/gcov.rst
diff --git a/Documentation/translations/zh_CN/dev-tools/gcov.rst b/Documentation/translations/zh_CN/dev-tools/gcov.rst new file mode 100644 index 000000000000..5ebbc55e5881 --- /dev/null +++ b/Documentation/translations/zh_CN/dev-tools/gcov.rst @@ -0,0 +1,274 @@ +Chinese translated version of Documentation/dev-tools/gcov.rst + +If you have any comment or update to the content, please contact the +original document maintainer directly. However, if you have a problem +communicating in English you can also ask the Chinese maintainer for +help. Contact the Chinese maintainer if this translation is outdated +or if there is a problem with the translation. + +Chinese maintainer: Bernard Zhao <bern...@vivo.com> +--------------------------------------------------------------------- +Documentation/dev-tools/gcov.rst ??????????????? + +?????????????????????????????????????????????????????????????????????????????????????????????????????? +?????????????????????????????????????????????????????????????????????????????????????????????????????? +???????????????????????????????????????????????? + +????????????????????? ????????? Bernard Zhao <bern...@vivo.com> +????????????????????? ????????? Bernard Zhao <bern...@vivo.com> + +??????????????? +--------------------------------------------------------------------- + +???Linux???????????????gcov???????????????????????? +=============================== +gcov???linux???????????????????????????????????????????????????????????????GCC????????????????????? +????????????????????? +linux?????????????????????????????????????????????gcov????????????????????????debug-fs????????? +?????????????????????????????????????????????????????????????????????????????????????????????????????? +???????????????????????????root???????????? + + # cd /tmp/linux-out + # gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c + +????????????????????????????????????????????????????????????????????????????????????????????????????????? +?????????????????????????????????????????????????????????gcov?????????????????????lcov?????? +????????????????????????linux kernel??????????????????????????????????????????????????????HTML??? +???????????? + +?????????????????? + +* ??????????????????????????????????????????????????????????????? +* ?????????????????????????????????????????????????????????????????????????????????????????? +* ????????????????????????????????????config????????????????????????????????????????????????????????? +??????????????????????????? + +gcov???lcov??????????????? +.. _gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html +.. _lcov: http://ltp.sourceforge.net/coverage/lcov.php + + +?????? +----------- + +????????????????????? + + CONFIG_DEBUG_FS=y + CONFIG_GCOV_KERNEL=y + +????????????????????????????????????????????????????????? + + CONFIG_GCOV_PROFILE_ALL=y + +???????????????????????????kernel??????????????????????????????kernel?????????????????????????????? +??????kernel?????????????????????????????? +????????????????????????????????????????????????kernel???????????????????????? + +?????????????????????????????????debugfs????????????????????????????????? + + mount -t debugfs none /sys/kernel/debug + + +????????? +------------- + +???????????????????????????????????????????????????????????????????????????????????????kernel????????? +??????Makefile??????????????????????????? + +- ?????????????????????????????????main.o??? + + GCOV_PROFILE_main.o := y + +- ??????????????????????????? + + GCOV_PROFILE := y + +??????????????????kernel???????????????????????????CONFIG_GCOV_PROFILE_ALL?????????????????? +???????????????????????????????????????????????????????????? + +- ??????????????????????????????main.o??? + + GCOV_PROFILE_main.o := n + +- ???????????????????????? + + GCOV_PROFILE := n + + +??????????????? +------------- + +gcov???????????????debugfs????????????????????? + +``/sys/kernel/debug/gcov`` + gcov???????????????????????? + +``/sys/kernel/debug/gcov/reset`` + gcov???????????????????????????????????????????????????gcov???????????????0 + +``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda`` + gcov???????????????????????????????????????????????? + +``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno`` + gcov???????????????????????????????????????????????????????????????????????????????????????????????? + ???gcc??????????????????????????????-ftest-coverage??????????????? + + +??????module????????? +------- + +kernel?????????????????????????????????????????????????????????????????????????????????????????? +gcov???????????????????????????????????????????????????????????????????????????????????????????????????????????? +????????????????????????????????????debugfs????????????????????? +??????????????????????????????????????????????????????????????????????????????debugfs????????????????????? + +???????????????????????????gcov_persist??????????????????gcov???module?????????????????? + + gcov_persist = 0 + +???????????????????????????????????????????????????????????????????????????gcov??????????????????????????? +????????????????????? + + +?????????????????????????????? +--------------------------------- + +gcov??????????????????????????????????????????????????????????????????????????????????????????????????? +?????????????????????????????? +????????????????????????????????????????????????????????????????????????????????????????????????gcov tools +???????????????????????? + +a) gcov?????????????????????????????? + + ??????????????????gcov??????????????????????????????????????????????????????gcc?????????????????? + ?????????????????????????????????????????????????????????????????? + + ?????????????????? + - ?????????C?????????????????? + + ????????????????????? + - ?????????C?????????????????? + - ?????????.gcda?????????.gcno?????? + - ????????????????????? + + ??????????????????????????????????????????????????????????????????????????????????????????????????????????????? + ???????????????????????????????????????????????????????????????????????????make??????????????????????????? + CURDIR??????????????? + +b) gcov?????????????????????????????? + + ???????????????????????????????????????????????????????????????????????????????????????????????? + + ???sysfs??????gcov???????????? + - ?????????.gcda?????? + - ?????????.gcno??????????????? + + ????????????????????????????????????????????????????????????gcov??????-o?????????????????????????????? + + ????????????????????????????????????????????? + /tmp/linux: ?????????????????? + /tmp/out: ???????????????????????????make O=????????? + /tmp/coverage: ???????????????????????????????????????????????? + + [user@build] cd /tmp/out + [user@build] gcov -o /tmp/coverage/tmp/out/init main.c + + +?????????????????????????????? +----------------- + +GCC???LLVM gcov???????????????????????? +??????????????????GCC?????????gcov_?????????.gcno???.gcda??????????????????Clang???????????? +?????????llvm-cov_??? + +gcc gcov???llvm cov??????????????? +.. _gcov: https://gcc.gnu.org/onlinedocs/gcc/Gcov.html +.. _llvm-cov: https://llvm.org/docs/CommandGuide/llvm-cov.html + +GCC???Clang gcov????????????????????????Kconfig???????????? +kconfig??????????????????????????????????????????????????????gcov????????? + +???????????? +--------------- + +?????????????????????1 + ????????????????????????????????? + +???????????? + ???????????????????????????????????????????????????????????????????????????????????????????????? + +???????????? + ?????????Makefile?????????GCOV_PROFILE := n?????? + GCOV_PROFILE_basename.o := n???????????????????????????????????? + +?????????????????????2 + ?????????sysfs???????????????????????????????????? + +???????????? + ??????seq_file???????????????????????????????????????cp???tar??????????????????????????? + sysfs??????????????? + +???????????? + ??????cat??????.gcda???????????????cp -d?????????????????????????????????B???????????? + ????????? + + +??????A???collect_on_build.sh +------------------------------ + +?????????????????????????????????????????????????????????????????????????????? + +.. code-block:: sh + + #!/bin/bash + + KSRC=$1 + KOBJ=$2 + DEST=$3 + + if [ -z "$KSRC" ] || [ -z "$KOBJ" ] || [ -z "$DEST" ]; then + echo "Usage: $0 <ksrc directory> <kobj directory> <output.tar.gz>" >&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 + + +??????B???collect_on_test.sh +----------------------------- + +?????????????????????????????????????????????????????????????????????????????? + +.. code-block:: sh + + #!/bin/bash -e + + DEST=$1 + GCDA=/sys/kernel/debug/gcov + + if [ -z "$DEST" ] ; then + echo "Usage: $0 <output.tar.gz>" >&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" -- 2.31.0