Skip to content

Commit

Permalink
gcov: Correct existing gcov configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
W-M-R committed Dec 30, 2024
1 parent 9922371 commit c581d35
Show file tree
Hide file tree
Showing 28 changed files with 43 additions and 50 deletions.
4 changes: 2 additions & 2 deletions arch/arm/src/cmake/armclang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
endif()

if(CONFIG_SCHED_GCOV)
add_compile_options(-fprofile-generate -ftest-coverage)
if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
endif()

if(CONFIG_PROFILE_ALL)
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/src/cmake/clang.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
endif()

if(CONFIG_SCHED_GCOV_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-instr-generate -fcoverage-mapping)
endif()

if(CONFIG_PROFILE_ALL)
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/cmake/gcc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
endif()

if(CONFIG_SCHED_GCOV_ALL)
if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/cmake/ghs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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})
endif()

if(CONFIG_SCHED_GCOV_ALL)
if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/src/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,6 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
nuttx_find_toolchain_lib(libsupc++.a)
endif()

if(CONFIG_SCHED_GCOV)
if(CONFIG_COVERAGE_TOOLCHAIN)
nuttx_find_toolchain_lib(libgcov.a)
endif()
2 changes: 1 addition & 1 deletion arch/arm/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif

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

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif

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

Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/src/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library})
endif()
if(CONFIG_SCHED_GCOV)
if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ if(${CONFIG_STACK_USAGE_WARNING})
endif()
endif()

if(CONFIG_SCHED_GCOV_ALL)
if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
list(APPEND EXTRA_LIB ${extra_library})
endif()

if(CONFIG_SCHED_GCOV)
if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a
Expand Down
2 changes: 1 addition & 1 deletion arch/risc-v/src/common/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif

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

Expand Down
2 changes: 1 addition & 1 deletion arch/sim/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ if(CONFIG_STACK_USAGE_WARNING)
add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING})
endif()

if(CONFIG_SCHED_GCOV_ALL)
if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/sim/src/sim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ set(HOSTSRCS)
set(HOST_INCLUDE_DIRS)
set(STDLIBS pthread)

if(CONFIG_SCHED_GCOV)
if(CONFIG_COVERAGE_TOOLCHAIN)
list(APPEND STDLIBS gcov)
endif()

Expand Down
4 changes: 2 additions & 2 deletions arch/sim/src/sim/posix/sim_hostmisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
* Public Function Prototypes
****************************************************************************/

#ifdef CONFIG_SCHED_GCOV
#ifndef CONFIG_COVERAGE_NONE
void __gcov_dump(void);
#endif

Expand All @@ -72,7 +72,7 @@ extern int backtrace(void **array, int size);

void host_abort(int status)
{
#ifdef CONFIG_SCHED_GCOV
#ifndef CONFIG_COVERAGE_NONE
/* Dump gcov data. */

host_uninterruptible_no_return(__gcov_dump);
Expand Down
2 changes: 1 addition & 1 deletion arch/tricore/src/cmake/ToolchainGnuc.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if(CONFIG_STACK_CANARIES)
add_compile_options(-fstack-protector-all)
endif()

if(CONFIG_SCHED_GCOV_ALL)
if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/tricore/src/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ if(CONFIG_TRICORE_TOOLCHAIN_GNU)
OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library})
endif()
if(CONFIG_SCHED_GCOV)
if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a
Expand Down
4 changes: 2 additions & 2 deletions arch/tricore/src/common/ToolchainGnuc.defs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ ifneq ($(CONFIG_STACK_USAGE_WARNING),0)
ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING)
endif

