Can't Enable GCOV in VSCode

User avatar
kozmotronik
Posts: 23
Joined: Wed Jan 29, 2025 8:28 am

Can't Enable GCOV in VSCode

Postby kozmotronik » Tue Jul 08, 2025 11:11 am

Hi,

I've tried to enable code coverage for unit testing in many ways but with no success. I follow instructions from https://docs.espressif.com/projects/vsc ... f-coverage page.

According to this guide I need to execute the following command to enable apptracing and gcov:

Code: Select all

ESP-IDF: Configure Project SDKConfig for Coverage
. When I execute it I get the following output:
{"version": 2, "set": { "APPTRACE_DEST_TRAX": true, "APPTRACE_GCOV_ENABLE": true }}

{"version":2,"save":"/disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig"}
---------------------------ERROR--------------------------

Error: The following config symbol(s) were not found: APPTRACE_DEST_TRAX, APPTRACE_GCOV_ENABLE

-----------------------END OF ERROR-----------------------
{"version": 2, "values": {}, "ranges": {}, "visible": {}, "error": ["The following config symbol(s) were not found: APPTRACE_DEST_TRAX, APPTRACE_GCOV_ENABLE"]}


Saving config to /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig...

{"version": 2, "values": {}, "ranges": {}, "visible": {}}
And a popup shows me this message:
Your project sdkconfig has been configured. Make sure to compile the source file with the --coverage option.
Then I've tried to set them manually in SDK Config interface, but nothing exists below the Component config about Application Level Tracing.
vscode-esp-idf-no-gcov.png
vscode-esp-idf-no-gcov.png (105.22 KiB) Viewed 5168 times
I've also tried with the idf.py menuconfig command, searched for apptrace options but found nothing about.

I really can't see those config symbols neither in the SDK Config interface nor in the sdkconfig file itself. Ain't those symbols should be generated automatically by Kconfig? How do I enable gcov for code coverage in this case?

It is a test app that implement unit tests on a custom component I develop. What is the key thing that I am missing? Is it something has to do with cmake configuration? Thank you.

For reference, here is some information about my setup:
OS: Linux
ESP-IDF SDK version: 5.4.2
Project repo: https://git.kozmotronik.com.tr/Kozmotro ... /test_apps

User avatar
kozmotronik
Posts: 23
Joined: Wed Jan 29, 2025 8:28 am

Re: Can't Enable GCOV in VSCode

Postby kozmotronik » Tue Jul 08, 2025 11:57 am

I've tried adding the path of the app_trace as IDF_PATH/components as below but didn't work.

I've also tried adding those config symbols to a sdkconfig.defaults file as below:

Code: Select all

# For IDF 5.0
CONFIG_ESP_TASK_WDT_EN=n

# For IDF4.4
CONFIG_ESP_TASK_WDT=n

CONFIG_APPTRACE_DEST_UART=y
# CONFIG_APPTRACE_DEST_NONE is not set
CONFIG_APPTRACE_ENABLE=y
CONFIG_APPTRACE_LOCK_ENABLE=y
CONFIG_APPTRACE_ONPANIC_HOST_FLUSH_TMO=-1
CONFIG_APPTRACE_POSTMORTEM_FLUSH_THRESH=0
CONFIG_APPTRACE_PENDING_DATA_SIZE_MAX=0
CONFIG_APPTRACE_GCOV_ENABLE=y
But when I clean and reopen the SDK Config UI I get the following output:
Loading defaults file /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults...
/disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults:5 CONFIG_ESP_TASK_WDT was replaced with CONFIG_ESP_TASK_WDT_INIT
warning: unknown kconfig symbol 'APPTRACE_DEST_UART' assigned to 'y' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_DEST_NONE' assigned to 'n' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_ENABLE' assigned to 'y' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_LOCK_ENABLE' assigned to 'y' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_ONPANIC_HOST_FLUSH_TMO' assigned to '-1' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_POSTMORTEM_FLUSH_THRESH' assigned to '0' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_PENDING_DATA_SIZE_MAX' assigned to '0' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
warning: unknown kconfig symbol 'APPTRACE_GCOV_ENABLE' assigned to 'y' in /disk/Projeler/ESP-Components/relay_chn/test_apps/sdkconfig.defaults
Are those symbols deprecated or what?

bignacio
Espressif staff
Espressif staff
Posts: 255
Joined: Wed May 02, 2018 12:12 pm

Re: Can't Enable GCOV in VSCode

Postby bignacio » Thu Jul 17, 2025 4:32 am

I think there is an issue with your project configuration.

please review the Code coverage example https://github.com/espressif/esp-idf/tr ... ystem/gcov

User avatar
kozmotronik
Posts: 23
Joined: Wed Jan 29, 2025 8:28 am

Re: Can't Enable GCOV in VSCode

Postby kozmotronik » Thu Jul 24, 2025 8:07 am

Hi @bignacio,

Thanks for the answer, but the example does not help to solve the problem.

It turns out that this problem arises because the ESP-IDF can't find the configuration of the app_trace component. Although this wasn't mentioned in the relevant docs or the gcov example, the component should be declared in the test_app/main/CMakeLists.txt file as a REQUIRED component.

Code: Select all

idf_component_register(
    SRCS ${srcs}
    INCLUDE_DIRS "."
    REQUIRES unity relay_chn app_trace
    WHOLE_ARCHIVE
)

Who is online

Users browsing this forum: No registered users and 0 guests