Project Home
Project Home
Source Code
Source Code
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Code Coverage: (10 Items)
   
Code Coverage  
I have a few questions about code coverage.

1) One of my applications acts as a TCP/IP server waiting for a connection to be established. Using code coverage with 
the code coverage data scan enabled (SIGUSR2, or any other signal for that matter) always stops after the first scan. 
Having raised the verbosity level of procnto I  get the following message:
Process 286732 (xyz_cov) terminated signo=0 code=0 by process 0 value=0.
Running the same application (in a qconn debug session) with the coverage tool tab disabled causes no problem, the appl 
keeps running. Did anyone had the same experience and found a solution for the application being terminated?

2) Can you run a code coverage session without the use of the IDE (no qconn) on the target ?

3) Generating a report within the Momentics IDE gives a report with html links to the source files showing the coverage 
for the code within the source file. When I save the report to xml file I only get an overview table with the coverage. 
I no longer can browse into the source files. Is this standard behaviour or do I miss something here?

Best regards,

Wim
Re: Code Coverage  

Wim Hellenthal wrote:
> I have a few questions about code coverage.
>
> 1) One of my applications acts as a TCP/IP server waiting for a connection to be established. Using code coverage with
 the code coverage data scan enabled (SIGUSR2, or any other signal for that matter) always stops after the first scan. 
Having raised the verbosity level of procnto I  get the following message:
> Process 286732 (xyz_cov) terminated signo=0 code=0 by process 0 value=0.
> Running the same application (in a qconn debug session) with the coverage tool tab disabled causes no problem, the 
appl keeps running. Did anyone had the same experience and found a solution for the application being terminated?
>   
I think your application just dies when receiving SIGUSR2. Normally code 
coverage library installs handler for this signal to periodically dump
coverage results, but sometimes application behavior gets in a way. You 
can disable this feature, this way you can only collect data when app 
exits but it won't die prematurely at least
> 2) Can you run a code coverage session without the use of the IDE (no qconn) on the target ?
>   
Yes. If you instrument it with code coverage it should just work (it 
will save data to a specific directory). You may need to set some env 
vars for that - check user guide. You can import this data later in the 
IDE or use gcov tool to view it.

> 3) Generating a report within the Momentics IDE gives a report with html links to the source files showing the 
coverage for the code within the source file. When I save the report to xml file I only get an overview table with the 
coverage. I no longer can browse into the source files. Is this standard behaviour or do I miss something here?
>   
XML file is just a data file,  it does not have hyprelinks.
> Best regards,
>
> Wim
>
>
>
> _______________________________________________
>
> General
> http://community.qnx.com/sf/go/post57050
>
>   
RE: Code Coverage  
1) For you first question about Code Coverage tool terminates your
application - Does you application have a signal handler which exit the
app when receive a signal? Code Coverage tool in IDE sends the signal to
suspend the app in order to collect dynamic changes to the Code Coverage
data. If you app can not be interrupted you can disable this option in
the launch configuration "Tools -> Code Coverage -> Advanced..." tab.
You won't get dynamic update in IDE but you should still be able to view
the Code Coverage result when your app exits normally.

2) Yes you can run without the IDE. After you collect the CC data
(.gcda) files you copy them to your host and import them in the IDE. Let
me know if you need more information on how to run it from command line.

3) When you save the report in XML format, you lose some formatting IDE
does when it applies the XSLT transform. So if you want the link to
source file you need to save it in HTML format.

-----Original Message-----
From: Wim Hellenthal [mailto:community-noreply@qnx.com] 
Sent: June 17, 2010 5:25 AM
To: general-toolchain
Subject: Code Coverage

I have a few questions about code coverage.

1) One of my applications acts as a TCP/IP server waiting for a
connection to be established. Using code coverage with the code coverage
data scan enabled (SIGUSR2, or any other signal for that matter) always
stops after the first scan. Having raised the verbosity level of procnto
I  get the following message:
Process 286732 (xyz_cov) terminated signo=0 code=0 by process 0 value=0.
Running the same application (in a qconn debug session) with the
coverage tool tab disabled causes no problem, the appl keeps running.
Did anyone had the same experience and found a solution for the
application being terminated?

2) Can you run a code coverage session without the use of the IDE (no
qconn) on the target ?

3) Generating a report within the Momentics IDE gives a report with html
links to the source files showing the coverage for the code within the
source file. When I save the report to xml file I only get an overview
table with the coverage. I no longer can browse into the source files.
Is this standard behaviour or do I miss something here?

