From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx.kolabnow.com (mx.kolabnow.com [212.103.80.154]) by sourceware.org (Postfix) with ESMTPS id 6CFEE386C59D for ; Tue, 25 Jun 2024 08:03:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 6CFEE386C59D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=lambda.is Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=lambda.is ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 6CFEE386C59D Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=212.103.80.154 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719302632; cv=none; b=j/AHC0ANIhsCPXiG2Qhv0voPeVnA8+fjLYpw9rqaDu88gk5bvE7T+m6aAEWuY851pxNi5gaRGkG7TYGMGYtth32PxSO3jEZEKDpjxCKSa5MWLffmtVhBoJFnwd5AwLL0/mo8ldrQ34mTpIJ9b+TLQAxpHHIBI8GnX5RFnQl85yQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1719302632; c=relaxed/simple; bh=JrCq3fYxcLcdUnceyLWW7rNNjMgps1e8E7iehhPfBwo=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=G12hti2eF+mHnisHnXMBP9sCi5fX8iJG8pSkK/f/2guaTW1pWgDinl09AMFR293GWwDNP/frIcLTJdoz+OY6cAwjucuhChJHKR+vbqASX1rudyOzCZ3EyQE1WNJ9LQxHwHnl5k30+FypT6PBBircdnnXIRMb0wtEI/7VM7M/ovE= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 7E9F33004C4C; Tue, 25 Jun 2024 10:03:43 +0200 (CEST) Authentication-Results: ext-mx-out013.mykolab.com (amavis); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20240523; t=1719302622; x=1721117023; bh=Que0IEqL+gfkVuelscewoK9/l9Tc4OrTZxmC1PYyhC0=; b=f7WV7sLbeGny Gp7oyM54d176WFWcA3RwIrRAILXiYIAC3PgdW0fzNYF7pxFwz13dolsAbSUWpzr0 Ds9wIdFvAhPjKKu+tQicp0pZBheHioMqLkC1GjrINzg04ieOidJTYgggWQq1svk7 /2+pUNrh5xMfmHOs+kfTyB4ihpTiCSWR8Co62eM0iYZcVgrFvVnAzwi03YQyRY+B TOhNyKYMct2bfTMtH9NOpEn8aCzVKNREDVfG/M7vzB5kFxGHyO08yB3wsq5nNC8S Pu/EXOvqbE7xsoyzu9v9KV7LpClNWzVnTjKcHartFWOddXvlpR9BrfV40kytbex+ GoDM8mEK/Q== X-Virus-Scanned: amavis at mykolab.com X-Spam-Score: -1 X-Spam-Level: X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,GIT_PATCH_0,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out013.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id FrNodVOFzg3y; Tue, 25 Jun 2024 10:03:42 +0200 (CEST) Received: from int-mx009.mykolab.com (unknown [10.9.13.9]) by mx.kolabnow.com (Postfix) with ESMTPS id 8E52D3004C5C; Tue, 25 Jun 2024 10:03:42 +0200 (CEST) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx009.mykolab.com (Postfix) with ESMTPS id 5F41C21F0909; Tue, 25 Jun 2024 10:03:42 +0200 (CEST) From: =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= To: gcc-patches@gcc.gnu.org Cc: hubicka@ucw.cz, =?UTF-8?q?J=C3=B8rgen=20Kvalsvik?= Subject: [PATCH 2/3] Add section on MC/DC in gcov manual Date: Tue, 25 Jun 2024 10:03:31 +0200 Message-Id: <20240625080332.1517736-3-j@lambda.is> In-Reply-To: <20240625080332.1517736-1-j@lambda.is> References: <20240625080332.1517736-1-j@lambda.is> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: gcc/ChangeLog: * doc/gcov.texi: Add MC/DC section. --- gcc/doc/gcov.texi | 72 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/gcc/doc/gcov.texi b/gcc/doc/gcov.texi index dc79bccb8cf..a9221738cce 100644 --- a/gcc/doc/gcov.texi +++ b/gcc/doc/gcov.texi @@ -917,6 +917,78 @@ of times the call was executed will be printed. This will usually be 100%, but may be less for functions that call @code{exit} or @code{longjmp}, and thus may not return every time they are called. +When you use the @option{-g} option, your output looks like this: + +@smallexample +$ gcov -t -m -g tmp + -: 0:Source:tmp.cpp + -: 0:Graph:tmp.gcno + -: 0:Data:tmp.gcda + -: 0:Runs:1 + -: 1:#include + -: 2: + -: 3:int + 1: 4:main (void) + -: 5:@{ + -: 6: int i, total; + 1: 7: total = 0; + -: 8: + 11: 9: for (i = 0; i < 10; i++) +condition outcomes covered 2/2 + 10: 10: total += i; + -: 11: + 1*: 12: int v = total > 100 ? 1 : 2; +condition outcomes covered 1/2 +condition 0 not covered (true) + -: 13: + 1*: 14: if (total != 45 && v == 1) +condition outcomes covered 1/4 +condition 0 not covered (true) +condition 1 not covered (true false) + #####: 15: printf ("Failure\n"); + -: 16: else + 1: 17: printf ("Success\n"); + 1: 18: return 0; + -: 19:@} +@end smallexample + +For every condition the number of taken and total outcomes are +printed, and if there are uncovered outcomes a line will be printed +for each condition showing the uncovered outcome in parentheses. +Conditions are identified by their index -- index 0 is the left-most +condition. In @code{a || (b && c)}, @var{a} is condition 0, @var{b} +condition 1, and @var{c} condition 2. + +An outcome is considered covered if it has an independent effect on +the decision, also known as masking MC/DC (Modified Condition/Decision +Coverage). In this example the decision evaluates to true and @var{a} +is evaluated, but not covered. This is because @var{a} cannot affect +the decision independently -- both @var{a} and @var{b} must change +value for the decision to change. + +@smallexample +$ gcov -t -m -g tmp + -: 0:Source:tmp.c + -: 0:Graph:tmp.gcno + -: 0:Data:tmp.gcda + -: 0:Runs:1 + -: 1:#include + -: 2: + 1: 3:int main() + -: 4:@{ + 1: 5: int a = 1; + 1: 6: int b = 0; + -: 7: + 1: 8: if (a && b) +condition outcomes covered 1/4 +condition 0 not covered (true false) +condition 1 not covered (true) + #####: 9: printf ("Success!\n"); + -: 10: else + 1: 11: printf ("Failure!\n"); + -: 12:@} +@end smallexample + The execution counts are cumulative. If the example program were executed again without removing the @file{.gcda} file, the count for the number of times each line in the source was executed would be added to -- 2.39.2