Skip to content

Commit 2458823

Browse files
committed
Checkpoint_Load: stop using streaming attributes for non-trivial types
Use streaming attributes only for atomic data types with specific size (Unsigned_8, Integer_32, ...). Create explicit checkpoint reading procedures for the rest (records, containers, scalars with implicit size, ...).
1 parent 816fc18 commit 2458823

20 files changed

+1409
-297
lines changed

tools/gnatcov/ali_files.adb

Lines changed: 42 additions & 22 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,10 @@ 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+
3439
-----------------------------------------------
3540
-- Regular expressions for ALI files parsing --
3641
-----------------------------------------------
@@ -622,42 +627,57 @@ package body ALI_Files is
622627
return ALI_Index;
623628
end Load_ALI;
624629

630+
-----------
631+
-- Write --
632+
-----------
633+
634+
procedure Write (S : access Root_Stream_Type'Class; V : ALI_Annotation) is
635+
begin
636+
CU_Id'Write (S, V.CU);
637+
ALI_Annotation_Kind'Write (S, V.Kind);
638+
if V.Message /= null then
639+
String'Output (S, V.Message.all);
640+
else
641+
String'Output (S, "");
642+
end if;
643+
end Write;
644+
625645
----------
626646
-- Read --
627647
----------
628648

629649
procedure Read
630-
(S : access Root_Stream_Type'Class;
631-
V : out ALI_Annotation)
632-
is
650+
(CLS : in out Checkpoint_Load_State; Value : out ALI_Annotation) is
633651
begin
634-
CU_Id'Read (S, V.CU);
635-
ALI_Annotation_Kind'Read (S, V.Kind);
652+
Value.CU := CLS.Read_CU;
653+
Value.Kind := ALI_Annotation_Kind'Val (CLS.Read_U8);
636654

637655
declare
638-
Msg : constant String := String'Input (S);
656+
Msg : constant String := CLS.Read_String;
639657
begin
640658
if Msg'Length > 0 then
641-
V.Message := new String'(Msg);
659+
Value.Message := new String'(Msg);
642660
end if;
643661
end;
644-
V.Violation_Count := 0;
645-
V.Undetermined_Cov_Count := 0;
646-
end Read;
647662

648-
-----------
649-
-- Write --
650-
-----------
663+
Value.Violation_Count := 0;
664+
Value.Undetermined_Cov_Count := 0;
665+
end Read;
651666

652-
procedure Write (S : access Root_Stream_Type'Class; V : ALI_Annotation) is
667+
procedure Read
668+
(CLS : access Checkpoints.Checkpoint_Load_State;
669+
Value : out ALI_Annotation_Maps.Map)
670+
is
671+
procedure Read_Map is new Checkpoints.Read_Map
672+
(Key_Type => Source_Location,
673+
Element_Type => ALI_Annotation,
674+
Map_Type => ALI_Annotation_Maps.Map,
675+
Clear => ALI_Annotation_Maps.Clear,
676+
Insert => ALI_Annotation_Maps.Insert,
677+
Read_Key => Read,
678+
Read_Element => Read);
653679
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;
661-
end Write;
680+
Read_Map (CLS.all, Value);
681+
end Read;
662682

663683
end ALI_Files;

tools/gnatcov/ali_files.ads

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ with Ada.Streams; use Ada.Streams;
2424
with GNAT.Regexp;
2525
with GNAT.Strings; use GNAT.Strings;
2626

27+
limited with Checkpoints;
2728
with SC_Obligations; use SC_Obligations;
2829
with Slocs; use Slocs;
2930
with Types; use Types;
@@ -67,16 +68,19 @@ package ALI_Files is
6768
-- This is relevant only for source trace based coverage analysis.
6869
end record;
6970

70-
procedure Read (S : access Root_Stream_Type'Class; V : out ALI_Annotation);
7171
procedure Write (S : access Root_Stream_Type'Class; V : ALI_Annotation);
72-
for ALI_Annotation'Read use Read;
7372
for ALI_Annotation'Write use Write;
7473

7574
package ALI_Annotation_Maps is
7675
new Ada.Containers.Ordered_Maps
7776
(Key_Type => Source_Location,
7877
Element_Type => ALI_Annotation);
7978

79+
procedure Read
80+
(CLS : access Checkpoints.Checkpoint_Load_State;
81+
Value : out ALI_Annotation_Maps.Map);
82+
-- Read a ALI_Annotation_Maps.Map from CLS
83+
8084
ALI_Annotations : ALI_Annotation_Maps.Map;
8185

8286
function Load_ALI

0 commit comments

Comments
 (0)