Skip to content

Commit

Permalink
Make groups more generic (PR gcov-profile/84548).
Browse files Browse the repository at this point in the history
2018-02-27  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/84548
	* gcov.c (process_file): Allow partial overlap and consider it
	also as group functions.
	(output_lines): Properly calculate range of lines for a group.
2018-02-27  Martin Liska  <mliska@suse.cz>

	PR gcov-profile/84548
	* g++.dg/gcov/pr84548.C: New test.


git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@258033 138bc75d-0d04-0410-961f-82ee72b054a4
  • Loading branch information
marxin committed Feb 27, 2018
1 parent cb2964e commit 2d99ce8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 2 deletions.
7 changes: 7 additions & 0 deletions gcc/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
2018-02-27 Martin Liska <mliska@suse.cz>

PR gcov-profile/84548
* gcov.c (process_file): Allow partial overlap and consider it
also as group functions.
(output_lines): Properly calculate range of lines for a group.

2018-02-27 Martin Liska <mliska@suse.cz>

* timevar.c (timer::print_row): Remove 'usr', 'sys', 'wall' and
Expand Down
10 changes: 8 additions & 2 deletions gcc/gcov.c
Original file line number Diff line number Diff line change
Expand Up @@ -1151,7 +1151,6 @@ process_file (const char *file_name)
function_info **slot = fn_map.get (needle);
if (slot)
{
gcc_assert ((*slot)->end_line == (*it)->end_line);
(*slot)->is_group = 1;
(*it)->is_group = 1;
}
Expand Down Expand Up @@ -2957,7 +2956,14 @@ output_lines (FILE *gcov_file, const source_info *src)
{
fns = src->get_functions_at_location (line_num);
if (fns.size () > 1)
line_start_group = fns[0]->end_line;
{
/* It's possible to have functions that partially overlap,
thus take the maximum end_line of functions starting
at LINE_NUM. */
for (unsigned i = 0; i < fns.size (); i++)
if (fns[i]->end_line > line_start_group)
line_start_group = fns[i]->end_line;
}
else if (fns.size () == 1)
{
function_info *fn = fns[0];
Expand Down
5 changes: 5 additions & 0 deletions gcc/testsuite/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2018-02-27 Martin Liska <mliska@suse.cz>

PR gcov-profile/84548
* g++.dg/gcov/pr84548.C: New test.

2018-02-27 Jakub Jelinek <jakub@redhat.com>

PR target/84575
Expand Down
19 changes: 19 additions & 0 deletions gcc/testsuite/g++.dg/gcov/pr84548.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// PR gcov-profile/84548
// { dg-options "-fprofile-arcs -ftest-coverage" }
// { dg-do run { target native } }
// TODO: add support for groups to gcov.exp script

struct A { static int foo () { return 1; }; static int bar () {
int x;
return 2; } };

int main()
{
int a = A::foo () + A::bar ();
if (a != 3)
return 1;

return 0;
}

// { dg-final { run-gcov remove-gcda pr84548.C } }

0 comments on commit 2d99ce8

Please sign in to comment.