Best regards,

Wim



_______________________________________________

General
http://community.qnx.com/sf/go/post57050
Re: RE: Code Coverage  
Thank you all for the information!

I tried  the following suggestions:

>Yes. If you instrument it with code coverage it should just work (it 
>will save data to a specific directory). You may need to set some env 
>vars for that - check user guide. You can import this data later in the 
>IDE or use gcov tool to view it.

running the application with code coverage on the target does not result in data written to a specific directory. only 
when running from the IDE with the tool tab disabled result in code coverage data directories being created on the 
target. Unfortunatly these directories are either corrupt or empty. Either way, I'm not able to import these. The pop up
 message in the IDE shows the following message:
          No coverage file and/or coverage notes file found
This message even appear when importing a directory that has some .gcda files present

I have no recent document about code coverage or the options/ enviroment variables I need to set, could you please give 
me a pointer to the relavant document?

> If you app can not be interrupted you can disable this option in
>the launch configuration "Tools -> Code Coverage -> Advanced..." tab.
>You won't get dynamic update in IDE but you should still be able to view
>the Code Coverage result when your app exits normally.

This works. However data is only collected when terminating using the slay command on the target, stopping the 
application within the IDE environemt results in an empty code coverage data set

>When you save the report in XML format, you lose some formatting IDE
>does when it applies the XSLT transform. So if you want the link to
>source file you need to save it in HTML format.

XML is the only option shown when executing the safe report command. Do I need to update something?

Thanks so far

Regards Wim
Re: RE: Code Coverage  
As already indicated by Andy Jin some while ago I have copied the .gcno files from the host to the target into the 
directory where the executable resides. 

When running outside Momentics IDE on the target I discovered the following:

By setting the GCOV_PREFIX environment variable on the target all .gcda files will be put in the directory specified. 
The GCOV_PREFIX_STRIP env variable does nothing as far as I can tell. Without setting the environment variable either no
 gcda files are created or they show up in a directory with a structure the same as the one on the host where the source
 files reside(win32).

By copying the .gcda file(s) to the source directory where the .gcno file(s) reside I can use the ntox86-gcov tool to 
create coverage information for the source files. 

Unfortunately I can't  import the .gcda files into the IDE. 

Are there more hidden feature I should know about ?

Please help -:)

Regards Wim 
RE: RE: Code Coverage  
Hi, Wim,

This gcc doc talks about using the two env vars http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html

If it still not solves your problem, can you attach your program and ".gcno" files so I can try?

HTH,
Andy

-----Original Message-----
From: Wim Hellenthal [mailto:community-noreply@qnx.com]
Sent: Fri 18/06/2010 5:47 AM
To: general-toolchain
Subject: Re: RE: Code Coverage
 
As already indicated by Andy Jin some while ago I have copied the .gcno files from the host to the target into the 
directory where the executable resides. 

When running outside Momentics IDE on the target I discovered the following:

By setting the GCOV_PREFIX environment variable on the target all .gcda files will be put in the directory specified. 
The GCOV_PREFIX_STRIP env variable does nothing as far as I can tell. Without setting the environment variable either no
 gcda files are created or they show up in a directory with a structure the same as the one on the host where the source
 files reside(win32).

By copying the .gcda file(s) to the source directory where the .gcno file(s) reside I can use the ntox86-gcov tool to 
create coverage information for the source files. 

Unfortunately I can't  import the .gcda files into the IDE. 

Are there more hidden feature I should know about ?

Please help -:)

Regards Wim 




Attachment: Text winmail.dat 3 KB
Re: Code Coverage  
Hi Any,

I've attached the small example already used earlier during a previous session we had. These are the step I take:

1) build the stuff on the win32 host (from the command line)
2) copy the executable from the obj dir and the .gcno file from the source dir to the user home directory on the target.

3) Set the environment variables GCOV_PREFIX and GCOV_PREFIX_STRIP
    (for some reason the stripping variable works now) such that the resulting .gcno file  shows up in the /var/coverage
 directory.
4) try to import the .gcda file into the IDE. This step fails. First of all I need to define a project name. What if the
 project is not part of the IDE environment which is the case for the small test program. I choose an existing project 
that has nothing to do with the test program,  just to be able to continue with the import command. Anyway, when I 
choose the directory where the .gcda file resides the tool pops up with the window saying:
         " No coverag file and/or coverage notes file found"
