Forum Topic - QNX *.da files does it collects cumulative across two different test cases.:
   
QNX *.da files does it collects cumulative across two different test cases.  
Can you please let me know which below version of the following compilers give us cumulative results for coverage data 
files(*.da)

1. "ntomips-gcov OR ntomips-gcov-2.95.3"
2. gcov (GCC) 3.3.5 (qnx-nto) - which is (ntomips-gcov-3.3.5)
Re: QNX *.da files does it collects cumulative across two different test cases.  
can someone please reply for this query?
Re: QNX *.da files does it collects cumulative across two different test cases.  
Nagaraj naik wrote:
> Can you please let me know which below version of the following compilers give us cumulative results for coverage data
 files(*.da)
> 
> 1. "ntomips-gcov OR ntomips-gcov-2.95.3"
> 2. gcov (GCC) 3.3.5 (qnx-nto) - which is (ntomips-gcov-3.3.5)

As I said before you have to use right version of the gcov tool for the 
compiler (e.g. ntomips-gcov-3.3.5 for gcc 3.3.5).

Here is a simple example of getting cumulative results:

# cat simple.c
#include <stdio.h>

int main(int argc, char *argv[]) {
  if (argc > 1) {
   printf("foo\n");
  } else {
   printf("bar\n");
  }
}

# qcc -V3.3.5,gcc_ntomipsbe -ftest-coverage -fprofile-arcs simple.c -o 
simple

On the target doing multiple runs:

# ./simple
bar

# ./simple 1
foo

# ./simple 2
foo

# ./simple 3
foo

On the host side:

# ntomips-gcov-3.3.5 -f simple.da
100.00% of 4 lines executed in function main
100.00% of 4 lines executed in file simple.c
Creating simple.c.gcov.
# cat simple.c.gcov
         -:    0:Source:simple.c
         -:    0:Object:simple.bb
         -:    1:#include <stdio.h>
         -:    2:
         4:    3:int main(int argc, char *argv[]) {
         4:    4: if (argc > 1) {
         3:    5:  printf("foo\n");
         -:    6: } else {
         1:    7:  printf("bar\n");
         -:    8: }
         -:    9:}
         -:   10:

As you can see from the generated gcov file code coverage data is 
collected from multiple runs.

Regards,

Ryan Mansfield
Re: QNX *.da files does it collects cumulative across two different test cases.  
thanks a lot for the example.

the problem with 3.3.5 compiler here is that the binary is bloated up by 4 times larger compare to 2.95.3.

So can you please let me know wether this cumulative results are collected with the 2.95.3 compiler and the 2.95.3 gcov 
versions?

thanks in advance
Re: QNX *.da files does it collects cumulative across two different test cases.  
Nagaraj naik wrote:
> thanks a lot for the example.
> 
> the problem with 3.3.5 compiler here is that the binary is bloated up by 4 times larger compare to 2.95.3.

Why would you even ask about using gcov 3.3.5 if you had no intention of 
using it?

I haven't seen such a significant increase in code size. Can you provide 
an example? Are you compiling with debug information? Are you comparing 
the size of the binary on size or the size of the loable segments?

Regards,

Ryan Mansfield
Re: QNX *.da files does it collects cumulative across two different test cases.  
Nagaraj naik wrote:
> So can you please let me know wether this cumulative results are collected with the 2.95.3 compiler and the 2.95.3 
gcov versions?

I just remembered that 2.95.3 did not use the __bb_exit_funcs from the 
gcc 2.95.3 libgcc (which does merge data) but instead uses a custom 
__bb_exit_funcs from libc.a and this routine did not merge the existing 
data.

The attached libc.a contains a gmon.o that will merge the existing .da 
file. You will need to relink your application to pick up the fix. 
Please let me know if you have any problems.

Regards,

Ryan Mansfield
Attachment: Text mipsbe-libca.tar.gz 406.26 KB
Re: QNX *.da files does it collects cumulative across two different test cases.  
Hi,

I had tried this new libc.a by newly compiling binary and the *.da not getting cumulative results for different 
executions.

Please help here.

the reason we try 3.3.5 compiler is because of this cumulative feature, if the patch is available for the 2.95.3 itself 
we wont use 3.3.5 comipler/gcov tool.
Re: QNX *.da files does it collects cumulative across two different test cases.  
Nagaraj naik wrote:
> Hi,
> 
> I had tried this new libc.a by newly compiling binary and the *.da not getting cumulative results for different 
executions.

How did you test it? Did you try following my example of how to use code 
coverage? Can you please tell me exactly what you are trying? Where did 
you install the libc.a on the host?

Let me illustrate for you that with the libc.a code coverage works with 
2.95.3:

On host:

# qcc -V2.95.3,gcc_ntomipsbe simple.c -ftest-coverage -fprofile-arcs -o 
simple

On target:

# ./simple
bar

# ./simple 1
foo

# ./simple 2
foo

# ./simple 3
foo

On host again:

# ntomips-gcov-2.95.3 -f simple.da
100.00% of 6 source lines executed in function main
No executable source lines in function _GLOBAL_$I$mainGCOV
100.00% of 6 source lines executed in file simple.c
Creating simple.c.gcov.
# cat simple.c.gcov
		#include <stdio.h>
		
		int main(int argc, char *argv[]) {
            4     if (argc > 1) {
            3      printf("foo\n");
            3     } else {
            1      printf("bar\n");
            4     }
            4    }
		

> Please help here.

Please provide an example or a better description of what does not work 
for you. If you cannot disclose details about your problem in the forum 
and need further assistance with the usage issues I suggest you contact 
our support department. They can confidentially work with you and get 
past whatever is holding you back from providing details.

