Skip to content

Commit 37cec71

Browse files
committed
Merge branch 'pmderodat/version_less' into 'master'
Preparatory work to avoid streaming attributes for Checkpoint_Load See merge request eng/das/cov/gnatcoverage!329 Remove dead code and rework a bit checkpoint load state primitives. For eng/das/cov/gnatcoverage#157
2 parents 8107788 + d987517 commit 37cec71

9 files changed

+145
-341
lines changed

tools/gnatcov/checkpoints.adb

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -583,36 +583,32 @@ package body Checkpoints is
583583
-- Check that we are loading the kind of checkpoint we are
584584
-- expecting (Purpose).
585585

586-
if not Version_Less (CLS'Access, Than => 2) then
587-
declare
588-
CP_Purpose : constant Checkpoint_Purpose :=
589-
Checkpoint_Purpose'Input (CLS.Stream);
590-
begin
591-
if CP_Purpose /= Purpose then
592-
Fatal_Error
593-
(Filename & " is a " & Purpose_Name (CP_Purpose)
594-
& " while a " & Purpose_Name (Purpose)
595-
& " was expected");
596-
end if;
597-
end;
598-
end if;
586+
declare
587+
CP_Purpose : constant Checkpoint_Purpose :=
588+
Checkpoint_Purpose'Input (CLS.Stream);
589+
begin
590+
if CP_Purpose /= Purpose then
591+
Fatal_Error
592+
(Filename & " is a " & Purpose_Name (CP_Purpose)
593+
& " while a " & Purpose_Name (Purpose)
594+
& " was expected");
595+
end if;
596+
end;
599597

600598
-- Check the kind of binary traces that were used to create this
601599
-- checkpoint.
602600

603-
if not Version_Less (CLS'Access, Than => 7) then
604-
declare
605-
Bits : constant Binary_Traces_Bits :=
606-
Binary_Traces_Bits'Input (CLS.Stream);
607-
begin
608-
if Bits not in Undetermined | Supported_Bits then
609-
Fatal_Error
610-
(Filename & " was created with " & Image (Bits)
611-
& " whereas the selected target requires "
612-
& Image (Supported_Bits));
613-
end if;
614-
end;
615-
end if;
601+
declare
602+
Bits : constant Binary_Traces_Bits :=
603+
Binary_Traces_Bits'Input (CLS.Stream);
604+
begin
605+
if Bits not in Undetermined | Supported_Bits then
606+
Fatal_Error
607+
(Filename & " was created with " & Image (Bits)
608+
& " whereas the selected target requires "
609+
& Image (Supported_Bits));
610+
end if;
611+
end;
616612

617613
Levels_Type'Read (CLS.Stream, Levels);
618614
declare
@@ -624,20 +620,16 @@ package body Checkpoints is
624620
end if;
625621
end;
626622

627-
if not Version_Less (CLS'Access, Than => 6) then
628-
declare
629-
CP_Trace_Kind : Any_Accepted_Trace_Kind;
630-
begin
631-
Any_Accepted_Trace_Kind'Read (CLS.Stream, CP_Trace_Kind);
632-
Update_Current_Trace_Kind (CP_Trace_Kind);
633-
end;
634-
end if;
623+
declare
624+
CP_Trace_Kind : Any_Accepted_Trace_Kind;
625+
begin
626+
Any_Accepted_Trace_Kind'Read (CLS.Stream, CP_Trace_Kind);
627+
Update_Current_Trace_Kind (CP_Trace_Kind);
628+
end;
635629

636630
Files_Table.Checkpoint_Load (CLS'Access, Ignored_Source_Files);
637631
SC_Obligations.Checkpoint_Load (CLS'Access);
638-
if not Version_Less (CLS'Access, Than => 2) then
639-
Instrument.Checkpoints.Checkpoint_Load (CLS'Access);
640-
end if;
632+
Instrument.Checkpoints.Checkpoint_Load (CLS'Access);
641633
Coverage.Source.Checkpoint_Load (CLS'Access);
642634
Traces_Files_Registry.Checkpoint_Load (CLS'Access);
643635

tools/gnatcov/checkpoints.ads

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,15 +253,15 @@ package Checkpoints is
253253

254254
use type Interfaces.Unsigned_32;
255255
function Version_Less
256-
(CS : access Root_Stream_Type'Class; Than : Checkpoint_Version)
257-
return Boolean is (Stateful_Stream (CS.all).Version < Than)
256+
(SS : Stateful_Stream'Class; Than : Checkpoint_Version) return Boolean
257+
is (SS.Version < Than)
258258
with Inline;
259259
-- This is provided as a function to prevent the compiler from generating
260260
-- "can never be greater than" warnings.
261261

262262
function Purpose_Of
263-
(CS : access Root_Stream_Type'Class) return Checkpoint_Purpose
264-
is (Stateful_Stream (CS.all).Purpose)
263+
(SS : Stateful_Stream'Class) return Checkpoint_Purpose
264+
is (SS.Purpose)
265265
with Inline;
266266
-- Shortcut to get the purpose of a stream that is known to be an instance
267267
-- of Stateful_Stream.

tools/gnatcov/coverage-source.adb

Lines changed: 16 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ with Ada.Containers.Ordered_Maps;
2323
with Ada.Directories;
2424
with Ada.Streams; use Ada.Streams;
2525
with Ada.Strings.Unbounded;
26-
with Ada.Tags;
2726
with Ada.Unchecked_Deallocation;
2827

2928
with Interfaces;
@@ -477,11 +476,6 @@ package body Coverage.Source is
477476
procedure Checkpoint_Load (CLS : access Checkpoint_Load_State) is
478477
use SCI_Vector_Vectors;
479478

480-
Stream_Tags : constant Boolean :=
481-
not Checkpoints.Version_Less (CLS, Than => 2);
482-
-- Before version 2, we streamed mere tags in the checkpoint. We stream
483-
-- tag provider names since then.
484-
485479
CP_Tag_Provider : Unbounded_String;
486480
CP_SCI_Vector : SCI_Vector_Vectors.Vector;
487481
Relocs : Checkpoint_Relocations renames CLS.Relocations;
@@ -492,23 +486,7 @@ package body Coverage.Source is
492486
-- tag provider is the default (i.e. no coverage separation), or same
493487
-- as checkpoint.
494488

495-
if Stream_Tags then
496-
CP_Tag_Provider := To_Unbounded_String (String'Input (CLS));
497-
else
498-
declare
499-
Tag : Ada.Tags.Tag;
500-
begin
501-
Ada.Tags.Tag'Read (CLS, Tag);
502-
CP_Tag_Provider := To_Unbounded_String (Tag_Providers.Name (Tag));
503-
exception
504-
when Constraint_Error =>
505-
Warn ("cannot read " & To_String (CLS.Filename)
506-
& ", it was produced with an incompatible version of "
507-
& "gnatcov");
508-
CP_Tag_Provider := To_Unbounded_String ("<unknown>");
509-
end;
510-
end if;
511-
489+
CP_Tag_Provider := To_Unbounded_String (String'Input (CLS));
512490
if Tag_Provider.all not in Default_Tag_Provider_Type
513491
and then Tag_Provider_Name /= To_String (CP_Tag_Provider)
514492
then
@@ -570,49 +548,21 @@ package body Coverage.Source is
570548

571549
if CLS.Purpose = Consolidation then
572550

573-
-- Before version 3, this list was not streamed. In this case, be
574-
-- conservative and consider that we don't have a valid list.
575-
576-
if Checkpoints.Version_Less (CLS, Than => 3) then
577-
Invalidate_Unit_List
578-
(US.To_String (CLS.Filename)
579-
& " does not contain the list of units (obsolete format)");
580-
581-
else
582-
declare
583-
Invalidated : constant Boolean := Boolean'Input (CLS);
584-
Obsolete : constant Boolean :=
585-
Checkpoints.Version_Less (CLS, Than => 12);
586-
Dummy : US.Unbounded_String;
587-
begin
588-
if Invalidated then
589-
Invalidate_Unit_List
590-
(US.To_String (CLS.Filename)
591-
& " does not contain the list of units (produced with"
592-
& " --scos or --sid)");
593-
else
594-
for I in 1 .. Ada.Containers.Count_Type'Input (CLS) loop
595-
596-
-- From version 3 up to version 11, Unit_List used to
597-
-- be a set of unbounded strings, and did not support
598-
-- homonym source files. If we are in that case, read the
599-
-- old Unit_List from the checkpoint and then discard it.
600-
601-
if Obsolete then
602-
if I = 1 then
603-
Invalidate_Unit_List
604-
(US.To_String (CLS.Filename)
605-
& " does not contain the list of units (obsolete"
606-
& " format)");
607-
end if;
608-
US.Unbounded_String'Read (CLS, Dummy);
609-
else
610-
Unit_List.Include (Compilation_Unit'Input (CLS));
611-
end if;
612-
end loop;
613-
end if;
614-
end;
615-
end if;
551+
declare
552+
Invalidated : constant Boolean := Boolean'Input (CLS);
553+
Dummy : US.Unbounded_String;
554+
begin
555+
if Invalidated then
556+
Invalidate_Unit_List
557+
(US.To_String (CLS.Filename)
558+
& " does not contain the list of units (produced with --scos"
559+
& " or --sid)");
560+
else
561+
for I in 1 .. Ada.Containers.Count_Type'Input (CLS) loop
562+
Unit_List.Include (Compilation_Unit'Input (CLS));
563+
end loop;
564+
end if;
565+
end;
616566
end if;
617567
end Checkpoint_Load;
618568

tools/gnatcov/files_table.adb

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2033,32 +2033,15 @@ package body Files_Table is
20332033

20342034
FE.Ignore_Status := Unknown;
20352035
FE.Unit := (Known => False);
2036-
if not Checkpoints.Version_Less (CLS, Than => 5) then
2037-
FE.Ignore_Status := Any_Ignore_Status'Input (S);
2038-
declare
2039-
Unit_Known : constant Boolean := Boolean'Input (S);
2040-
begin
2041-
if Unit_Known then
2042-
2043-
-- Starting with the version 13 of checkpoints,
2044-
-- owning units are represented as Compilation_Unit
2045-
-- values (they were mere strings before). Consider
2046-
-- the owning unit unknown if we do not have recent
2047-
-- formats.
2048-
2049-
if Checkpoints.Version_Less (CLS, Than => 13) then
2050-
declare
2051-
Dummy : constant String := String'Input (S);
2052-
begin
2053-
null;
2054-
end;
2055-
else
2056-
FE.Unit := (Known => True,
2057-
Name => Compilation_Unit'Input (S));
2058-
end if;
2059-
end if;
2060-
end;
2061-
end if;
2036+
FE.Ignore_Status := Any_Ignore_Status'Input (S);
2037+
declare
2038+
Unit_Known : constant Boolean := Boolean'Input (S);
2039+
begin
2040+
if Unit_Known then
2041+
FE.Unit := (Known => True,
2042+
Name => Compilation_Unit'Input (S));
2043+
end if;
2044+
end;
20622045
when Library_File =>
20632046
FE := (Kind => Library_File, others => <>);
20642047
FE.Main_Source := Source_File_Index'Input (S);

tools/gnatcov/instrument-checkpoints.adb

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -95,46 +95,44 @@ package body Instrument.Checkpoints is
9595

9696
-- Load the mappings for preprocessing commands
9797

98-
if not Version_Less (CLS, Than => 8) then
99-
declare
100-
CP_PP_Cmds : SFI_To_PP_Cmd_Maps.Map;
101-
CP_SFI : Source_File_Index;
102-
begin
103-
SFI_To_PP_Cmd_Maps.Map'Read (CLS.Stream, CP_PP_Cmds);
104-
105-
for CP_Cur in CP_PP_Cmds.Iterate loop
106-
107-
-- If this source file is now ignored, just discard its
108-
-- preprocessing commands.
109-
110-
CP_SFI := SFI_To_PP_Cmd_Maps.Key (CP_Cur);
111-
if not SFI_Ignored (Relocs, CP_SFI) then
112-
declare
113-
SFI : constant Source_File_Index :=
114-
Remap_SFI (Relocs, CP_SFI);
115-
Cur : constant SFI_To_PP_Cmd_Maps.Cursor :=
116-
PP_Cmds.Find (SFI);
117-
begin
118-
-- If there was no known preprocessing command for SFI so
119-
-- far, just register the loaded one.
120-
121-
if not SFI_To_PP_Cmd_Maps.Has_Element (Cur) then
122-
PP_Cmds.Insert (SFI, CP_PP_Cmds.Reference (CP_Cur));
123-
124-
-- Otherwise, warn if the already known command and the
98+
declare
99+
CP_PP_Cmds : SFI_To_PP_Cmd_Maps.Map;
100+
CP_SFI : Source_File_Index;
101+
begin
102+
SFI_To_PP_Cmd_Maps.Map'Read (CLS.Stream, CP_PP_Cmds);
103+
104+
for CP_Cur in CP_PP_Cmds.Iterate loop
105+
106+
-- If this source file is now ignored, just discard its
107+
-- preprocessing commands.
108+
109+
CP_SFI := SFI_To_PP_Cmd_Maps.Key (CP_Cur);
110+
if not SFI_Ignored (Relocs, CP_SFI) then
111+
declare
112+
SFI : constant Source_File_Index :=
113+
Remap_SFI (Relocs, CP_SFI);
114+
Cur : constant SFI_To_PP_Cmd_Maps.Cursor :=
115+
PP_Cmds.Find (SFI);
116+
begin
117+
-- If there was no known preprocessing command for SFI so
118+
-- far, just register the loaded one.
119+
120+
if not SFI_To_PP_Cmd_Maps.Has_Element (Cur) then
121+
PP_Cmds.Insert (SFI, CP_PP_Cmds.Reference (CP_Cur));
122+
123+
-- Otherwise, warn if the already known command and the
125124
-- loaded one are different.
126125

127-
elsif CP_PP_Cmds.Reference (CP_Cur)
128-
/= PP_Cmds.Reference (Cur)
129-
then
130-
Warn ("inconsistent information for instrumented file "
131-
& Get_Full_Name (SFI));
132-
end if;
133-
end;
134-
end if;
135-
end loop;
136-
end;
137-
end if;
126+
elsif CP_PP_Cmds.Reference (CP_Cur)
127+
/= PP_Cmds.Reference (Cur)
128+
then
129+
Warn ("inconsistent information for instrumented file "
130+
& Get_Full_Name (SFI));
131+
end if;
132+
end;
133+
end if;
134+
end loop;
135+
end;
138136
end Checkpoint_Load;
139137

140138
end Instrument.Checkpoints;

tools/gnatcov/sc_obligations-bdd.adb

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -81,30 +81,20 @@ package body SC_Obligations.BDD is
8181
-- Read --
8282
----------
8383

84-
procedure Read
85-
(S : access Root_Stream_Type'Class;
86-
V : out BDD_Type)
87-
is
84+
procedure Read (S : access Root_Stream_Type'Class; V : out BDD_Type) is
8885
begin
8986
SCO_Id'Read (S, V.Decision);
9087
BDD_Node_Id'Read (S, V.Root_Condition);
9188
BDD_Node_Id'Read (S, V.First_Node);
9289
BDD_Node_Id'Read (S, V.Last_Node);
9390
BDD_Node_Id'Read (S, V.First_Multipath_Condition);
9491
Reachability'Read (S, V.Reachable_Outcomes);
95-
96-
if not Version_Less (S, Than => 2) then
97-
Natural'Read (S, V.Path_Count);
98-
end if;
92+
Natural'Read (S, V.Path_Count);
9993
end Read;
10094

101-
procedure Read
102-
(S : access Root_Stream_Type'Class;
103-
V : out BDD_Node)
104-
is
95+
procedure Read (S : access Root_Stream_Type'Class; V : out BDD_Node) is
10596
New_BDDN : BDD_Node (BDD_Node_Kind'Input (S));
10697
pragma Warnings (Off, New_BDDN);
107-
10898
begin
10999
-- Set discriminant
110100

@@ -119,12 +109,7 @@ package body SC_Obligations.BDD is
119109
Boolean'Read (S, V.Parent_Value);
120110
SCO_Id'Read (S, V.C_SCO);
121111
Destinations'Read (S, V.Dests);
122-
123-
-- Checkpoint version 2 data (instrumentation support)
124-
125-
if not Version_Less (S, 2) then
126-
Natural'Read (S, V.Path_Offset);
127-
end if;
112+
Natural'Read (S, V.Path_Offset);
128113

129114
when Jump =>
130115
BDD_Node_Id'Read (S, V.Dest);

0 commit comments

Comments
 (0)