From 8f41a3b95e6a3f46d8aa6a99b082188764d055c8 Mon Sep 17 00:00:00 2001 From: wangmingrong1 Date: Thu, 14 Nov 2024 16:10:59 +0800 Subject: [PATCH] gcov: arm,arm64 add coverage global --- arch/arm/src/common/Toolchain.defs | 8 ++++++++ arch/arm64/src/Toolchain.defs | 8 ++++++++ arch/arm64/src/cmake/Toolchain.cmake | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index b68f94dc0c..9d4c9942b1 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -72,6 +72,14 @@ ifneq ($(CONFIG_STACK_USAGE_WARNING),0) ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING) endif +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 + ifeq ($(CONFIG_PROFILE_ALL),y) ARCHOPTIMIZATION += -pg endif diff --git a/arch/arm64/src/Toolchain.defs b/arch/arm64/src/Toolchain.defs index bafa0251f8..8345442984 100644 --- a/arch/arm64/src/Toolchain.defs +++ b/arch/arm64/src/Toolchain.defs @@ -104,6 +104,14 @@ ifeq ($(CONFIG_ARCH_INSTRUMENT_ALL),y) ARCHOPTIMIZATION += -finstrument-functions endif +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 + ifeq ($(CONFIG_PROFILE_ALL),y) ARCHOPTIMIZATION += -pg endif diff --git a/arch/arm64/src/cmake/Toolchain.cmake b/arch/arm64/src/cmake/Toolchain.cmake index e0783be82f..ed5fee4005 100644 --- a/arch/arm64/src/cmake/Toolchain.cmake +++ b/arch/arm64/src/cmake/Toolchain.cmake @@ -135,6 +135,14 @@ if(CONFIG_ARCH_INSTRUMENT_ALL) add_compile_options(-finstrument-functions) endif() +if(CONFIG_COVERAGE_ALL) + if(CONFIG_ARCH_TOOLCHAIN_GCC) + add_compile_options(-fprofile-generate -ftest-coverage) + elseif(CONFIG_ARCH_TOOLCHAIN_CLANG) + add_compile_options(-fprofile-instr-generate -fcoverage-mapping) + endif() +endif() + if(CONFIG_PROFILE_ALL) add_compile_options(-pg) endif()