Gcov Report generate using MCUExpresso 11.4.0

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Gcov Report generate using MCUExpresso 11.4.0

Jump to solution
18,559 Views
HCPATEL99
Contributor II

I have trying to generate the lcov and gcov report for ".c" files base on evkIMXRT1170 with "Hello World" example code.

I have followed the gcov generation step from MCUExpresso IDE -> Help -> MCUExpresso IDE user guide.

From that I have tried to generate gcov report but it's showing "gcov files not found".

Can you explain briefly the all steps with screenshot.

Details :

Board : evkIMXRT1170 board

IDE : MCUExpresso 11.4.0

SDK Example : "Hello world " example code.

 

 

0 Kudos
Reply
1 Solution
18,364 Views
ErichStyger
Specialist I

Hi @HCPATEL99 ,

I don't own the i.MX RT1170 board, but I checked it with the i.MX RT1064 board I have and wrote a tutorial about using it:

https://mcuoneclipse.com/2021/09/19/tutorial-gnu-gcov-coverage-with-the-nxp-i-mx-rt1064/

That one works for me.

I hope this helps,

Erich

View solution in original post

21 Replies
18,257 Views
ErichStyger
Specialist I

Hi @HCPATEL99 ,

if  https://mcuoneclipse.com/2021/02/01/tutorial-gnu-coverage-with-mcuxpresso-ide/ does not help, check what has been generated in the 'debug' folder. The compiler shall generate .gcno files in there, and the application shall generate .gcda files. For the .gcda files you need to have a functional semihosting with file I/O supported, for example a SEGGER J-Link (that one can be loaded as firmware on the i.MX RT EVK board).

I hope this helps,

Erich

0 Kudos
Reply
18,229 Views
HCPATEL99
Contributor II

For me  https://mcuoneclipse.com/2021/02/01/tutorial-gnu-coverage-with-mcuxpresso-ide/ does not help.

After adding all the settings according to above link's steps I am able to generate the ".gcno" file at build the project stage also generated ".gcda" file at debug the project using the "J-Link Segger".

But, When I am trying to open the ".gcda" file there are not showing any results also no any pop or another chart window(graphical window).

Can you help me out for this below I have attached screenshot for my current settings for generating a ".gcda" report file for a single ".c" file.

0 Kudos
Reply
18,215 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi @HCPATEL99 ,

Following Erich's guide, I can see the graphical windows.  What is you OS?

jingpan_0-1631589920174.png

 

Regards,

Jing

 

 

0 Kudos
Reply
18,211 Views
HCPATEL99
Contributor II

Details About My Setup:

1). MCUExpresso Version: MCUXpresso IDE v11.4.0 [Build 6237] [2021-08-06]

    OS: Linux, v.5.4.0-81-generic, x86_64 / gtk 3.22.30, WebKit 2.32.3
    Java version: 11.0.10

2). PC OS Version : Linux harsiddhP-Desktop 18.04.1-Ubuntu SMP Fri Jul 23 13:36:29 UTC 2021    x86_64 x86_64 x86_64 GNU/Linux.

3) Board Details: evkIMXRT1170

4) Currently generating gcov and lcov report for below example code:

EX . evkmimxrt1170_hello_world_demo_cm7

0 Kudos
Reply
18,206 Views
ErichStyger
Specialist I

can you share a zip file of all files of that project?

Then one can see if it is a problem with the setup or with your host environment.

Erich

18,200 Views
HCPATEL99
Contributor II

Okay Sure,

Here I have attached all project files which is currently working on it.

If you have any issue then ,You can also import from MCUExpresso welcome page. According to below steps.

Go to -> import SDK example(s) -> select the "evkmimxrt1170" -> demo_apps -> select "hello_world_demo_cm7".

18,133 Views
jingpan
NXP TechSupport
NXP TechSupport

Hi,

I test your demo on my evk. I found that CMSIS-DAP can't read gcov data well. It will hang in gcov_write(). But jlink can. After finish, it can exit gcov_write(). You must wait nearly one minute till it finish download.

I'm win10. But I meet the same problem like you. I can't open .gcda. But I can open Erich's FRDM-K64F gcda.

I also attached Erich's project which has gcov result. Can you open it on your computer?

Regards,

Jing

18,122 Views
HCPATEL99
Contributor II

Hello Jingpan,

Here, I have imported(FRDM-K64F_gcov_bm - Project) your project files into my mcuexpresso environment.

Now, I can able to open the already generated "*.gcda" files from Debug->board folder.

I am thinking no any OS related issue or IDE related.

The thing is about the evk board only.

Are you using same evk (evkIMXRT1170)which one used by me?

0 Kudos
Reply
18,137 Views
ErichStyger
Specialist I

Thanks for sharing the files. At a high level, the settings look ok. I can open the gcov files on my machine (Windows, not sure if this matters), of course I needed to point to the different file location.

But the files are empty in the sense that no useful coverage information is collected.

I don't have your hardware at hand, so I have to check things otherwise if time permits.

Erich

0 Kudos
Reply
18,116 Views
HCPATEL99
Contributor II


Hello @ErichStyger ,

Here, I have imported(FRDM-K64F_gcov_bm - Project) project files into my mcuexpresso environment.

