From: "Seongbae Park (박성배, 朴成培)" <seongbae.park@gmail.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>,
"Janis Johnson" <janis187@us.ibm.com>,
mark@codesourcery.com, nathan@codesourcery.com
Subject: [PATCH] Wrong coverage attribution.
Date: Thu, 26 Jul 2007 23:35:00 -0000 [thread overview]
Message-ID: <ab3a61990707261609m285359d7hebfd00e8247beda7@mail.gmail.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 690 bytes --]
Hi,
gcc/ChangeLog:
2007-07-26 Seongbae Park <seongbae.park@gmail.com>
* tree-eh.c (lower_try_finally_onedest): Reset the locus of moved goto.
gcc/testsuite/ChangeLog:
2007-07-26 Seongbae Park <seongbae.park@gmail.com>
* lib/gcov.exp (verify-lines): Recognize - and # as possible count.
* g++.dg/gcov/gcov-4.C: New test.
Attached patch fixes the problem shown in the testcase
- this testcase fails in the current mainline
because of GOTO moved to a different block during eh lowering.
Bootstrap and regtest are in progress.
If all tests look clean,
ok for mainline and 4.2 branch ?
--
#pragma ident "Seongbae Park, compiler, http://seongbae.blogspot.com"
[-- Attachment #2: bad-eh-lineno.patch --]
[-- Type: text/x-patch, Size: 2342 bytes --]
Index: gcc/testsuite/g++.dg/gcov/gcov-4.C
===================================================================
--- gcc/testsuite/g++.dg/gcov/gcov-4.C (revision 0)
+++ gcc/testsuite/g++.dg/gcov/gcov-4.C (revision 0)
@@ -0,0 +1,41 @@
+/* Check that execution counts and branch probabilities for various C
+ constructs are reported correctly by gcov. */
+
+#include <stdio.h>
+
+/* { dg-options "-fprofile-arcs -ftest-coverage -fno-exceptions" } */
+/* { dg-do run { target native } } */
+
+class foo {
+public:
+ foo() { printf("foo()\n"); };
+ ~foo() { printf("~foo()\n"); };
+ void method(void) { printf("method()\n"); };
+};
+
+int func(int i, int j) __attribute__((noinline));
+
+int func(int i, int j){
+ if (j) {
+ printf("unreachable\n");
+ return 3;
+ }
+
+ foo f;
+
+ if (i == 1) {
+ f.method();
+ f.method();
+ } else {
+ f.method();
+ printf("unreachable\n");
+ return 2; /* count(#####) */
+ }
+ f.method();
+ return 0;
+}
+
+int main() {
+ return func(1, 0);
+}
+/* { dg-final { run-gcov gcov-4.C } } */
Index: gcc/testsuite/lib/gcov.exp
===================================================================
--- gcc/testsuite/lib/gcov.exp (revision 126963)
+++ gcc/testsuite/lib/gcov.exp (working copy)
@@ -42,7 +42,9 @@ proc verify-lines { testcase file } {
set failed 0
set fd [open $file r]
while { [gets $fd line] >= 0 } {
- if [regexp "^ *(\[^:]*): *(\[0-9\]+):.*count\\((\[0-9\]+)\\)" \
+ # We want to match both "-" and "#####" as count as well as numbers,
+ # since we want to detect lines that shouldn't be marked as covered.
+ if [regexp "^ *(\[^:]*): *(\[0-9\\-#]+):.*count\\((\[0-9\\-#]+)\\)" \
"$line" all is n shouldbe] {
if { $is == "" } {
fail "$n:no data available for this line"
Index: gcc/tree-eh.c
===================================================================
--- gcc/tree-eh.c (revision 126963)
+++ gcc/tree-eh.c (working copy)
@@ -999,6 +999,9 @@ lower_try_finally_onedest (struct leh_st
}
}
+ /* Reset the locus of the goto since we're moving
+ goto to a different block which might be on a different line. */
+ SET_EXPR_LOCUS (tf->goto_queue[0].cont_stmt, NULL);
append_to_statement_list (tf->goto_queue[0].cont_stmt, tf->top_p);
maybe_record_in_goto_queue (state, tf->goto_queue[0].cont_stmt);
}
next reply other threads:[~2007-07-26 23:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-26 23:35 Seongbae Park (박성배, 朴成培) [this message]
2007-07-30 18:34 ` Seongbae Park (박성배, 朴成培)
2007-07-31 3:52 ` Nathan Sidwell
2007-07-31 15:44 ` Seongbae Park (박성배, 朴成培)
2007-07-31 18:20 ` Seongbae Park (박성배, 朴成培)
2007-08-09 4:41 ` Seongbae Park (박성배, 朴成培)
2007-08-15 23:12 ` Seongbae Park (박성배, 朴成培)
2007-07-30 19:12 ` Janis Johnson
2007-08-16 1:35 ` Diego Novillo
2007-08-16 17:30 ` Seongbae Park (박성배, 朴成培)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ab3a61990707261609m285359d7hebfd00e8247beda7@mail.gmail.com \
--to=seongbae.park@gmail.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=janis187@us.ibm.com \
--cc=mark@codesourcery.com \
--cc=nathan@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).