Gcov: Enable Code coverage reporting over UART.
This patch provides support for generating Code coverage reports. The prj.conf needs to enable CONFIG_COVERAGE. Once enabled, the code coverage data dump now comes via UART. This data dump on the UART is triggered once the main thread exits. Next step is to save this data dump on file. Then run scripts/gen_gcov_files.py with the serial console log as argument. The last step would be be to run the gcovr. Use the following cmd gcovr -r . --html -o gcov_report/coverage.html --html-details Currently supported architectures are ARM and x86. Signed-off-by: Adithya Baglody <adithya.nagaraj.baglody@intel.com>
This commit is contained in:
parent
e223cfa9dd
commit
71e90f98fd
3 changed files with 24 additions and 0 deletions
|
@ -162,6 +162,7 @@ config PRIVILEGED_STACK_TEXT_AREA
|
||||||
|
|
||||||
config KOBJECT_TEXT_AREA
|
config KOBJECT_TEXT_AREA
|
||||||
int "Size if kobject text area"
|
int "Size if kobject text area"
|
||||||
|
default 512 if COVERAGE_GCOV
|
||||||
default 256 if (!SIZE_OPTIMIZATIONS || STACK_CANARIES || ARC)
|
default 256 if (!SIZE_OPTIMIZATIONS || STACK_CANARIES || ARC)
|
||||||
default 256 if CODE_DATA_RELOCATION
|
default 256 if CODE_DATA_RELOCATION
|
||||||
default 128
|
default 128
|
||||||
|
|
|
@ -41,6 +41,18 @@
|
||||||
__object_access_end = .;
|
__object_access_end = .;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef CONFIG_COVERAGE_GCOV
|
||||||
|
/* Section needed by gcov when coverage is turned on.*/
|
||||||
|
SECTION_PROLOGUE (gcov, (OPTIONAL),)
|
||||||
|
{
|
||||||
|
PROVIDE_HIDDEN (__init_array_start = .);
|
||||||
|
KEEP (*(SORT(.init_array.*)))
|
||||||
|
KEEP (*(.init_array*))
|
||||||
|
PROVIDE_HIDDEN (__init_array_end = .);
|
||||||
|
} GROUP_LINK_IN(ROMABLE_REGION)
|
||||||
|
#endif /* CONFIG_COVERAGE_GCOV */
|
||||||
|
|
||||||
SECTION_PROLOGUE (devconfig, (OPTIONAL),)
|
SECTION_PROLOGUE (devconfig, (OPTIONAL),)
|
||||||
{
|
{
|
||||||
__devconfig_start = .;
|
__devconfig_start = .;
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <logging/log_ctrl.h>
|
#include <logging/log_ctrl.h>
|
||||||
#include <tracing.h>
|
#include <tracing.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <misc/gcov.h>
|
||||||
|
|
||||||
#define IDLE_THREAD_NAME "idle"
|
#define IDLE_THREAD_NAME "idle"
|
||||||
#define LOG_LEVEL CONFIG_KERNEL_LOG_LEVEL
|
#define LOG_LEVEL CONFIG_KERNEL_LOG_LEVEL
|
||||||
|
@ -156,6 +157,10 @@ void _bss_zero(void)
|
||||||
(void)memset(&__app_bss_start, 0,
|
(void)memset(&__app_bss_start, 0,
|
||||||
((u32_t) &__app_bss_end - (u32_t) &__app_bss_start));
|
((u32_t) &__app_bss_end - (u32_t) &__app_bss_start));
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef CONFIG_COVERAGE_GCOV
|
||||||
|
(void)memset(&__gcov_bss_start, 0,
|
||||||
|
((u32_t) &__gcov_bss_end - (u32_t) &__gcov_bss_start));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,6 +257,9 @@ static void bg_thread_main(void *unused1, void *unused2, void *unused3)
|
||||||
|
|
||||||
main();
|
main();
|
||||||
|
|
||||||
|
/* Dump coverage data once the main() has exited. */
|
||||||
|
gcov_coverage_dump();
|
||||||
|
|
||||||
/* Terminate thread normally since it has no more work to do */
|
/* Terminate thread normally since it has no more work to do */
|
||||||
_main_thread->base.user_options &= ~K_ESSENTIAL;
|
_main_thread->base.user_options &= ~K_ESSENTIAL;
|
||||||
}
|
}
|
||||||
|
@ -453,6 +461,9 @@ extern uintptr_t __stack_chk_guard;
|
||||||
*/
|
*/
|
||||||
FUNC_NORETURN void _Cstart(void)
|
FUNC_NORETURN void _Cstart(void)
|
||||||
{
|
{
|
||||||
|
/* gcov hook needed to get the coverage report.*/
|
||||||
|
gcov_static_init();
|
||||||
|
|
||||||
#ifdef CONFIG_MULTITHREADING
|
#ifdef CONFIG_MULTITHREADING
|
||||||
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
|
#ifdef CONFIG_ARCH_HAS_CUSTOM_SWAP_TO_MAIN
|
||||||
struct k_thread *dummy_thread = NULL;
|
struct k_thread *dummy_thread = NULL;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue