{"action":"created","issue":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/3180","repository_url":"https://api.github.com/repos/ARMmbed/mbed-os","labels_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/3180/labels{/name}","comments_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/3180/comments","events_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/3180/events","html_url":"https://github.com/ARMmbed/mbed-os/pull/3180","id":186570425,"number":3180,"title":"Enable Code Coverage using gcov","user":{"login":"mazimkhan","id":13520658,"avatar_url":"https://avatars.githubusercontent.com/u/13520658?v=3","gravatar_id":"","url":"https://api.github.com/users/mazimkhan","html_url":"https://github.com/mazimkhan","followers_url":"https://api.github.com/users/mazimkhan/followers","following_url":"https://api.github.com/users/mazimkhan/following{/other_user}","gists_url":"https://api.github.com/users/mazimkhan/gists{/gist_id}","starred_url":"https://api.github.com/users/mazimkhan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mazimkhan/subscriptions","organizations_url":"https://api.github.com/users/mazimkhan/orgs","repos_url":"https://api.github.com/users/mazimkhan/repos","events_url":"https://api.github.com/users/mazimkhan/events{/privacy}","received_events_url":"https://api.github.com/users/mazimkhan/received_events","type":"User","site_admin":false},"labels":[{"id":144902129,"url":"https://api.github.com/repos/ARMmbed/mbed-os/labels/needs:%20work","name":"needs: work","color":"fbca04","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":31,"created_at":"2016-11-01T15:54:34Z","updated_at":"2016-11-04T12:58:36Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/pulls/3180","html_url":"https://github.com/ARMmbed/mbed-os/pull/3180","diff_url":"https://github.com/ARMmbed/mbed-os/pull/3180.diff","patch_url":"https://github.com/ARMmbed/mbed-os/pull/3180.patch"},"body":"# Code Coverage (GCOV)\r\n\r\nGCOV based code coverage can be enabled by compiling and linking code with flags `-fprofile-arcs -ftest-coverage`. Optimisation should be disabled with flag `-O0` and debug symbols added with `-g` flags. An additional coverage macro `-DMBED_CFG_DEBUG_OPTIONS_COVERAGE` is added to code the instrumentation required for moving coverage data from embedded platform to the host machine under it.\r\n## GCOV Impact on application\r\n\r\nEnabling gcov profiling has an impact on binary size and stack requirement. Stack size has been increased in `rtos/rtx/TARGET_CORTEX_M/cmsis_os.h` under coverage macro. \r\n\r\nIt has not been possible to compile whole of mbed-os with coverage flags as it increases static data part of the binary making heap and stack overlap. Typically giving following error:\r\n\r\n```\r\n[DEBUG] Errors: c:/program files (x86)/gnu tools arm embedded/4.9 2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: region m_data_2 overflowed with stack and\r\n heap\r\n```\r\n\r\nor\r\n\r\n```\r\n[DEBUG] Errors: c:/program files (x86)/gnu tools arm embedded/4.9 2015q3/bin/../lib/gcc/arm-none-eabi/4.9.3/../../../../arm-none-eabi/bin/ld.exe: C:/Users/azikha01/Documents/GitHub/mazimkhan/mbed\r\n-os/.build/tests/K64F/GCC_ARM/./TESTS/integration/basic/basic.elf section `.bss' will not fit in region `m_data_2'\r\n```\r\n\r\nHeap and stack size are reduced a little in below file to fit individual modules: `hal/targets/cmsis/TARGET_Freescale/TARGET_MCU_K64F/TOOLCHAIN_GCC_ARM/MK64FN1M0xxx12.ld`.\r\n\r\nStill whole mbed-os does not fit the memory. For this reason below build tool changes are made to selectively turn On coverage on parts mbed-os source.\r\n## Build tools changes\r\n\r\nA new option is passed down `test.py` to `class GCC` that adds coverage flags to `gcc` compiler:\r\nOption synopsis:\r\n`--coverage-filter <regex to match source path> [--coverage-filter <regex to match source path>]` \r\nThis new option collects all supplied filters (regex) into a list. Coverage is turned on if list is not empty.\r\n\r\n`test.py` also enables coverage on test case sources when coverage filter is supplied. This is because for gcov to initialise it should also be enabled on the file containing `main()`.\r\n## Code changes\r\n\r\ngcov flags make the application write profiling data on disk per source file profiled. Embedded applications that do not have file-system require instrumentation to print coverage report on serial console that can be read and consolidated by a host application (greentea). \r\nMainly `open`, `write` and `close` wrappers in `retartget.cpp` are modified to channel gcov file data to serial console.\r\n"},"comment":{"url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/comments/258424226","html_url":"https://github.com/ARMmbed/mbed-os/pull/3180#issuecomment-258424226","issue_url":"https://api.github.com/repos/ARMmbed/mbed-os/issues/3180","id":258424226,"user":{"login":"adbridge","id":11191917,"avatar_url":"https://avatars.githubusercontent.com/u/11191917?v=3","gravatar_id":"","url":"https://api.github.com/users/adbridge","html_url":"https://github.com/adbridge","followers_url":"https://api.github.com/users/adbridge/followers","following_url":"https://api.github.com/users/adbridge/following{/other_user}","gists_url":"https://api.github.com/users/adbridge/gists{/gist_id}","starred_url":"https://api.github.com/users/adbridge/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adbridge/subscriptions","organizations_url":"https://api.github.com/users/adbridge/orgs","repos_url":"https://api.github.com/users/adbridge/repos","events_url":"https://api.github.com/users/adbridge/events{/privacy}","received_events_url":"https://api.github.com/users/adbridge/received_events","type":"User","site_admin":false},"created_at":"2016-11-04T12:58:36Z","updated_at":"2016-11-04T12:58:36Z","body":"One comment wrt using profiles. Looking at the mbed cli readme documentation , profiles are only mentioned in passing. I can't see any detailed explanation of why they are there or how they could/should be used by customers. Unless someone @theotherjimmy can point me to some? Thus if we are considering adding a profile for code coverage then we would need to document quite thoroughly how this could be edited for individual customer needs... "}}
{"actor":{"display_login":"adbridge"}}