From 8d5a22c3c1babdf8f9ca00813662da2aaa8e8d86 Mon Sep 17 00:00:00 2001 From: Enjia Mai Date: Fri, 4 Dec 2020 23:09:33 +0800 Subject: [PATCH] tests: enable the code coverage report for qemu_x86_64 Enable the code coverage report for qemu_x86_64 platform. See issue #17991 please. Signed-off-by: Enjia Mai --- boards/x86/qemu_x86/Kconfig.board | 1 + kernel/init.c | 2 +- subsys/testsuite/coverage/coverage.c | 6 +++--- subsys/testsuite/coverage/coverage_ram.ld | 16 +++++++++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/boards/x86/qemu_x86/Kconfig.board b/boards/x86/qemu_x86/Kconfig.board index 6671686fa5f..f00f2c0f934 100644 --- a/boards/x86/qemu_x86/Kconfig.board +++ b/boards/x86/qemu_x86/Kconfig.board @@ -12,3 +12,4 @@ config BOARD_QEMU_X86_64 depends on SOC_IA32 select QEMU_TARGET select X86_64 + select HAS_COVERAGE_SUPPORT diff --git a/kernel/init.c b/kernel/init.c index fdfda411c0a..9e2956a6b1d 100644 --- a/kernel/init.c +++ b/kernel/init.c @@ -108,7 +108,7 @@ void z_bss_zero(void) #endif /* CONFIG_CODE_DATA_RELOCATION */ #ifdef CONFIG_COVERAGE_GCOV (void)memset(&__gcov_bss_start, 0, - ((uint32_t) &__gcov_bss_end - (uint32_t) &__gcov_bss_start)); + ((uintptr_t) &__gcov_bss_end - (uintptr_t) &__gcov_bss_start)); #endif } diff --git a/subsys/testsuite/coverage/coverage.c b/subsys/testsuite/coverage/coverage.c index 767c4b2028d..965715e0d6f 100644 --- a/subsys/testsuite/coverage/coverage.c +++ b/subsys/testsuite/coverage/coverage.c @@ -258,9 +258,9 @@ coverage_dump_end: /* Initialize the gcov by calling the required constructors */ void gcov_static_init(void) { - extern uint32_t __init_array_start, __init_array_end; - uint32_t func_pointer_start = (uint32_t) &__init_array_start; - uint32_t func_pointer_end = (uint32_t) &__init_array_end; + extern uintptr_t __init_array_start, __init_array_end; + uintptr_t func_pointer_start = (uintptr_t) &__init_array_start; + uintptr_t func_pointer_end = (uintptr_t) &__init_array_end; while (func_pointer_start < func_pointer_end) { void (**p)(void); diff --git a/subsys/testsuite/coverage/coverage_ram.ld b/subsys/testsuite/coverage/coverage_ram.ld index 96b228b91d2..4a98045ddb3 100644 --- a/subsys/testsuite/coverage/coverage_ram.ld +++ b/subsys/testsuite/coverage/coverage_ram.ld @@ -31,7 +31,21 @@ __gcov_bss_num_words = ((__gcov_bss_end - __gcov_bss_start) >> 2); __gcov_bss_size = __gcov_bss_end - __gcov_bss_start; #endif -#ifdef CONFIG_X86 +#ifdef CONFIG_X86_64 +SECTION_PROLOGUE(_GCOV_BSS_SECTION_NAME, (NOLOAD), ALIGN(16)) +{ + MMU_PAGE_ALIGN + __gcov_bss_start = .; + *(".bss.__gcov0.*"); + . = ALIGN(8); + MMU_PAGE_ALIGN + __gcov_bss_end = .; +}GROUP_DATA_LINK_IN(RAMABLE_REGION, RAMABLE_REGION) + +__gcov_bss_num_words = ((__gcov_bss_end - __gcov_bss_start) >> 2); +__gcov_bss_size = __gcov_bss_end - __gcov_bss_start; + +#elif CONFIG_X86 SECTION_PROLOGUE(_GCOV_BSS_SECTION_NAME, (NOLOAD),) { MMU_PAGE_ALIGN