Skip to content

Commit 1070f9d

Browse files
committed
Checkpoint_Save: 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 writing procedures for the rest (records, containers, scalars with implicit size, ...).
1 parent 457233f commit 1070f9d

19 files changed

+1119
-238
lines changed

tools/gnatcov/ali_files.adb

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ package body ALI_Files is
3636
(CLS : in out Checkpoint_Load_State; Value : out ALI_Annotation);
3737
-- Read a ALI_Annotation from CLS
3838

39+
procedure Write
40+
(CSS : in out Checkpoint_Save_State; Value : ALI_Annotation);
41+
-- Write a ALI_Annotation to CSS
42+
3943
-----------------------------------------------
4044
-- Regular expressions for ALI files parsing --
4145
-----------------------------------------------
@@ -627,21 +631,6 @@ package body ALI_Files is
627631
return ALI_Index;
628632
end Load_ALI;
629633

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-
645634
----------
646635
-- Read --
647636
----------
@@ -680,4 +669,36 @@ package body ALI_Files is
680669
Read_Map (CLS, Value);
681670
end Read;
682671

672+
-----------
673+
-- Write --
674+
-----------
675+
676+
procedure Write (CSS : in out Checkpoint_Save_State; Value : ALI_Annotation)
677+
is
678+
begin
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);
702+
end Write;
703+
683704
end ALI_Files;

tools/gnatcov/ali_files.ads

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
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;
@@ -68,9 +67,6 @@ package ALI_Files is
6867
-- This is relevant only for source trace based coverage analysis.
6968
end record;
7069

71-
procedure Write (S : access Root_Stream_Type'Class; V : ALI_Annotation);
72-
for ALI_Annotation'Write use Write;
73-
7470
package ALI_Annotation_Maps is
7571
new Ada.Containers.Ordered_Maps
7672
(Key_Type => Source_Location,
@@ -81,6 +77,11 @@ package ALI_Files is
8177
Value : out ALI_Annotation_Maps.Map);
8278
-- Read a ALI_Annotation_Maps.Map from CLS
8379

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+
8485
ALI_Annotations : ALI_Annotation_Maps.Map;
8586

8687
function Load_ALI

0 commit comments

Comments
 (0)