Has this something to do with the tool not being able to find the .gcno file?

5) Wen I copy the gcda file to the host, into the same directory as where the .gcno file resides, I can retrieve  the 
coverage data with the ntox86-gcov program. However I would like to use graphical interface provided by Momentics.
Furthermore I would like to build a report file in html format with links into the source files

Attachment: Compressed file coverage.zip 49.81 KB
RE: Code Coverage  
Hi, Wim,

You are on the right track but there are still some minor setup issues.
Here is what I did to test your program.

1) Ceate an empty IDE C++ project called "coverage". This is to facility
the below steps. Note you need to pre-define the location of the source
file before you build the program because "gcc" writes the absolute path
of your source file to the output ".gcno" note file. You can't relocate
the source file after the build.
2) Build the program using command line "gcc".
3) The build creates the ".gcno" file. If you view it in IDE text editor
you should see the correct absolute path to your source file
4) Transfer the output program to remote target under "/tmp". Define the
two env vars "GCOV_PREFIX" and "GCOV_PREFIX_STRIP". Note the definition
of the env vars is optional - they allow you to relocate the ".gcda"
file. If you don't define them you still get the ".gcda" file in a
directory mirrored to your host setup as outlined in No. 1 above.
5) Run the program and copy the ".gcda" file to the host to the same
directory as where the ".gcno" file is. Note this is important to put
the two meta-data at the same directory as the IDE assumes they are
locate together (as you can see if you run the Code Coverage in IDE)
6) Use the IDE "import" wizard to import the Code Coverage data and
create a new session. I can see the correct coverage percentage (72.73%)
and can open the source file with the correct coverage annotations.

Try again to see if it works for you now.

As to your second question on how to save the report in HTML format with
links to the source files, unfortunately the IDE can only save the
report in xml format now and it does not preserve the links to the
sources (as discussed earlier in this thread). We can look into this as
a potential feature to add to the future release. For now here is a
work-around for you:

- In the IDE "Preferences -> General -> Web Browser" switch to "Use
external browser".
- In the IDE Code Coverage Sessions view, right click on the session and
select "Generate Report".
- IDE will open the external browser with the HTML report and links to
the source files.
- In the browser you can now save the report to your hard drive.

I use Mozilla Firefox and it works fine for me.

Hope this help, Thanks,
Andy

-----Original Message-----
From: Wim Hellenthal [mailto:community-noreply@qnx.com] 
Sent: June 21, 2010 3:36 AM
To: general-toolchain
Subject: Re: Code Coverage

Hi Any,

I've attached the small example already used earlier during a previous
session we had. These are the step I take:

1) build the stuff on the win32 host (from the command line)
2) copy the executable from the obj dir and the .gcno file from the
source dir to the user home directory on the target.
3) Set the environment variables GCOV_PREFIX and GCOV_PREFIX_STRIP
    (for some reason the stripping variable works now) such that the
resulting .gcno file  shows up in the /var/coverage directory.
4) try to import the .gcda file into the IDE. This step fails. First of
all I need to define a project name. What if the project is not part of
the IDE environment which is the case for the small test program. I
choose an existing project that has nothing to do with the test program,
just to be able to continue with the import command. Anyway, when I
choose the directory where the .gcda file resides the tool pops up with
the window saying:
         " No coverag file and/or coverage notes file found"
Has this something to do with the tool not being able to find the .gcno
file?

5) Wen I copy the gcda file to the host, into the same directory as
where the .gcno file resides, I can retrieve  the coverage data with the
ntox86-gcov program. However I would like to use graphical interface
provided by Momentics.
Furthermore I would like to build a report file in html format with
links into the source files
Code Coverage  
Hi Andy,

Thanks for the information! I understand all the steps you describe except for the first one. Probably my ignorance -:) 
Do I have to associate the coverage project sent as attachment with the created  empty c++ propject winthin the  IDE 
environent? If this is the case how exactly should I do that . 

Regards Wim

RE: Code Coverage  
The project you sent as attachment is not an IDE project. I create an empty IDE project called "coverage" and point the 
project directory to where your attachment is. The created IDE project then has access to all your files.

I don't believe this is strictly required. You can use any project as you like. The most important point is once you 
define your project and source location and build it, you can't relocate your source because the output ".gcno" file has
 absolute path to your source.



Attachment: Text winmail.dat 2.38 KB