ifeq ($(CONFIG_SCHED_GCOV_ALL),y)
ifeq ($(CONFIG_COVERAGE_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
endif

Expand Down Expand Up @@ -183,7 +183,7 @@ ifeq ($(CONFIG_LIBSUPCXX),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif

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

Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/src/cmake/Toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ if(${CONFIG_STACK_USAGE_WARNING})
endif()
endif()

if(CONFIG_SCHED_GCOV_ALL)
if(CONFIG_COVERAGE_ALL)
add_compile_options(-fprofile-generate -ftest-coverage)
endif()

Expand Down
2 changes: 1 addition & 1 deletion arch/x86_64/src/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
list(APPEND EXTRA_LIB ${extra_library})
endif()

if(CONFIG_SCHED_GCOV)
if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ if(CONFIG_LIBSUPCXX_TOOLCHAIN)
OUTPUT_VARIABLE extra_library)
list(APPEND EXTRA_LIB ${extra_library})
endif()
if(CONFIG_SCHED_GCOV)
if(CONFIG_COVERAGE_TOOLCHAIN)
execute_process(
COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_FLAG_ARGS} ${NUTTX_EXTRA_FLAGS}
--print-file-name=libgcov.a
Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/lx6/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif

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

Expand Down
2 changes: 1 addition & 1 deletion arch/xtensa/src/lx7/Toolchain.defs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ ifeq ($(CONFIG_LIBSUPCXX_TOOLCHAIN),y)
EXTRA_LIBS += $(wildcard $(shell $(CC) $(ARCHCPUFLAGS) --print-file-name=libsupc++.a))
endif

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

Expand Down
8 changes: 6 additions & 2 deletions boards/sim/sim/sim/scripts/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,12 @@ ifneq ($(CONFIG_STACK_USAGE_WARNING),0)
ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING)
endif

ifeq ($(CONFIG_SCHED_GCOV_ALL),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
ifeq ($(CONFIG_COVERAGE_ALL),y)
ifeq ($(CONFIG_ARCH_TOOLCHAIN_GCC),y)
ARCHOPTIMIZATION += -fprofile-generate -ftest-coverage
else ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y)
ARCHOPTIMIZATION += -fprofile-instr-generate -fcoverage-mapping
endif
endif

ifneq ($(CONFIG_PROFILE_ALL)$(CONFIG_SIM_PROFILE),)
Expand Down
1 change: 0 additions & 1 deletion libs/libbuiltin/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ KBIN = libkbuiltin$(LIBEXT)
KBINDIR = kbin

include compiler-rt/Make.defs

include libgcc/Make.defs

AOBJS = $(addprefix $(BINDIR)$(DELIM), $(ASRCS:.S=$(OBJEXT)))
Expand Down
7 changes: 7 additions & 0 deletions libs/libbuiltin/compiler-rt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@ if(CONFIG_COVERAGE_COMPILER_RT)
rt.profile PRIVATE ${INCDIR}
${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
-Wno-strict-prototypes -Wno-shadow)

Expand All @@ -149,5 +152,9 @@ if(CONFIG_COVERAGE_COMPILER_RT)

elseif(CONFIG_COVERAGE_MINI)
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)
endif()
3 changes: 3 additions & 0 deletions libs/libbuiltin/compiler-rt/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ ifeq ($(CONFIG_COVERAGE_COMPILER_RT),y)

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 += -DCOMPILER_RT_HAS_UNAME

Expand All @@ -107,6 +108,8 @@ CSRCS += InstrProfilingPlatform.c

else ifeq ($(CONFIG_COVERAGE_MINI),y)

FLAGS += -fno-profile-instr-generate -fno-coverage-mapping

CSRCS += coverage.c

endif
Expand Down
20 changes: 0 additions & 20 deletions sched/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1348,26 +1348,6 @@ config SCHED_STACK_RECORD
to disable.Through instrumentation, record the backtrace at
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

menu "Files and I/O"
Expand Down
2 changes: 1 addition & 1 deletion tools/Config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ endef

# CLEAN - Default clean target

ifeq ($(CONFIG_SCHED_GCOV),y)
ifeq ($(CONFIG_COVERAGE_NONE),)
EXTRA = *.gcno *.gcda
endif

Expand Down

0 comments on commit c581d35

Please sign in to comment.