This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question using gcov


Hi Daniel,

2011/5/27 Daniel Kraft <d@domob.eu>:
>> Can anyone tell me what I should do instead?
>
> it's been some while since I used gcov, but when I did, I always used
> the flags
>
> - -ftest-coverage -fprofile-arcs -pg
>
> (which also enable gprof profiling)
>
> You could try those, but I have to admit that I don't *really* know what
> any of those do exactly. ?gcov just worked for me (although I think I
> also didn't try it with Fortran).
>

With -pg I indeed get the gmon.out file used by gprof, but gcov still
complains about this .gcda file. Even more so:
When I add the -fprofile-arcs option, my _program_ complains that
it cannot create the directory /D: - it is running on my D-disk.
It also says it skips the .gcda file.

Trying this under Linux:
- With only -ftest-coverage, the same as on PC
- With -ftest-coverage -pg, the .gcno and gmon.out files are produced
(but gcov complains)
- With -ftest-coverage -fprofile-arcs -pg, I do get the .gcda file and
gcov produces (almost)
  the kind of report I expect. (almost because I can not explain the
numbers - it is a very
  simple program where each statement - if executed - is executed
once, but a subroutine
  call gets a number 2 - see below)

Regards,

Arjen

-----
Output from gcov - notice the "2". (Running the program twice produces
2 and 4, so it
seems to mean the number of times a statement was run)

        -:    0:Source:coverage_example.f90
        -:    0:Graph:coverage_example.gcno
        -:    0:Data:coverage_example.gcda
        -:    0:Runs:1
        -:    0:Programs:1
        -:    1:! coverage_example.f90 --
        -:    2:!     Show how to use the gcov utility
        -:    3:!
        1:    4:program test_coverage
        -:    5:    implicit none
        -:    6:
        -:    7:    real :: a = 0.0
        -:    8:
        2:    9:    call setvalue( a, 1 )
        -:   10:
        1:   11:    write(*,*) 'Parameter = ', a
        -:   12:
        -:   13:contains
        -:   14:subroutine setvalue( param, type )
        -:   15:
        -:   16:    real, intent(inout) :: param
        -:   17:    integer, intent(in) :: type
        -:   18:
        2:   19:    if ( type == 0 ) then
    #####:   20:        param = param * exp(-param)
        -:   21:    endif
        -:   22:
        -:   23:end subroutine setvalue
        -:   24:end program test_coverage


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]