Add translations to dev-tools gcov Signed-off-by: Bernard Zhao <bern...@vivo.com>
--- Changes since V2: * fix some inaccurate translation Changes since V1: * add index.rst in dev-tools and link to to zh_CN/index.rst * fix some inaccurate translation --- .../translations/zh_CN/dev-tools/gcov.rst | 261 ++++++++++++++++++ .../translations/zh_CN/dev-tools/index.rst | 35 +++ Documentation/translations/zh_CN/index.rst | 1 + 3 files changed, 297 insertions(+) create mode 100644 Documentation/translations/zh_CN/dev-tools/gcov.rst create mode 100644 Documentation/translations/zh_CN/dev-tools/index.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..882eee4c75c5 --- /dev/null +++ b/Documentation/translations/zh_CN/dev-tools/gcov.rst @@ -0,0 +1,261 @@ +.. include:: ../disclaimer-zh_CN.rst + +:Original: Documentation/dev-tools/gcov.rst +:Translator: ????????? Bernard Zhao <bern...@vivo.com> + +???Linux???????????????gcov???????????????????????? +========================================= + +gcov???linux???????????????????????????????????????????????????????????????GCC????????????????????? +????????????????????? +linux?????????????????????????????????????????????gcov????????????????????????debug-fs????????? +?????????gcov???``-o``?????????????????????????????????????????????????????????????????????????????? +???????????????????????????????????????????????????root?????????:: + + # cd /tmp/linux-out + # gcov -o /sys/kernel/debug/gcov/tmp/linux-out/kernel spinlock.c + +??????????????????????????????????????????????????????????????????????????? +?????????????????????????????????????????????????????????gcov_?????????????????????lcov_??????????????? +???????????????linux ????????????????????????????????????????????????????????????HTML??????????????? + +???????????????: + +* ??????????????????????????????????????????????????????????????? +* ?????????????????????????????????????????????????????????????????????????????????????????? +* ??????????????????????????????????????????????????????????????????????????????????????????????????? +??????????????????????????? + +_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 + +??????????????????????????????????????????????????????????????????????????????????????????????????? +?????????????????????????????????????????? +?????????????????????????????????????????????????????????????????????????????? + +?????????????????????????????????debugfs??????????????????????????????:: + + mount -t debugfs none /sys/kernel/debug + + +????????? +------------- + +?????????????????????????????????????????????????????????????????????????????????????????????????????? +??????Makefile????????????????????????: + +- ?????????????????????????????????main.o???:: + + GCOV_PROFILE_main.o := y + +- ???????????????????????????:: + + GCOV_PROFILE := y + +???????????????????????????????????????????????????CONFIG_GCOV_PROFILE_ALL?????????????????? +?????????????????????????????????????????????????????????:: + + GCOV_PROFILE_main.o := n + +???:: + + GCOV_PROFILE := n + +??????????????????????????????????????????????????????????????????????????? + + +???????????? +------------- + +gcov???????????????debugfs?????????????????????: + +``/sys/kernel/debug/gcov`` + gcov???????????????????????? + +``/sys/kernel/debug/gcov/reset`` + ??????????????????:??????????????????????????????????????????gcov???????????????0 + +``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcda`` + gcov?????????????????????????????????????????????????????????????????????????????? + ??????????????????gcov???????????????0 + +``/sys/kernel/debug/gcov/path/to/compile/dir/file.gcno`` + gcov???????????????????????????????????????????????????????????????????????????????????????????????? + ???gcc??????????????????????????????``-ftest-coverage``??????????????? + + +????????????????????? +--------------- + +???????????????????????????????????????????????????????????????????????????????????????????????? +gcov???????????????????????????????????????????????????????????????????????????????????????????????????????????? +????????????????????????????????????debugfs????????????????????? +??????????????????????????????????????????????????????????????????????????????debugfs????????????????????? + +???????????????????????????gcov_persist??????????????????gcov????????????????????????:: + + gcov_persist = 0 + +???????????????????????????????????????????????????????????????????????????gcov??????????????????????????? +????????????????????? + + +?????????????????????????????? +--------------------- + +gcov??????????????????????????????????????????????????????????????????????????????????????????????????? +?????????????????????????????? +????????????????????????????????????????????????????????????????????????????????????????????????gcov?????? +?????????????????????: + +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_??? + +_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 +------------------------------ + +??????????????????????????????????????????????????????????????????????????????. +?????????6a????????? + +.. 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 +----------------------------- + +?????????????????????????????????????????????????????????????????????????????? +?????????6b????????? + +.. 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" diff --git a/Documentation/translations/zh_CN/dev-tools/index.rst b/Documentation/translations/zh_CN/dev-tools/index.rst new file mode 100644 index 000000000000..28b256ad4257 --- /dev/null +++ b/Documentation/translations/zh_CN/dev-tools/index.rst @@ -0,0 +1,35 @@ +.. include:: ../disclaimer-zh_CN.rst + +:Original: Documentation/dev-tools/index.rst +:Translator: ????????? Bernard Zhao <bern...@vivo.com> + +================================ +?????????????????? +================================ + +?????????????????????????????????????????????????????? +?????????????????????????????????????????????????????????????????????????????? +????????????????????? + +.. class:: toc-title + + ?????? + +.. toctree:: + :maxdepth: 2 + + gcov + +Todolist: + + coccinelle + sparse + kcov + kasan + ubsan + kmemleak + kcsan + gdb-kernel-debugging + kgdb + kselftest + kunit/index diff --git a/Documentation/translations/zh_CN/index.rst b/Documentation/translations/zh_CN/index.rst index be6f11176200..a5e483b0c7f2 100644 --- a/Documentation/translations/zh_CN/index.rst +++ b/Documentation/translations/zh_CN/index.rst @@ -20,6 +20,7 @@ process/index filesystems/index arm64/index + dev-tools/index ??????????????? ---------- -- 2.31.0