Skip to content

Commit 8a7f83e

Browse files
author
Mohammad Azim Khan
committed
Added code comments
1 parent ef1f902 commit 8a7f83e

File tree

6 files changed

+26
-3
lines changed

6 files changed

+26
-3
lines changed

platform/retarget.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,18 @@ extern const char __stderr_name[] = "/stderr";
7373
#endif
7474

7575
#if defined MBED_CFG_DEBUG_OPTIONS_COVERAGE
76+
/* Coverage sync flag used between greentea_client\source\test_env.cpp:greentea_notify_completion()
77+
* and _open() to indicate that file is being open by gcov.
78+
*/
7679
bool coverage_report = false;
80+
81+
/* Special file descriptor for gcov report. It helps in special handling of gcov report file, that
82+
* is printing data on serial console rather than writing on file system.
83+
*/
7784
const int gcov_fd = 'g' + ((int)'c' << 8);
7885

79-
void greentea_notify_coverage_start(const char *path);
80-
void greentea_notify_coverage_end(void);
86+
extern void greentea_notify_coverage_start(const char *path);
87+
extern void greentea_notify_coverage_end(void);
8188
#endif
8289

8390
// Heap limits - only used if set
@@ -188,6 +195,7 @@ extern "C" FILEHANDLE PREFIX(_open)(const char* name, int openmode) {
188195
#if defined MBED_CFG_DEBUG_OPTIONS_COVERAGE
189196
else if(coverage_report) {
190197
init_serial();
198+
// Encapsulate coverage data in greentea key,value pair.
191199
greentea_notify_coverage_start(name);
192200
return gcov_fd;
193201
}
@@ -252,6 +260,7 @@ extern "C" int PREFIX(_close)(FILEHANDLE fh) {
252260
return 0;
253261
#if defined MBED_CFG_DEBUG_OPTIONS_COVERAGE
254262
else if (coverage_report && gcov_fd == fh) {
263+
// Close greentea key,value encapsulation
255264
greentea_notify_coverage_end();
256265
return 0;
257266
}

rtos/rtx/TARGET_CORTEX_M/cmsis_os.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@
8989
#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE/2)
9090
#else
9191
#if defined (MBED_CFG_DEBUG_OPTIONS_COVERAGE)
92+
/* GCOV works with stack size approx. 32K. */
9293
#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4*8)
9394
#else
9495
#define DEFAULT_STACK_SIZE (WORDS_STACK_SIZE*4)

targets/TARGET_Freescale/TARGET_KSDK2_MCUS/TARGET_MCU_K64F/device/TOOLCHAIN_GCC_ARM/MK64FN1M0xxx12.ld

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ ENTRY(Reset_Handler)
5252

5353
__ram_vector_table__ = 1;
5454

55-
/* Heap 1/4 of ram and stack 1/8 */
55+
/* Heap 1/4 of ram and stack 1/8. 0x1000 is reduced from both heap
56+
* and stack to accomodate static data introduced by GCOV.
57+
*/
5658
__stack_size__ = 0x7000;
5759
__heap_size__ = 0x09000;
5860

tools/build_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ def prepare_toolchain(src_paths, target, toolchain_name,
299299
config - a Config object to use instead of creating one
300300
app_config - location of a chosen mbed_app.json file
301301
build_profile - a dict of flags that will be passed to the compiler
302+
coverage_filter - list of regex to filter source files for enabling coverage
302303
"""
303304

304305
# We need to remove all paths which are repeated to avoid
@@ -400,6 +401,7 @@ def build_project(src_paths, build_path, target, toolchain_name,
400401
config - a Config object to use instead of creating one
401402
app_config - location of a chosen mbed_app.json file
402403
build_profile - a dict of flags that will be passed to the compiler
404+
coverage_filter - list of regex to filter source files for enabling coverage
403405
"""
404406

405407
# Convert src_path to a list if needed
@@ -540,6 +542,7 @@ def build_library(src_paths, build_path, target, toolchain_name,
540542
properties - UUUUHHHHH beats me
541543
extra_verbose - even more output!
542544
project_id - the name that goes in the report
545+
coverage_filter - list of regex to filter source files for enabling coverage
543546
remove_config_header_file - delete config header file when done building
544547
app_config - location of a chosen mbed_app.json file
545548
build_profile - a dict of flags that will be passed to the compiler

tools/test_api.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2119,6 +2119,9 @@ def build_tests(tests, base_source_paths, build_path, target, toolchain_name,
21192119
"""Given the data structure from 'find_tests' and the typical build parameters,
21202120
build all the tests
21212121
2122+
Keyword arguments:
2123+
coverage_filter - list of regex to filter source files for enabling coverage
2124+
21222125
Returns a tuple of the build result (True or False) followed by the test
21232126
build data structure"""
21242127

tools/toolchains/gcc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,11 @@ def __init__(self, target, notify=None, macros=None,
8484
self.cpu.append("-mfloat-abi=hard")
8585
self.cpu.append("-mno-unaligned-access")
8686

87+
# Coverage is turned On if coverage_filter is not empty. This means all sources are compiled with coverage
88+
# macro and application is linked with coverage flags.
89+
# Only source files that match regex from coverage_filter list are compiled with coverage flags. Since turning
90+
# On code coverage on all sources increases static data size it overlaps with stack allocation and causes linker
91+
# error.
8792
self.coverage_filter = coverage_filter
8893
if self.coverage_filter:
8994
self.macros.append(self.COVERAGE_MACRO)

0 commit comments

Comments
 (0)