Skip to content

Commit 21c170b

Browse files
committed
Add API to reset coverage buffers
The Ada API of the Ada instrumentation runtime must be strictly the same as the Ada API of the standard instrumentation runtime. GNATCOV_RTS.Buffers.Lists was missing the Reset_Group_Array_Buffers subprogram which resulted in the manual dump trigger not working.
1 parent de84521 commit 21c170b

File tree

2 files changed

+120
-0
lines changed

2 files changed

+120
-0
lines changed
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
------------------------------------------------------------------------------
2+
-- --
3+
-- GNATcoverage Instrumentation Runtime --
4+
-- --
5+
-- Copyright (C) 2024, AdaCore --
6+
-- --
7+
-- GNATcoverage is free software; you can redistribute it and/or modify it --
8+
-- under terms of the GNU General Public License as published by the Free --
9+
-- Software Foundation; either version 3, or (at your option) any later --
10+
-- version. This software is distributed in the hope that it will be useful --
11+
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
12+
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. --
13+
-- --
14+
-- As a special exception under Section 7 of GPL version 3, you are granted --
15+
-- additional permissions described in the GCC Runtime Library Exception, --
16+
-- version 3.1, as published by the Free Software Foundation. --
17+
-- --
18+
-- You should have received a copy of the GNU General Public License and --
19+
-- a copy of the GCC Runtime Library Exception along with this program; --
20+
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
21+
-- <http://www.gnu.org/licenses/>. --
22+
-- --
23+
------------------------------------------------------------------------------
24+
25+
with System; use System;
26+
27+
package body GNATcov_RTS.Buffers.Lists is
28+
29+
procedure Reset_Buffer
30+
(Buffer_Address : System.Address; Last_Bit_Id : Any_Bit_Id);
31+
-- Reset a coverage buffer
32+
33+
procedure Reset_Buffers (C_Buffers : Coverage_Buffers_Access);
34+
-- Reset statement, decision, and mcdc coverage buffers
35+
36+
procedure Reset_Buffers_Group
37+
(C_Buffers_Group : Coverage_Buffers_Group_Access);
38+
-- Reset a buffers group, which consists of all the buffers for a unit,
39+
-- i.e. for its specification, its body, and its separates.
40+
41+
------------------
42+
-- Reset_Buffer --
43+
------------------
44+
45+
procedure Reset_Buffer
46+
(Buffer_Address : System.Address; Last_Bit_Id : Any_Bit_Id)
47+
is
48+
Buffer : Coverage_Buffer_Type (1 .. Last_Bit_Id);
49+
for Buffer'Address use Buffer_Address;
50+
begin
51+
for I in Buffer'Range loop
52+
Buffer (I) := False;
53+
end loop;
54+
end Reset_Buffer;
55+
56+
-------------------
57+
-- Reset_Buffers --
58+
-------------------
59+
60+
procedure Reset_Buffers (C_Buffers : Coverage_Buffers_Access) is
61+
begin
62+
if C_Buffers = null then
63+
return;
64+
end if;
65+
if C_Buffers.Statement /= System.Null_Address then
66+
Reset_Buffer (C_Buffers.Statement, C_Buffers.Statement_Last_Bit);
67+
end if;
68+
if C_Buffers.Decision /= System.Null_Address then
69+
Reset_Buffer (C_Buffers.Decision, C_Buffers.Decision_Last_Bit);
70+
end if;
71+
if C_Buffers.MCDC /= System.Null_Address then
72+
Reset_Buffer (C_Buffers.Statement, C_Buffers.MCDC_Last_Bit);
73+
end if;
74+
end Reset_Buffers;
75+
76+
-------------------------
77+
-- Reset_Buffers_Group --
78+
-------------------------
79+
80+
procedure Reset_Buffers_Group
81+
(C_Buffers_Group : Coverage_Buffers_Group_Access) is
82+
begin
83+
if C_Buffers_Group = null then
84+
return;
85+
end if;
86+
declare
87+
Buffers_Group : Coverage_Buffers_Group
88+
(1 .. Integer (C_Buffers_Group.Length));
89+
pragma Import (C, Buffers_Group);
90+
for Buffers_Group'Address use C_Buffers_Group.Buffers;
91+
begin
92+
for I in Buffers_Group'Range loop
93+
Reset_Buffers (Buffers_Group (I));
94+
end loop;
95+
end;
96+
end Reset_Buffers_Group;
97+
98+
-------------------------------
99+
-- Reset_Group_Array_Buffers --
100+
-------------------------------
101+
102+
procedure Reset_Group_Array_Buffers
103+
(Arr : GNATcov_RTS_Coverage_Buffers_Group_Array)
104+
is
105+
Buffers_Groups : Coverage_Buffers_Group_Array
106+
(1 .. Integer (Arr.Length));
107+
pragma Import (C, Buffers_Groups);
108+
for Buffers_Groups'Address use Arr.Groups;
109+
begin
110+
for I in Buffers_Groups'Range loop
111+
Reset_Buffers_Group (Buffers_Groups (I));
112+
end loop;
113+
end Reset_Group_Array_Buffers;
114+
115+
end GNATcov_RTS.Buffers.Lists;

tools/gnatcov/ada-rts/gnatcov_rts-buffers-lists.ads

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,9 @@ package GNATcov_RTS.Buffers.Lists is
5959
end record;
6060
pragma Convention (C, GNATcov_RTS_Coverage_Buffers_Group_Array);
6161

62+
procedure Reset_Group_Array_Buffers
63+
(Arr : GNATcov_RTS_Coverage_Buffers_Group_Array);
64+
-- Set the components of all the buffers in each group to zero, effectively
65+
-- resetting the coverage state of all obligations to "not covered".
66+
6267
end GNATcov_RTS.Buffers.Lists;

0 commit comments

Comments
 (0)