Now, I can able to open the already generated ".gcda" files from Debug->board folder.

Those files are given by Jingpan. He is also from nxp support team only.

I am thinking like no any OS related issue or IDE related.

The thing is about the evk board may be.So, What do you think ?

Can you do one favor for me , can you generate the gcov files for IMXRT1170 evk board on any platform whether it's windows or Linux OS asap.

And I will try same step here whether it's working or not for me.

0 Kudos
Reply
18,365 Views
ErichStyger
Specialist I

Hi @HCPATEL99 ,

I don't own the i.MX RT1170 board, but I checked it with the i.MX RT1064 board I have and wrote a tutorial about using it:

https://mcuoneclipse.com/2021/09/19/tutorial-gnu-gcov-coverage-with-the-nxp-i-mx-rt1064/

That one works for me.

I hope this helps,

Erich

18,066 Views
HCPATEL99
Contributor II

Hello @ErichStyger 

Thanks a Million ErichS.

Finally It's working for me.

But, Still I want one little help about how to export this "gcov" code coverage data into ".html" or any other format like ".csv".

Please give me any hint or any link those are previously generated this type of report.

Also I have tried opening this data into ".csv" fomat but it's showing internal error(from eclipse given tools).

Thanks in Advance....

0 Kudos
Reply
18,050 Views
ErichStyger
Specialist I

gcov comes as command line tool too, see

https://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html

For example you can export the data in JSON format.

I hope this helps,

Erich

 

 

0 Kudos
Reply
17,501 Views
HCPATEL99
Contributor II

Hello ErichS,

Thanks for all your reply.

After successfully generating code coverage for all files.

Some function lines are not instrumented as well as not executed by gcov library.

Can you give me some idea How can I cover up to 100% code coverage for all files?

Below I have attached an image for your reference.

I am waiting for your fantastic reply.

Thanks in advance....

 

0 Kudos
Reply
17,492 Views
ErichStyger
Specialist I

The reason is because there is no code behind your assignments to status, so it cannot be covered. Not sure if I should go into the topics and depths of 'basic blocks' and 'brancht tail merging' compiler-writer-lingo.

In short, there is no assignment to that status variable at all generated by the compiler, caused by optimizations. You might get code there if you turn off optimizations, or if you mark the status variable as volatile.

The compiler sees that you assign status in both branches (or basic blocks) and immediately return that value. So the compiler can load that directly into the register and no storage is needed.

Keep in mind that with coverage information you always will have such kind of things, especially with compiler optimizations. If you really want to tweak this, you will have to tweak the source code which as for myself would not do for this.

I hope this helps,

Erich

0 Kudos
Reply
17,486 Views
HCPATEL99
Contributor II

Hello Dear ErichS,

Thanks for your immediate reply.

It's very helpful for a conclusion on code coverage performance.

|----------------------------------------------------------------------------------------------------------------------------------------|

In short, there is no assignment to that status variable at all generated by the compiler, caused by optimizations. You might get code there if you turn off optimizations, or if you mark the status variable as volatile.

|-----------------------------------------------------------------------------------------------------------------------------------------|

- We have already performed make a status variable as volatile also it's executed well same as per your suggestion.

Scenario1: I have performed a coverage stub with no any optimization.

- Below image highlighted the "return status" statement not executed can you give me a reason?

Scenario2: But, I have another scenario when I enabled optimization level 3.

- Somehow Instrumentation coverage area increased due to this optimization level.

- Can you give me an explanation what is the role of optimization in code coverage?

0 Kudos
Reply
17,477 Views
ErichStyger
Specialist I

You need to understand that coverage information is collected by instrumentation points inserted by the compiler, and that things are driven by 'basic' blocks (continuous block of code executed). So not every line is instrumented, but the BB paths. The compiler links that back to source lines, but as with debugging/stepping, one single source line has a 1-n relationship to code pieces. Or in other words: one single assignment or statement might sprinkle into multiple code or BB locations.

Dwarf2 would be able to deal with the most complex cases, but the gcov data imho is not able to deal with this. So you always might find such a situation.

As for coverage information or reports: you always have to get through a manual exception/inspection phase, augmenting the information you have collected. I cannot rely on the machine data only.

I know this might be a complex topic or new to you, but I hope this helps understanding the process.

17,459 Views
HCPATEL99
Contributor II

Hello ErichS,

Once again Thank you so much.

I also need to understand that coverage information is collected by instrumentation points inserted by the compiler, but I didn't found any instrumentation data files means no any "gcov" files found.(Ex. test.c.gcov)

So, How can I find "gcov" files from MCUXpresso IDE and analyze  the instrumentation data for each line.

Can you give me  any suggestion or way for the same?

Thanks In Advance.....

 

 

 

 

0 Kudos
Reply
17,333 Views
ErichStyger
Specialist I

I'm sorry, I think I don't really undestand your question? The instrumentation happens on the object file level, not on the source file level.

In any case, see https://mcuoneclipse.com/2014/12/26/code-coverage-for-embedded-target-with-eclipse-gcc-and-gcov/ which describes the technology used.

I hope this helps,

Erich

18,241 Views
converse
Senior Contributor V