1
0
Fork 0
forked from nuttx/nuttx-update

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>
This commit is contained in:
wangmingrong1 2024-11-14 16:01:00 +08:00 committed by Xiang Xiao
parent b6f6cadf93
commit 17ce9b86c1
28 changed files with 48 additions and 50 deletions

View file

@ -116,8 +116,8 @@ if(CONFIG_STACK_USAGE_WARNING AND NOT "${CONFIG_STACK_USAGE_WARNING}" STREQUAL
add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING}) add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING})
endif() endif()
if(CONFIG_SCHED_GCOV) if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage) add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
endif() endif()
if(CONFIG_PROFILE_ALL) if(CONFIG_PROFILE_ALL)

View file

@ -117,8 +117,8 @@ if(CONFIG_STACK_USAGE_WARNING AND NOT "${CONFIG_STACK_USAGE_WARNING}" STREQUAL
add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING}) add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING})
endif() endif()
if(CONFIG_SCHED_GCOV_ALL) if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage) add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
endif() endif()
if(CONFIG_PROFILE_ALL) if(CONFIG_PROFILE_ALL)

View file

@ -127,7 +127,7 @@ if(CONFIG_STACK_USAGE_WARNING AND NOT "${CONFIG_STACK_USAGE_WARNING}" STREQUAL
add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING}) add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING})
endif() endif()
if(CONFIG_SCHED_GCOV_ALL) if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage) add_compile_options(-fprofile-generate -ftest-coverage)
endif() endif()

View file

@ -88,7 +88,7 @@ if(CONFIG_STACK_USAGE_WARNING AND NOT "${CONFIG_STACK_USAGE_WARNING}" STREQUAL
add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING}) add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING})
endif() endif()
if(CONFIG_SCHED_GCOV_ALL) if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage) add_compile_options(-fprofile-generate -ftest-coverage)
endif() endif()

View file

@ -83,6 +83,6 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
nuttx_find_toolchain_lib(libsupc++.a) nuttx_find_toolchain_lib(libsupc++.a)
endif() endif()
if(CONFIG_SCHED_GCOV) if(CONFIG_COVERAGE_TOOLCHAIN)
nuttx_find_toolchain_lib(libgcov.a) nuttx_find_toolchain_lib(libgcov.a)
endif() endif()

View file

@ -502,7 +502,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif endif
ifeq ($(CONFIG_SCHED_GCOV),y) ifeq ($(CONFIG_COVERAGE_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif endif

View file

@ -215,7 +215,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif endif
ifeq ($(CONFIG_SCHED_GCOV),y) ifeq ($(CONFIG_COVERAGE_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif endif

View file

@ -56,7 +56,7 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
OUTPUT_VARIABLE extra_library) OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library}) list(APPEND EXTRA_LIB ${extra_library})
endif() endif()
if(CONFIG_SCHED_GCOV) if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process( execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS} COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a --print-file-name=libgcov.a

View file

@ -159,7 +159,7 @@ if(${CONFIG_STACK_USAGE_WARNING})
endif() endif()
endif() endif()
if(CONFIG_SCHED_GCOV_ALL) if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage) add_compile_options(-fprofile-generate -ftest-coverage)
endif() endif()

View file

@ -61,7 +61,7 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
list(APPEND EXTRA_LIB ${extra_library}) list(APPEND EXTRA_LIB ${extra_library})
endif() endif()
if(CONFIG_SCHED_GCOV) if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process( execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS} COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a --print-file-name=libgcov.a

View file

@ -417,7 +417,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif endif
ifeq ($(CONFIG_SCHED_GCOV),y) ifeq ($(CONFIG_COVERAGE_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif endif

View file

@ -86,7 +86,7 @@ if(CONFIG_STACK_USAGE_WARNING)
add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING}) add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING})
endif() endif()
if(CONFIG_SCHED_GCOV_ALL) if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage) add_compile_options(-fprofile-generate -ftest-coverage)
endif() endif()

View file

@ -27,7 +27,7 @@ set(HOSTSRCS)
set(HOST_INCLUDE_DIRS) set(HOST_INCLUDE_DIRS)
set(STDLIBS pthread) set(STDLIBS pthread)
if(CONFIG_SCHED_GCOV) if(CONFIG_COVERAGE_TOOLCHAIN)
list(APPEND STDLIBS gcov) list(APPEND STDLIBS gcov)
endif() endif()

