-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
libs: add gcov framework support #14838
base: master
Are you sure you want to change the base?
Conversation
profile-generate is used to generate compilation feedback optimization data, not just code coverage data It will rely on the toolchain library: nuttx/libs/libc/misc/lib_utsname.c:94:(.text.uname+0x2c): undefined reference to `__gcov_indirect_call_profiler_v4' arm-none-eabi-ld: nuttx/libs/libc/misc/lib_utsname.c:113:(.text.uname+0x178): undefined reference to `__gcov_indirect_call' arm-none-eabi-ld: nuttx/libs/libc/misc/lib_utsname.c:113:(.text.uname+0x188): undefined reference to `__gcov_time_profiler_counter' arm-none-eabi-ld: nuttx/staging/libc.a(lib_utsname.o):(.data..LPBX0+0x30): undefined reference to `__gcov_merge_time_profile' Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
[Experimental Bot, please feedback here] This PR appears to mostly meet the NuttX requirements, but is lacking in key details. Here's a breakdown: Strengths:
Weaknesses:
Recommendations for Improvement:
By addressing these points, the PR will be much more complete and easier for reviewers to evaluate. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice @Gary-Hobson your commit log message included all needed information to let people start to using it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you @Gary-Hobson :-)
endif | ||
|
||
ifeq ($(CONFIG_COVERAGE_MINI)$(CONFIG_ARCH_TOOLCHAIN_GCC),yy) | ||
CSRCS += gcov.c |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
coverage.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This cannot have the same name as coverage.c in compiler-rt. When compiling using makefile, it will search for coverage.c in the compiler-rt directory, causing it to not find the correct symbol when linking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's use the full path
6698258
to
9a4c7dc
Compare
{ | ||
} | ||
|
||
void __gcov_dump(void) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not implement __gcov_dump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The toolchain already has an implementation of __gcov_dump. I think you can use the default one most of the time. If necessary, we can reimplement __gcov_dump
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but this is mini version, how can we enable toolchain and mini version at the same time?
In devices without storage media, you can export data to the command line and then generate the corresponding gcda file It can save the result output by calling __gcov_info_to_gcda The usage is similar to: https://gcc.gnu.org/onlinedocs/gcc/Freestanding-Environments.html#Profiling-and-Test-Coverage-in-Freestanding-Environments Usage: ./tools/configure.sh qemu-armv7a:nsh Modify the configuration +CONFIG_COVERAGE_ALL=y +CONFIG_COVERAGE_MINI=y +CONFIG_SYSTEM_GCOV=y Run: qemu-system-arm -cpu cortex-a7 -nographic -smp 4 \ -machine virt,virtualization=off,gic-version=2 \ -net none -chardev stdio,id=con,mux=on -serial chardev:con \ -mon chardev=con,mode=readline -kernel ./nuttx/nuttx -semihosting -s | tee gcov.txt ./nuttx/tools/gcov_convert.py -i ./gcov.txt ./nuttx/tools/gcov.sh -t arm-none-eabi-gcov Signed-off-by: yinshengkai <yinshengkai@xiaomi.com>
@Gary-Hobson please consider creating later a Guide (https://nuttx.apache.org/docs/latest/guides/index.html) to use GCOV with NuttX using these commands you included in the commit log. |
Yes, we will upload the documentation for checking code coverage in different environments later Currently, we support gcc, clang, simulator, device, it will take some time to verify all environments |
Summary
libs: add gcov framework support
In devices without storage media, you can export data to the
command line and then generate the corresponding gcda file
It can save the result output by calling __gcov_info_to_gcda
The usage is similar to:
https://gcc.gnu.org/onlinedocs/gcc/Freestanding-Environments.html#Profiling-and-Test-Coverage-in-Freestanding-Environments
Usage:
./tools/configure.sh qemu-armv7a:nsh
Modify the configuration
Run:
Impact
Testing
qemu