Commit graph

18 commits

Author SHA1 Message Date
wangmingrong1
893e67745b gcc/gcov: Add instrumentation function
Some functions will insert these functions:
void __gcov_execve(void)
{
}
void __gcov_execv(void)
{
}
void __gcov_fork(void)
{
}

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-12-03 23:51:12 +08:00
wangmingrong1
cdbf5c6ebe Fix compilation errors
CC:  gcov.c gcov.c: In function 'gcov_stdout_dump':
gcov.c:146:50: error: passing argument 3 of '__gcov_info_to_gcda' from incompatible pointer type [-Werror=incompatible-pointer-types]
  146 |       __gcov_info_to_gcda(info, stdout_filename, stdout_dump, NULL, &arg);
      |                                                  ^~~~~~~~~~~
      |                                                  |
      |                                                  void (*)(const void *, size_t,  void *) {aka void (*)(const void *, long unsigned int,  void *)}
In file included from gcov.c:25:
/mnt/vela/github/NX/nuttx/include/gcov.h:139:44: note: expected 'void (*)(const void *, unsigned int,  void *)' but argument is of type 'void (*)(const void *, size_t,  void *)' {aka 'void (*)(const void *, long unsigned int,  void *)'}
  139 |                                 FAR void (*dump)(FAR const void *,
      |                                     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~
  140 |                                                  unsigned int, FAR void *),
      |                                                  ~~~~~~~~~~~~~~~~~~~~~~~~~

libgcc/gcov.c: In function 'gcov_process_path.constprop':
libgcc/gcov.c:235:29: error: 'filename' may be used uninitialized [-Werror=maybe-uninitialized]
  235 |       tokens[token_count++] = filename;
      |       ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
libgcc/gcov.c:189:13: note: 'filename' was declared here
  189 |   FAR char *filename;

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-26 19:25:24 +08:00
wangmingrong1
47e33c6433 clang/gcov: Add a way to directly dump memory address
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-25 18:03:19 +08:00
wangmingrong1
a73217d1d6 Clang/gcov: Supports gcc standard output interface "__gcov_dump"
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-25 18:03:19 +08:00
yinshengkai
0413d74f31 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
+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>
2024-11-22 19:08:08 +08:00
wangmingrong1
1d04884812 gcov: Add toolchain gcov dependency option
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-21 21:32:06 +08:00
wangmingrong1
17ce9b86c1 gcov: Correct existing gcov configuration
1. add CONFIG_COVERAGE_ALL to replace CONFIG_SCHED_GCOV_ALL
2. Correct all SCHED_GCOV, SCHED_GCOV_ALL

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-15 01:05:16 +08:00
wangmingrong1
181f461145 libbuiltin/kconfig: Modify coverage function dependencies
Currently, there are four code coverage statistics implementations:
1. GCC native implementation
2. CLANG native implementation
3. GCC coverage nuttx mini version
4. CLANG coverage nuttx mini version
Coverage Support:
                                               GCC native implementation  CLANG native implementation  GCC coverage nuttx mini version  CLANG coverage nuttx mini version
Compiler version requirements                              ALL                       ALL                         GCC 13.2 and below             CLANG 17.0 and below
Program coverage statistics support   Main program          √                         √                                  √                               √
Program coverage statistics support   Interrupt program     X                         √                                  √                               √
Configuration options                         CONFIG_COVERAGE_TOOLCHAIN    CONFIG_COVERAGE_COMPILER_RT          CONFIG_COVERAGE_MINI            CONFIG_COVERAGE_MINI
Platform Support            ARM                             √                         √                                  √                               √
                            ARM64                           √                                                            √
                                                                                                            (Coming soon, not yet merged)

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-15 01:05:16 +08:00
wangmingrong1
b59e3616f4 gcov: Support for the most streamlined profile of LLVM-embedded-toolchain-for-Arm
1. Excerpted from: https://github.com/ARM-software/LLVM-embedded-toolchain-for-Arm/blob/main/samples/src/cpp-baremetal-semihosting-prof/proflib.c
2. Since llvm profile supports more than just gcov, and some features have not yet been explored, two clang gcov implementations are supported after this patch
3. Using this lib only supports the gcov compilation options of "-fprofile-instr-generate -fcoverage-mapping"
4. This file is heavily dependent on the compiler clang version, and is currently aligned with ci, supporting 17.0.1 and below. 18 and above are not supported by this library due to different internal implementations of the compiler

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-13 05:33:00 +08:00
wangmingrong1
bf93c7840a gprof: move gprof function from sched to libbuiltin/libgcc
1. Enable interrupt gprof please config CONFIG_PROFILE_MINI
2. Enable instuction gprof please add compile opt "-pg" or config CONFIG_PROFILE_ALL

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-13 02:42:31 +08:00
wangmingrong1
9facfade90 compiler_rt/cmake: Align compiler-rt/Make.defs
1. Remove unnecessary compilation options
2. Use * instead of examples one by one

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-12 16:12:53 +08:00
wangmingrong1
4232a717f2 libbuilin/compiler_rt: Organize make.defs and eliminate compilation warnings
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-12 16:12:53 +08:00
wangmingrong1
e3917e2f09 libbuitin/compiler_rt: Supports separate builtin rt.builtins or rt.profile
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-12 16:12:53 +08:00
wangmingrong1
f59edf8645 libbuiltin/Makefile: Modify the libbuiltin makefile to standard
1. bin and kbin folders are dynamically generated
2. Context comes before depend, so the bin and kbin folders are created in the context construction phase. When the depend process comes, each library is downloaded, and a relative bin/xxx and kbin/xxx directory is created for each library to place files. This is to prevent duplicate file names.

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-10 10:19:58 +08:00
wangmingrong1
4ba941e2b0 libbuiltin: Simplify makefile writing
Create a separate bin folder to place the generated .o files

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-11-07 01:13:25 +08:00
wangmingrong1
8461f0ea54 clang: Support compiling rt.profile library
1. Since the implementation of gcov has changed since clang17, versions before clang17 need to use the libunwind.a file

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-30 17:10:23 +08:00
wangmingrong1
20e33ed84a libbuitlin: distclean should delete all files
Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-28 22:19:58 +08:00
wangmingrong1
e174d73cd9 clang:libclang_rt.builtins-xxx.a supports builtin
1. enable CONFIG_BUILTIN_COMPILER_RT  to built libclang_rt.builtins-xxx.a and no longer use the compiler's built-in
2. Modify clang version acquisition to get two decimal points
3. It has been ported to support four architectures: ARM, ARM64, RISCV, and x86_64, among which ARM has been validated

Signed-off-by: wangmingrong1 <wangmingrong1@xiaomi.com>
2024-10-28 16:38:45 +08:00