View file

@ -50,7 +50,7 @@
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
#ifdef CONFIG_SCHED_GCOV #ifndef CONFIG_COVERAGE_NONE
void __gcov_dump(void); void __gcov_dump(void);
#endif #endif
@ -72,7 +72,7 @@ extern int backtrace(void **array, int size);
void host_abort(int status) void host_abort(int status)
{ {
#ifdef CONFIG_SCHED_GCOV #ifndef CONFIG_COVERAGE_NONE
/* Dump gcov data. */ /* Dump gcov data. */
host_uninterruptible_no_return(__gcov_dump); host_uninterruptible_no_return(__gcov_dump);

View file

@ -84,7 +84,7 @@ if(CONFIG_STACK_CANARIES)
add_compile_options(-fstack-protector-all) add_compile_options(-fstack-protector-all)
endif() endif()
if(CONFIG_SCHED_GCOV_ALL) if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage) add_compile_options(-fprofile-generate -ftest-coverage)
endif() endif()

View file

@ -60,7 +60,7 @@ if(CONFIG_TRICORE_TOOLCHAIN_GNU)
OUTPUT_VARIABLE extra_library) OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library}) list(APPEND EXTRA_LIB ${extra_library})
endif() endif()
if(CONFIG_SCHED_GCOV) if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process( execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS} COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a --print-file-name=libgcov.a

View file

@ -58,7 +58,7 @@ ifneq ($(CONFIG_STACK_USAGE_WARNING),0)
ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING) ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING)
endif endif
ifeq ($(CONFIG_SCHED_GCOV_ALL),y) ifeq ($(CONFIG_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif endif
@ -183,7 +183,7 @@ ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif endif
ifeq ($(CONFIG_SCHED_GCOV),y) ifeq ($(CONFIG_COVERAGE_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif endif

View file

@ -75,7 +75,7 @@ if(${CONFIG_STACK_USAGE_WARNING})
endif() endif()
endif() endif()
if(CONFIG_SCHED_GCOV_ALL) if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage) add_compile_options(-fprofile-generate -ftest-coverage)
endif() endif()

View file

@ -61,7 +61,7 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
list(APPEND EXTRA_LIB ${extra_library}) list(APPEND EXTRA_LIB ${extra_library})
endif() endif()
if(CONFIG_SCHED_GCOV) if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process( execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS} COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a --print-file-name=libgcov.a

View file

@ -56,7 +56,7 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
OUTPUT_VARIABLE extra_library) OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library}) list(APPEND EXTRA_LIB ${extra_library})
endif() endif()
if(CONFIG_SCHED_GCOV) if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process( execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS} COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a --print-file-name=libgcov.a

View file

@ -199,7 +199,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif endif
ifeq ($(CONFIG_SCHED_GCOV),y) ifeq ($(CONFIG_COVERAGE_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif endif

View file

@ -203,7 +203,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif endif
ifeq ($(CONFIG_SCHED_GCOV),y) ifeq ($(CONFIG_COVERAGE_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a)) EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libgcov.a))
endif endif

View file

@ -74,8 +74,12 @@ ifneq ($(CONFIG_STACK_USAGE_WARNING),0)
ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING) ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING)
endif endif
ifeq ($(CONFIG_SCHED_GCOV_ALL),y) ifeq ($(CONFIG_COVERAGE_ALL),y)
ifeq ($(CONFIG_ARCH_TOOLCHAIN_GCC),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
else ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHOPTIMIZATION += -fprofile-instr-generate -fcoverage-mapping
endif
endif endif
ifneq ($(CONFIG_PROFILE_ALL)$(CONFIG_SIM_PROFILE),) ifneq ($(CONFIG_PROFILE_ALL)$(CONFIG_SIM_PROFILE),)

View file

@ -27,7 +27,6 @@ KBIN = libkbuiltin$(LIBEXT)
KBINDIR = kbin KBINDIR = kbin
include compiler-rt/Make.defs include compiler-rt/Make.defs
include libgcc/Make.defs include libgcc/Make.defs
AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT))) AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT)))

View file