Regards,

Ryan Mansfield
Re: QNX *.da files does it collects cumulative across two different test cases.  
What i did here is that

I had put the latest libc.a file under <qnx/target/qnx6/mipsbe/lib/>

1.compiled the program, and 
2. I tried some test cases that covers line 1 to 5
3. and then rebooted the system.
4. i had put last *.da files back in place 
5. tried another test case whcih covers 8 to 10 lines.

and then tried gcov 2.95.3 and i see only 8 to 10 lines are tocuhed that means its overwritten the file.

does this libc.a should be installed on host side of it, not on the target like i did above, please let me know.
If its on host side, please let me know which directory should i keep this libc.a


Re: QNX *.da files does it collects cumulative across two different test cases.  
Nagaraj naik wrote:
> does this libc.a should be installed on host side of it, not on the target like i did above, please let me know.

Yes, it needs to be installed on host side.  libc.a is a static archive 
and as I explained in a previous email, your application needs to use 
the updated gmon.o from libc.a.

Unless linking your executable on your target (not likely) there is no 
point in having a libc.a on the target.

Regards,

Ryan Mansfield
Re: QNX *.da files does it collects cumulative across two different test cases.  
thanks 

can you please tell me where on host side need to be installed this libc.a
Re: QNX *.da files does it collects cumulative across two different test cases.  
Nagaraj naik wrote:
> thanks 
> 
> can you please tell me where on host side need to be installed this libc.a

$QNX_TARGET/mipsbe/lib/libc.a

Sorry, I didn't figure I needed to tell you exactly where since there is 
only one libc.a per architecture on the host and it's easy to find using 
a utility like find or Windows search. You can back up the existing 
libc.a and replace it with the new one using 'cp'.

Regards,

Ryan Mansfield

Re: QNX *.da files does it collects cumulative across two different test cases.  
Yes, as you provided earlier libc.a fix for nomral gcov is getting "aborted" error.

like that I have installed libc.a on the same as you mentioned 
i.e. at $QNX_TARGET/mipsbe/lib/libc.a

earlier you had given me following files with the fix, let me know if we are missing anything here other than libc.a 
libc.so, libcS.a, libc.a, libc.so.2 

and by putting libc.a at above location only i had tried my test cases but its not accumalating the results in *.da 
files.

please help.
Re: QNX *.da files does it collects cumulative across two different test cases.  
Nagaraj naik wrote:
> Yes, as you provided earlier libc.a fix for nomral gcov is getting "aborted" error.
> 
> like that I have installed libc.a on the same as you mentioned 
> i.e. at $QNX_TARGET/mipsbe/lib/libc.a

Yes, those files are on your host not your the target. I'm not sure why 
earlier you said you had installed them on your target?

> earlier you had given me following files with the fix, let me know if we are missing anything here other than libc.a 
> libc.so, libcS.a, libc.a, libc.so.2 

This fix was in gmon.o and gmon.o is only in the archive variant. If you 
are having troubles linking against the proper libc.a you can extract 
the libc.a and explicitly link the gmon.o into your executable.

> and by putting libc.a at above location only i had tried my test cases but its not accumalating the results in *.da 
files.
> 
> please help.

I am only going to ask these questions once more. Can you provide your 
testcase? Did you try my example?

Regards,

Ryan Mansfield
Re: QNX *.da files does it collects cumulative across two different test cases.  
I have done with your simple.c program

#qcc -V2.95.3,gcc_ntomipsbe -Wc, -fprofile-arcs -Wc, -ftest-coverage   -c -o simple.o simple.c 

#qcc -V2.95.3,gcc_ntomipsbe -o simple  simple.o /vobs/projects/springboard/tps/qnx/target/qnx6/mipsbe/lib/libc.a -
Bstatic

# ./simple
bar
# ./simple 1
foo
# ./simple 2
foo
# ./simple 3
foo
#ntomips-gcov-2.95.3 simple.c
 83.33% of 6 source lines executed in file simple.c
Creating simple.c.gcov.
#cat simple.c.gcov
                #include <stdio.h>

                int main(int argc, char *argv[]) {
           1      if (argc > 1) {
           1       printf("foo\n");
           1      } else {
      ######       printf("bar\n");
           1      }
           1    }

here it got the data which was last executed.

i had attached all the simple.c, libc.a, simple.bb, simple.bbg and simple.c.gcov all i had used, please let me know 
where might be wrong here.

the filesystem here where I am running this program is DRAM based file system.

I tried the same simple.c with 3.3.5 its going through fine here.
Attachment: Text simple.tar.gz 462.95 KB
Re: QNX *.da files does it collects cumulative across two different test cases.  
Nagaraj naik wrote:
> 
> i had attached all the simple.c, libc.a, simple.bb, simple.bbg and simple.c.gcov all i had used, please let me know 
where might be wrong here.

The problem is that embedded filename for the .da file is: 
/vobs/projects/springboard/npfos/platform/scimitar/shell/simple.da

Presumably you don't have access to this path on your target so the when 
code coverage code fails to open the embedded filename it ends up 
writing a new .da file using the file's basename to the current working 
directory. I've modified gmon.c code in libc.a to check for the 
existence of a <basename>.da file and merge in code coverage data if it 
exists and the arcs match.

Attached is a new libc.a.

Regards,

Ryan Mansfield
Attachment: Text mipsbe-fix.tar.gz 406.31 KB
Re: QNX *.da files does it collects cumulative across two different test cases.  
Thanks a lot.
It solved the problem for cumulative coverage data here.
it was a great timely response from you, thanks again.

will keep in touch with official support channel inorder to get the official fix for the same along with you being in 
loop.