Skip to content

Commit 4ffdb5c

Browse files
committed
Merge branch 'pmderodat/ckpt_no_stream' into 'master'
Checkpoint_Load/Save: stop using streaming attributes for non-trivial types Closes #157 See merge request eng/das/cov/gnatcoverage!337 Closes eng/das/cov/gnatcoverage#157
2 parents 816fc18 + ccbfaac commit 4ffdb5c

24 files changed

+2493
-503
lines changed

tools/gnatcov/ali_files.adb

Lines changed: 58 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ with Ada.Text_IO; use Ada.Text_IO;
2323
with GNAT.Regpat; use GNAT.Regpat;
2424
with SCOs;
2525

26+
with Checkpoints; use Checkpoints;
2627
with Diagnostics; use Diagnostics;
2728
with Files_Table; use Files_Table;
2829
with Get_SCOs;
@@ -31,6 +32,14 @@ with Outputs; use Outputs;
3132

3233
package body ALI_Files is
3334

35+
procedure Read
36+
(CLS : in out Checkpoint_Load_State; Value : out ALI_Annotation);
37+
-- Read a ALI_Annotation from CLS
38+
39+
procedure Write
40+
(CSS : in out Checkpoint_Save_State; Value : ALI_Annotation);
41+
-- Write a ALI_Annotation to CSS
42+
3443
-----------------------------------------------
3544
-- Regular expressions for ALI files parsing --
3645
-----------------------------------------------
@@ -627,37 +636,69 @@ package body ALI_Files is
627636
----------
628637

629638
procedure Read
630-
(S : access Root_Stream_Type'Class;
631-
V : out ALI_Annotation)
632-
is
639+
(CLS : in out Checkpoint_Load_State; Value : out ALI_Annotation) is
633640
begin
634-
CU_Id'Read (S, V.CU);
635-
ALI_Annotation_Kind'Read (S, V.Kind);
641+
Value.CU := CLS.Read_CU;
642+
Value.Kind := ALI_Annotation_Kind'Val (CLS.Read_U8);
636643

637644
declare
638-
Msg : constant String := String'Input (S);
645+
Msg : constant String := CLS.Read_String;
639646
begin
640647
if Msg'Length > 0 then
641-
V.Message := new String'(Msg);
648+
Value.Message := new String'(Msg);
642649
end if;
643650
end;
644-
V.Violation_Count := 0;
645-
V.Undetermined_Cov_Count := 0;
651+
652+
Value.Violation_Count := 0;
653+
Value.Undetermined_Cov_Count := 0;
654+
end Read;
655+
656+
procedure Read
657+
(CLS : in out Checkpoints.Checkpoint_Load_State;
658+
Value : out ALI_Annotation_Maps.Map)
659+
is
660+
procedure Read_Map is new Checkpoints.Read_Map
661+
(Key_Type => Source_Location,
662+
Element_Type => ALI_Annotation,
663+
Map_Type => ALI_Annotation_Maps.Map,
664+
Clear => ALI_Annotation_Maps.Clear,
665+
Insert => ALI_Annotation_Maps.Insert,
666+
Read_Key => Read,
667+
Read_Element => Read);
668+
begin
669+
Read_Map (CLS, Value);
646670
end Read;
647671

648672
-----------
649673
-- Write --
650674
-----------
651675

652-
procedure Write (S : access Root_Stream_Type'Class; V : ALI_Annotation) is
676+
procedure Write (CSS : in out Checkpoint_Save_State; Value : ALI_Annotation)
677+
is
653678
begin
654-
CU_Id'Write (S, V.CU);
655-
ALI_Annotation_Kind'Write (S, V.Kind);
656-
if V.Message /= null then
657-
String'Output (S, V.Message.all);
658-
else
659-
String'Output (S, "");
660-
end if;
679+
CSS.Write_CU (Value.CU);
680+
CSS.Write_U8 (ALI_Annotation_Kind'Pos (Value.Kind));
681+
CSS.Write_Unbounded (if Value.Message = null
682+
then ""
683+
else Value.Message.all);
684+
end Write;
685+
686+
procedure Write
687+
(CSS : in out Checkpoints.Checkpoint_Save_State;
688+
Value : ALI_Annotation_Maps.Map)
689+
is
690+
procedure Write_Map is new Checkpoints.Write_Map
691+
(Key_Type => Source_Location,
692+
Element_Type => ALI_Annotation,
693+
Map_Type => ALI_Annotation_Maps.Map,
694+
Cursor_Type => ALI_Annotation_Maps.Cursor,
695+
Length => ALI_Annotation_Maps.Length,
696+
Iterate => ALI_Annotation_Maps.Iterate,
697+
Query_Element => ALI_Annotation_Maps.Query_Element,
698+
Write_Key => Write,
699+
Write_Element => Write);
700+
begin
701+
Write_Map (CSS, Value);
661702
end Write;
662703

663704
end ALI_Files;

tools/gnatcov/ali_files.ads

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
-- ALI files reader
2020

2121
with Ada.Containers.Ordered_Maps;
22-
with Ada.Streams; use Ada.Streams;
2322

2423
with GNAT.Regexp;
2524
with GNAT.Strings; use GNAT.Strings;
2625

26+
limited with Checkpoints;
2727
with SC_Obligations; use SC_Obligations;
2828
with Slocs; use Slocs;
2929
with Types; use Types;
@@ -67,16 +67,21 @@ package ALI_Files is
6767
-- This is relevant only for source trace based coverage analysis.
6868
end record;
6969

70-
procedure Read (S : access Root_Stream_Type'Class; V : out ALI_Annotation);
71-
procedure Write (S : access Root_Stream_Type'Class; V : ALI_Annotation);
72-
for ALI_Annotation'Read use Read;
73-
for ALI_Annotation'Write use Write;
74-
7570
package ALI_Annotation_Maps is
7671
new Ada.Containers.Ordered_Maps
7772
(Key_Type => Source_Location,
7873
Element_Type => ALI_Annotation);
7974

75+
procedure Read
76+
(CLS : in out Checkpoints.Checkpoint_Load_State;
77+
Value : out ALI_Annotation_Maps.Map);
78+
-- Read a ALI_Annotation_Maps.Map from CLS
79+
80+
procedure Write
81+
(CSS : in out Checkpoints.Checkpoint_Save_State;
82+
Value : ALI_Annotation_Maps.Map);
83+
-- Write a ALI_Annotation_Maps.Map to CSS
84+
8085
ALI_Annotations : ALI_Annotation_Maps.Map;
8186

8287
function Load_ALI

0 commit comments

Comments
 (0)