@ -96,6 +96,11 @@ if(CONFIG_BUILTIN_COMPILER_RT)
list(REMOVE_ITEM RT_BUILTINS_SRCS ${RT_BUILTINS_BFLOAT16_SRCS}) list(REMOVE_ITEM RT_BUILTINS_SRCS ${RT_BUILTINS_BFLOAT16_SRCS})
endif() endif()
if(NOT CONFIG_COVERAGE_NONE)
target_compile_options(rt.buitlins -fno-profile-instr-generate
-fno-coverage-mapping)
endif()
target_sources(rt.buitlins PRIVATE ${RT_BUILTINS_SRCS}) target_sources(rt.buitlins PRIVATE ${RT_BUILTINS_SRCS})
endif() endif()
@ -108,6 +113,9 @@ if(CONFIG_COVERAGE_COMPILER_RT)
rt.profile PRIVATE ${INCDIR} rt.profile PRIVATE ${INCDIR}
${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile) ${CMAKE_CURRENT_LIST_DIR}/compiler-rt/lib/profile)
target_compile_options(rt.profile -fno-profile-instr-generate
-fno-coverage-mapping)
target_compile_options(rt.profile PRIVATE -DCOMPILER_RT_HAS_UNAME -Wno-undef target_compile_options(rt.profile PRIVATE -DCOMPILER_RT_HAS_UNAME -Wno-undef
-Wno-strict-prototypes -Wno-shadow) -Wno-strict-prototypes -Wno-shadow)
@ -124,5 +132,9 @@ if(CONFIG_COVERAGE_COMPILER_RT)
elseif(CONFIG_COVERAGE_MINI) elseif(CONFIG_COVERAGE_MINI)
nuttx_add_system_library(rt.miniprofile) nuttx_add_system_library(rt.miniprofile)
target_compile_options(rt.miniprofile -fno-profile-instr-generate
-fno-coverage-mapping)
target_sources(rt.profile PRIVATE ${CMAKE_CURRENT_LIST_DIR}/coverage.c) target_sources(rt.profile PRIVATE ${CMAKE_CURRENT_LIST_DIR}/coverage.c)
endif() endif()

View file

@ -98,6 +98,7 @@ ifeq ($(CONFIG_COVERAGE_COMPILER_RT),y)
FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile FLAGS += ${INCDIR_PREFIX}$(CURDIR)/compiler-rt/compiler-rt/lib/profile
FLAGS += -fno-profile-instr-generate -fno-coverage-mapping
FLAGS += -Wno-undef -Wno-strict-prototypes -Wno-shadow FLAGS += -Wno-undef -Wno-strict-prototypes -Wno-shadow
FLAGS += -DCOMPILER_RT_HAS_UNAME FLAGS += -DCOMPILER_RT_HAS_UNAME
@ -107,6 +108,8 @@ CSRCS += InstrProfilingPlatform.c
else ifeq ($(CONFIG_COVERAGE_MINI),y) else ifeq ($(CONFIG_COVERAGE_MINI),y)
FLAGS += -fno-profile-instr-generate -fno-coverage-mapping
CSRCS += coverage.c CSRCS += coverage.c
endif endif

View file

@ -1348,26 +1348,6 @@ config SCHED_STACK_RECORD
to disable.Through instrumentation, record the backtrace at to disable.Through instrumentation, record the backtrace at
the deepest point in the stack. the deepest point in the stack.
config SCHED_GCOV
bool "Enable GCOV support"
select HAVE_CXXINITIALIZE
default n
---help---
Enable GCOV support for code coverage analysis.
After turning on this option, code coverage can be analyzed.
If this option is enabled, image size and performance will be
significantly reduced. Before use, you need to add the
"-fprofile-generate -ftest-coverage" compilation parameters
to the file to be analyzed.
config SCHED_GCOV_ALL
bool "Enable gcov call graph for all modules"
depends on SCHED_GCOV
default n
---help---
Enable gcov profiling for all code, it will instrument
all code, which will cause a large performance penalty for the code.
endmenu endmenu
menu "Files and I/O" menu "Files and I/O"

View file

@ -659,7 +659,7 @@ endef
# CLEAN - Default clean target # CLEAN - Default clean target
ifeq ($(CONFIG_SCHED_GCOV),y) ifeq ($(CONFIG_COVERAGE_NONE),)
EXTRA = *.gcno *.gcda EXTRA = *.gcno *.gcda
endif endif