From 20d1af89b40d0a939a7afefeecf6652bd587e18b Mon Sep 17 00:00:00 2001 From: Martin Liska Date: Fri, 12 Aug 2016 14:23:32 +0200 Subject: [PATCH] Create x.gcov file for binary w/o x.gcda file (PR * g++.dg/gcov/gcov-16.C: New test. * lib/gcov.exp: Support new argument for run-gcov function. Adam Fineman * gcov.c (process_file): Create .gcov file when .gcda file is missing. From-SVN: r239413 --- gcc/ChangeLog | 7 +++++++ gcc/gcov.c | 2 +- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/g++.dg/gcov/gcov-16.C | 10 ++++++++++ gcc/testsuite/lib/gcov.exp | 28 ++++++++++++++++++++++++---- 5 files changed, 47 insertions(+), 5 deletions(-) create mode 100644 gcc/testsuite/g++.dg/gcov/gcov-16.C diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 165e183b68c..14f95cf1a92 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2016-08-12 Martin Liska + + Adam Fineman + + * gcov.c (process_file): Create .gcov file when .gcda + file is missing. + 2016-08-12 Marek Polacek PR c/7652 diff --git a/gcc/gcov.c b/gcc/gcov.c index f05ef7cb3c3..30fc167a0b3 100644 --- a/gcc/gcov.c +++ b/gcc/gcov.c @@ -902,7 +902,7 @@ process_file (const char *file_name) fns = fn->next; fn->next = NULL; - if (fn->counts) + if (fn->counts || no_data_file) { unsigned src = fn->src; unsigned line = fn->line; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index b06e8fa67f6..7700cec8b2d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2016-08-12 Martin Liska + + * g++.dg/gcov/gcov-16.C: New test. + * lib/gcov.exp: Support new argument for run-gcov function. + 2016-08-12 Martin Liska PR gcov-profile/35590 diff --git a/gcc/testsuite/g++.dg/gcov/gcov-16.C b/gcc/testsuite/g++.dg/gcov/gcov-16.C new file mode 100644 index 00000000000..f09d4060cbd --- /dev/null +++ b/gcc/testsuite/g++.dg/gcov/gcov-16.C @@ -0,0 +1,10 @@ +// PR gcov-profile/64634 +// { dg-options "-fprofile-arcs -ftest-coverage" } +// { dg-do run { target native } } + +int main() +{ + return 0; /* count(#####) */ +} + +// { dg-final { run-gcov remove-gcda gcov-16.C } } diff --git a/gcc/testsuite/lib/gcov.exp b/gcc/testsuite/lib/gcov.exp index dfc1301cd33..02bc6b92c14 100644 --- a/gcc/testsuite/lib/gcov.exp +++ b/gcc/testsuite/lib/gcov.exp @@ -19,16 +19,28 @@ global GCOV +# +# clean-gcov-file -- delete a working file the compiler creates for gcov +# +# TESTCASE is the name of the test. +# SUFFIX is file suffix + +proc clean-gcov-file { testcase suffix } { + set basename [file tail $testcase] + set base [file rootname $basename] + remote_file host delete $base.$suffix +} + # # clean-gcov -- delete the working files the compiler creates for gcov # # TESTCASE is the name of the test. # proc clean-gcov { testcase } { - set basename [file tail $testcase] - set base [file rootname $basename] - remote_file host delete $base.gcno $base.gcda \ - $basename.gcov $base.h.gcov + clean-gcov-file $testcase "gcno" + clean-gcov-file $testcase "gcda" + clean-gcov-file $testcase "gcov" + clean-gcov-file $testcase "h.gcov" } # @@ -305,6 +317,7 @@ proc run-gcov { args } { set gcov_verify_branches 0 set gcov_verify_lines 1 set gcov_verify_intermediate 0 + set gcov_remove_gcda 0 set xfailed 0 foreach a $args { @@ -317,6 +330,8 @@ proc run-gcov { args } { set gcov_verify_calls 0 set gcov_verify_branches 0 set gcov_verify_lines 0 + } elseif { $a == "remove-gcda" } { + set gcov_remove_gcda 1 } elseif { $gcov_args == "" } { set gcov_args $a } else { @@ -332,6 +347,11 @@ proc run-gcov { args } { # Extract the test file name from the arguments. set testcase [lindex $gcov_args end] + if { $gcov_remove_gcda } { + verbose "Removing $testcase.gcda" + clean-gcov-file $testcase "gcda" + } + verbose "Running $GCOV $testcase" 2 set testcase [remote_download host $testcase] set result [remote_exec host $GCOV $gcov_args] -- 2.30.2