Skip to content

coverage: C++ fix loop in gcov_coverage_dump #31029

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 10, 2021
Merged

coverage: C++ fix loop in gcov_coverage_dump #31029

merged 1 commit into from
Jan 10, 2021

Conversation

mpoljanic
Copy link
Contributor

During coverage reports generation in C++ code gcov_coverage_dump()
function would get stuck in endless loop. Fix by checking list head
pointer with current list pointer.

Signed-off-by: Marko Poljanic [email protected]

Environment:
Host: macOS 11.1
Cross toolchain: gcc-arm-none-eabi-9-2020-q2-update

Steps to test the fix:
Test will run in qemu and dump gcov data to log.log file after that it is possible to generate .html coverage report.

  1. cd $ZEPHYR_BASE/tests/application_development/gen_inc_file

  2. west build -b mps2_an385 -- -DCONFIG_COVERAGE=y -DCONFIG_COVERAGE_GCOV=y -DCONFIG_COVERAGE_DUMP=y

  3. ninja -Cbuild run | tee log.log

  4. python3 $ZEPHYR_BASE/scripts/gen_gcov_files.py -i log.log

  5. cp src/main.cpp build/CMakeFiles/app.dir/src

  6. cd build/CMakeFiles/app.dir

  7. gcovr -r . --html -o coverage.html --html-details --gcov-executable <gcov_path_in_SDK>

Related to:
#20729

@mpoljanic mpoljanic requested a review from nashif as a code owner December 28, 2020 16:14
@github-actions github-actions bot added the area: Test Framework Issues related not to a particular test, but to the framework instead label Dec 28, 2020
@@ -23,7 +23,7 @@
K_HEAP_DEFINE(gcov_heap, MALLOC_MAX_HEAP_SIZE);


static struct gcov_info *gcov_info_head;
static struct gcov_info *gcov_info_head = NULL;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary: the pointer will be default initialized to zero by the C runtime startup.

@@ -247,6 +248,10 @@ void gcov_coverage_dump(void)

k_heap_free(&gcov_heap, buffer);
gcov_list = gcov_list->next;
if(gcov_list_first == gcov_list)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix style issues (spacing and brace placement):

if (gcov_list_first == gcov_list) {
	goto coverage_dump_end;
}

Copy link
Collaborator

@pabigot pabigot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks; looks good to me.

FWIW: the compliance check fails because your Author: name is in Unicode (Poljanić) while the signed-off-by isn't (Poljanic).

You can run this to check locally before pushing:

scripts/ci/check_compliance.py -c HEAD^..

@mpoljanic
Copy link
Contributor Author

Thanks; looks good to me.

FWIW: the compliance check fails because your Author: name is in Unicode (Poljanić) while the signed-off-by isn't (Poljanic).

You can run this to check locally before pushing:

scripts/ci/check_compliance.py -c HEAD^..

Great ! Thanks I will fix it 👍

During coverage reports generation in C++ code gcov_coverage_dump()
function would get stuck in endless loop. Fix by checking list head
pointer with current list pointer.

Signed-off-by: Marko Poljanić <[email protected]>
@nashif nashif merged commit 2b92ae3 into zephyrproject-rtos:master Jan 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Test Framework Issues related not to a particular test, but to the framework instead area: Testsuite Testsuite
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants