[Bug gcov-profile/83877] Make gcov accept a path to the gcda and a path to the gcno file

2018-08-30 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83877

--- Comment #3 from Marco Castelluccio  ---
The problem we have is that there's a directory containing gcno files and
multiple directories containing gcda files (one for each test suite execution).

gcov expects the gcda and gcno files to be in the same directory, so we
currently create symlinks to the gcno files in the gcda directories.

Example situation:
gcno_dir/main.gcno
gcda_dir_1/main.gcda
gcda_dir_2/main.gcda

If I run `gcov gcda_dir_1/main.gcda -o gcno_dir/`, gcov says:
gcno/main.gcda:cannot open data file, assuming not executed

[Bug gcov-profile/86536] Function "returned NAN %" for a simple program which forks

2018-08-30 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86536

--- Comment #4 from Marco Castelluccio  ---
Sorry for the delay, it sounds fine to me, I can't think of anything better
than that!

[Bug gcov-profile/86536] New: Function "returned NAN %" for a simple program which forks

2018-07-16 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86536

Bug ID: 86536
   Summary: Function "returned NAN %" for a simple program which
forks
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mcastelluccio at mozilla dot com
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

-:0:Source:main.c
-:0:Graph:main.gcno
-:0:Data:main.gcda
-:0:Runs:1
-:0:Programs:1
-:1:#include 
-:2:
function main called 1 returned NAN % blocks executed 100%
1:3:int main(void) {
1:4:  int j = 22;
-:5:
1:6:  fork();
call0 returned 2
-:7:
2:8:  int i = 7;
-:9:
2:   10:  return 0;
-:   11:}

[Bug gcov-profile/86411] Some lines are considered as uncoverable when using __gcov_flush

2018-07-05 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86411

Marco Castelluccio  changed:

   What|Removed |Added

 Status|UNCONFIRMED |RESOLVED
 Resolution|--- |INVALID

--- Comment #4 from Marco Castelluccio  ---
Oh, I wasn't aware of that.

[Bug gcov-profile/86411] Some lines are considered as uncoverable when using __gcov_flush

2018-07-05 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86411

--- Comment #2 from Marco Castelluccio  ---
Line 14 and line 16 should be "#" (not covered), instead they are "-" (not
coverable, a line not containing any code).

[Bug gcov-profile/86411] New: Some lines are considered as uncoverable when using __gcov_flush

2018-07-05 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86411

Bug ID: 86411
   Summary: Some lines are considered as uncoverable when using
__gcov_flush
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mcastelluccio at mozilla dot com
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

-:0:Source:main.c
-:0:Graph:main.gcno
-:0:Data:main.gcda
-:0:Runs:1
-:0:Programs:1
-:1:extern void __gcov_flush(void);
-:2:
1:3:void f(int c) {}
-:4:
1:5:int main(int argc, char *argv[]) {
1:6:  f(1);
-:7:
1:8:  __gcov_flush();
-:9:
#:   10:  f(2);
-:   11:
#:   12:  _exit(0);
-:   13:
-:   14:  f(3);
-:   15:
-:   16:  return 0;
-:   17:}
-:   18:

[Bug gcov-profile/83878] Line hit counts are sometimes wrong

2018-07-04 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83878

Marco Castelluccio  changed:

   What|Removed |Added

 Status|RESOLVED|VERIFIED

--- Comment #4 from Marco Castelluccio  ---
Thanks! I've verified that the test case is fixed now!

[Bug gcov-profile/83878] Line hit counts are sometimes wrong

2018-06-12 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83878

--- Comment #2 from Marco Castelluccio  ---
Created attachment 44267
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44267=edit
Archive with GCNO, GCDA, source file and GCOV output

Sorry for replying late, but I just managed to find a reproducible small test
case.

g++ --coverage -fno-exceptions -O0 main.cpp
./a.out
gcov -u -b -c main.cpp

The relevant part is:
> function main called 1 returned 100% blocks executed 94%
> 1:   24:int main(void)
> -:   25:{
> 2:   26:  Ciao ciao;
> call0 returned 1
> call1 returned 1
> unconditional  2 taken 1
> -:   27:
> 1:   28:  ciao.setName("Marco");

Line 26 is clearly executed once, but gcov shows it as executed twice. The same
happens if you have an if block where you call a constructor.

[Bug gcov-profile/83879] __gcov_dump doesn't work with dlopen-ed libraries

2018-01-22 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83879

--- Comment #4 from Marco Castelluccio  ---
Would it be feasible to force exporting "__gcov_master" to the dynamic symbol
table when coverage instrumentation is enabled?

[Bug gcov-profile/83879] New: __gcov_dump doesn't work with dlopen-ed libraries

2018-01-15 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83879

Bug ID: 83879
   Summary: __gcov_dump doesn't work with dlopen-ed libraries
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mcastelluccio at mozilla dot com
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Created attachment 43144
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43144=edit
Archive containing source files to reproduce the bug

See the attached example.

To reproduce the problem, run the "run.sh" script and see that no func.gcda or
func2.gcda are generated.

If you remove the "pause()" call in main.c and let the program exit, the
func.gcda and func2.gcda files are generated.

[Bug gcov-profile/83878] New: Line hit counts are sometimes wrong

2018-01-15 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83878

Bug ID: 83878
   Summary: Line hit counts are sometimes wrong
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mcastelluccio at mozilla dot com
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Created attachment 43143
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=43143=edit
Archive with GCNO, GCDA, source file and GCOV output

I'm attaching an archive with gcno, gcda, cpp and gcov files that shows the
problem.

See for example after line 3181:
> -: 3181:static bool
> function 
> _ZL24DefineSelfHostedPropertyP9JSContextN2JS6HandleIP8JSObjectEENS2_I4jsidEEPKcS9_j
>  called 28803 returned 100% blocks executed 65%
> 28803: 3182:DefineSelfHostedProperty(JSContext* cx, HandleObject obj, 
> HandleId id,
> 28803: 3182-block  0
> -: 3183: const char* getterName, const char* 
> setterName,
> -: 3184: unsigned attrs)
> -: 3185:{
> 28803: 3186:JSAtom* getterNameAtom = Atomize(cx, getterName, 
> strlen(getterName));
> 28803: 3186-block  0
> call0 returned 28803
> 28803: 3187:if (!getterNameAtom)
> branch  0 taken 28803 (fallthrough)
> branch  1 taken 0
> -: 3188:return false;
> 57606: 3189:RootedPropertyName getterNameName(cx, 
> getterNameAtom->asPropertyName());
> -: 3190:

Why does line 3189 have a hit count twice as big as previous lines and the
function itself?

The files were generated with GCC 6, we are going to try compiling with a new
version soon. Do you already know of similar problems that have been fixed
between 6 and 8?

[Bug gcov-profile/83877] New: Make gcov accept a path to the gcda and a path to the gcno file

2018-01-15 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83877

Bug ID: 83877
   Summary: Make gcov accept a path to the gcda and a path to the
gcno file
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mcastelluccio at mozilla dot com
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Sometimes they are not close to each other (e.g. if you build on one machine
and run tests on other machines).
It would be nice if there was a way to specify the paths to both the gcno and
the gcda and not be forced to move/copy/symlink the gcno in the directories as
siblings to the gcda files.

[Bug gcov-profile/82614] GCOV crashes while parsing gcda file

2017-11-07 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82614

--- Comment #10 from Marco Castelluccio  ---
(In reply to Martin Liška from comment #9)
> (In reply to Marco Castelluccio from comment #8)
> > Created attachment 42462 [details]
> > Archive with GCNO and GCDA file generated with GCC 6
> > 
> > This is an archive containing the GCNO and GCDA files generated with GCC 6.
> > 
> > We are going to test 7 next.
> 
> Thanks for that. Still can't reproduce and it will be highly probably that
> it's related to fact that I do not have source files which are annotated.
> Can you please attach them?
> 
> Moreover, can you please run it in gdb and paste full backtrace?

I don't have the source files either, they are built on a remote machine and
I'm only downloading the gcno/gcda file.

Here's the backtrace:
#0  __GI_raise (sig=sig@entry=6) at ../sysdeps/unix/sysv/linux/raise.c:51
#1  0x77a2df5d in __GI_abort () at abort.c:90
#2  0x77a7628d in __libc_message (action=action@entry=(do_abort |
do_backtrace), fmt=fmt@entry=0x77b9b9e6 "*** %s ***: %s terminated\n")
at ../sysdeps/posix/libc_fatal.c:181
#3  0x77b1c7ef in __GI___fortify_fail_abort
(need_backtrace=need_backtrace@entry=true, msg=msg@entry=0x77b9b96d "buffer
overflow detected")
at fortify_fail.c:33
#4  0x77b1c811 in __GI___fortify_fail (msg=msg@entry=0x77b9b96d
"buffer overflow detected") at fortify_fail.c:44
#5  0x77b1a500 in __GI___chk_fail () at chk_fail.c:28
#6  0x77b199e9 in _IO_str_chk_overflow (fp=,
c=) at vsprintf_chk.c:31
#7  0x77a7ad59 in __GI__IO_default_xsputn (f=0x7fffd0f0,
data=, n=19) at genops.c:455
#8  0x77a4932d in _IO_vfprintf_internal (s=s@entry=0x7fffd0f0,
format=, format@entry=0x46f771 "%ld", 
ap=ap@entry=0x7fffd230) at vfprintf.c:1642
#9  0x77b19a8b in ___vsprintf_chk (s=0x697670  "-674122451547433726", flags=1, slen=20, 
format=0x46f771 "%ld", args=args@entry=0x7fffd230) at vsprintf_chk.c:82
#10 0x77b199ba in ___sprintf_chk (s=s@entry=0x697670  "-674122451547433726", flags=flags@entry=1, 
slen=slen@entry=20, format=format@entry=0x46f771 "%ld") at sprintf_chk.c:31
#11 0x00405934 in sprintf (__fmt=0x46f771 "%ld", __s=0x697670
 "-674122451547433726")
at /usr/include/x86_64-linux-gnu/bits/stdio2.h:34
#12 format_gcov (top=, bottom=, dp=-1) at
../../src/gcc/gcov.c:1998
#13 0x00404b41 in output_lines (src=0x1108e00, gcov_file=0x71a650) at
../../src/gcc/gcov.c:2563
#14 output_gcov_file (src=0x1108e00, file_name=0xa8f490
"Unified_cpp_js_src31.gcda") at ../../src/gcc/gcov.c:962
#15 generate_results (file_name=) at ../../src/gcc/gcov.c:1035
#16 main (argc=, argv=) at
../../src/gcc/gcov.c:640

[Bug gcov-profile/82702] gcov intermediate format is creating multiple 'gcov' files, it was creating a single file up to GCC 6

2017-10-30 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82702

--- Comment #7 from Marco Castelluccio  ---
(In reply to Martin Liška from comment #6)
> Marco is right that it started with the mentioned revision. But let me start
> in more general context:
> 
> Consider virtual.cpp file that includes some standard header files.
> In that case gcov tool can be invoked with arbitrary file extension, because
> the file name is only used to find a proper gc{da,no} file:
> 
> $ gcov virtual.abcdef
> File 'virtual.cpp'
> Lines executed:100.00% of 9
> Creating 'virtual.cpp.gcov'
> 
> File '/home/marxin/bin/gcc2/include/c++/7.2.1/iostream'
> Lines executed:100.00% of 1
> Creating 'iostream.gcov'
> 
> Even if you rename virtual.gcno and virtual.gcda to x.gcno (x.gcda
> respectively):
> 
> $ gcov x.gcda
> File 'virtual.cpp'
> Lines executed:100.00% of 9
> Creating 'virtual.cpp.gcov'
> 
> File '/home/marxin/bin/gcc2/include/c++/7.2.1/iostream'
> Lines executed:100.00% of 1
> Creating 'iostream.gcov'
> 
> Because each gcno file contains locations for all function, it has exactly
> one source file and multiple header files. Here we come to intermediate
> format. I would prefer to generate same sets of .gcov files for both normal
> and intermediate format. I consider it more stable.
> 
> In your use case, I would suggest to support -l (--long-names) in
> intermediate format and use the path for content of intermediate file:
> 
> file:/home/marxin/bin/gcc2/include/c++/7.2.1/iostream.gcov
> 
> Doing so, one can concatenate all *.gcov files and use it for tools like
> lcov. I know it's behavior change, but can help if you have problem with
> number of files that need to be filled to lcov?

We are not using directly lcov, but a replacement we rewrote in Rust.
We can easily support reading from multiple gcov files instead of one
(actually, we already support it when llvm is used, since it doesn't support
the intermediate format).
The only problem is that it slows down parsing for large projects, which is
unfortunate since I guess the intermediate format was introduced to speed-up
parsing. We have a lot of included files (e.g. I just run it with one of our
gcno files and it generated 160
gcov files), so clearly opening and reading thousands of files is faster than
opening and reading hundreds of thousands.

[Bug gcov-profile/82702] gcov intermediate format is creating multiple 'gcov' files, it was creating a single file up to GCC 6

2017-10-25 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82702

--- Comment #4 from Marco Castelluccio  ---
I suppose this is a regression caused by
https://github.com/gcc-mirror/gcc/commit/41da7513d5aaaff3a5651b40edeccc1e32ea785a.

Is it intentional?

Note that generating multiple files makes parsing slower, as lcov (or similar
tools) will need to 1) list the files generated; 2) open and parse them one by
one.

[Bug gcov-profile/82702] gcov intermediate format is creating multiple 'gcov' files, it was creating a single file up to GCC 6

2017-10-25 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82702

--- Comment #3 from Marco Castelluccio  ---
See also this comment:
https://github.com/gcc-mirror/gcc/blob/3c311329bd71ab4589fced78baf30187e50b6d3f/gcc/gcov.c#L865.

This used to be true, but it's not anymore.

[Bug gcov-profile/82702] gcov intermediate format is creating multiple 'gcov' files, it was creating a single file up to GCC 6

2017-10-25 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82702

--- Comment #2 from Marco Castelluccio  ---
(In reply to Andrew Pinski from comment #1)
> https://gcc.gnu.org/onlinedocs/gcc/Invoking-Gcov.html#Invoking-Gcov
> 
> The output is a single .gcov file per .gcda file. 
> 
> The same documentation was in GCC 5.1.0's docs:
> https://gcc.gnu.org/onlinedocs/gcc-5.1.0/gcc/Invoking-Gcov.html#Invoking-Gcov

Exactly. So "gcov -i file.gcno" should generate (and indeed, was generating) a
single gcov file. Now, it's generating multiple gcov files.

[Bug gcov-profile/82614] GCOV crashes while parsing gcda file

2017-10-24 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82614

--- Comment #8 from Marco Castelluccio  ---
Created attachment 42462
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42462=edit
Archive with GCNO and GCDA file generated with GCC 6

This is an archive containing the GCNO and GCDA files generated with GCC 6.

We are going to test 7 next.

[Bug gcov-profile/82702] New: gcov intermediate format is creating multiple 'gcov' files, it was creating a single file up to GCC 6

2017-10-24 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82702

Bug ID: 82702
   Summary: gcov intermediate format is creating multiple 'gcov'
files, it was creating a single file up to GCC 6
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mcastelluccio at mozilla dot com
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Running "gcov -i file.gcno" was generating a single file ("file.gcno.gcov")
with info about all the files included in file.cpp.
Now, it is creating multiple "gcov" files, one for each included file.

[Bug gcov-profile/82614] GCOV crashes while parsing gcda file

2017-10-20 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82614

--- Comment #7 from Marco Castelluccio  ---
(In reply to Martin Liška from comment #6)
> (In reply to Marco Castelluccio from comment #5)
> > (In reply to Martin Liška from comment #4)
> > > (In reply to Marco Castelluccio from comment #3)
> > > > > Thanks for the report Marco. Looks it comes from Firefox, am I right?
> > > > 
> > > > Yes, that's correct. Actually, from a build of the JS shell.
> > > > 
> > > > > Which version of GCC have you been using?
> > > > 
> > > > The build was done with "gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 
> > > > 20160609".
> > > > 
> > > > We were also able to reproduce the crash with a gcda generated normally,
> > > > without __gcov_dump.
> > > 
> > > I see, not the GCC 5.x is not longer supported. Anyway, please paste
> > > backtrace from gcov when the segfaults happens.
> > 
> > I'm having a hard time installing debugging symbols here, I might have to
> > build GCC from scratch.
> > If you already have a debug build of GCC 6 lurking around, you could try if
> > you could reproduce the crash yourself.
> 
> Yes, but am I right that the gcda and gcno files attached are created with
> GCC 5.4?
> I can't reproduce the segfault on my machine. Please paste command line
> invocation.

Yes, they were created with GCC 5.4.
Here's a crash report when I try to parse them with gcov-7:
https://bugs.launchpad.net/ubuntu/+source/gcc-7/+bug/1725255, perhaps you can
get the stacktrace from there.

I will report back after we finish testing with GCC 6/7.

[Bug gcov-profile/82614] GCOV crashes while parsing gcda file

2017-10-19 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82614

--- Comment #5 from Marco Castelluccio  ---
(In reply to Martin Liška from comment #4)
> (In reply to Marco Castelluccio from comment #3)
> > > Thanks for the report Marco. Looks it comes from Firefox, am I right?
> > 
> > Yes, that's correct. Actually, from a build of the JS shell.
> > 
> > > Which version of GCC have you been using?
> > 
> > The build was done with "gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 
> > 20160609".
> > 
> > We were also able to reproduce the crash with a gcda generated normally,
> > without __gcov_dump.
> 
> I see, not the GCC 5.x is not longer supported. Anyway, please paste
> backtrace from gcov when the segfaults happens.

I'm having a hard time installing debugging symbols here, I might have to build
GCC from scratch.
If you already have a debug build of GCC 6 lurking around, you could try if you
could reproduce the crash yourself.

> I did quite some fixes to gcov that are included in GCC 7.x branch. Can you
> please test a new release?

We are testing with GCC 6 now, and will try with GCC 7 later on.

[Bug gcov-profile/82614] GCOV crashes while parsing gcda file

2017-10-19 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82614

--- Comment #3 from Marco Castelluccio  ---
> Thanks for the report Marco. Looks it comes from Firefox, am I right?

Yes, that's correct. Actually, from a build of the JS shell.

> Which version of GCC have you been using?

The build was done with "gcc (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609".

We were also able to reproduce the crash with a gcda generated normally,
without __gcov_dump.

[Bug gcov-profile/82614] GCOV crashes while parsing gcda file

2017-10-19 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82614

--- Comment #1 from Marco Castelluccio  ---
Created attachment 42399
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42399=edit
GCNO file

[Bug gcov-profile/82614] New: GCOV crashes while parsing gcda file

2017-10-19 Thread mcastelluccio at mozilla dot com
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82614

Bug ID: 82614
   Summary: GCOV crashes while parsing gcda file
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: gcov-profile
  Assignee: unassigned at gcc dot gnu.org
  Reporter: mcastelluccio at mozilla dot com
CC: marxin at gcc dot gnu.org
  Target Milestone: ---

Created attachment 42398
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=42398=edit
GCDA file

This file was generated using _gcov_dump. It was generated along many others,
but this is the only one where gcov crashes.