Skip to content

Commit b2569e9

Browse files
committed
Fix build with C_SUPPORT=False
Adapt the stub after Instrument.C specification changes. Change-Id: I548d8f04093b8bb77c705f25d939e5fd86952972 TN: V927-039 (cherry picked from commit 0c9cb7a)
1 parent 56d00a5 commit b2569e9

File tree

2 files changed

+68
-58
lines changed

2 files changed

+68
-58
lines changed

tools/gnatcov/instrument-c__stub.adb

+28-37
Original file line numberDiff line numberDiff line change
@@ -21,61 +21,52 @@ package body Instrument.C is
2121
Error_Msg : constant String :=
2222
"GNATcoverage not built with C support.";
2323

24-
---------------------------
25-
-- Add_Auto_Dump_Buffers --
26-
---------------------------
24+
----------------------
25+
-- Skip_Source_File --
26+
----------------------
2727

28-
procedure Add_Auto_Dump_Buffers
29-
(IC : Inst_Context;
30-
Info : in out Project_Info;
31-
Main : Compilation_Unit_Name;
32-
Rew : C_Source_Rewriter) is
33-
begin
34-
raise Program_Error with Error_Msg;
35-
end Add_Auto_Dump_Buffers;
28+
function Skip_Source_File
29+
(Self : C_Family_Instrumenter_Type;
30+
Source_File : GNATCOLL.Projects.File_Info) return Boolean
31+
is (raise Program_Error with Error_Msg);
3632

37-
-----------
38-
-- Apply --
39-
-----------
33+
---------------------
34+
-- Instrument_Unit --
35+
---------------------
4036

41-
procedure Apply (Self : in out C_Source_Rewriter) is
37+
procedure Instrument_Unit
38+
(Self : C_Family_Instrumenter_Type;
39+
CU_Name : Compilation_Unit_Name;
40+
IC : in out Inst_Context;
41+
Unit_Info : in out Instrumented_Unit_Info) is
4242
begin
4343
raise Program_Error with Error_Msg;
44-
end Apply;
44+
end Instrument_Unit;
4545

46-
---------------------
47-
-- Start_Rewriting --
48-
---------------------
46+
-------------------------------
47+
-- Auto_Dump_Buffers_In_Main --
48+
-------------------------------
4949

50-
procedure Start_Rewriting
51-
(Self : out C_Source_Rewriter;
52-
Info : in out Project_Info;
53-
Input_Filename : String) is
50+
procedure Auto_Dump_Buffers_In_Main
51+
(Self : C_Family_Instrumenter_Type;
52+
IC : in out Inst_Context;
53+
Main : Compilation_Unit_Name;
54+
Filename : String;
55+
Info : in out Project_Info) is
5456
begin
5557
raise Program_Error with Error_Msg;
56-
end Start_Rewriting;
58+
end Auto_Dump_Buffers_In_Main;
5759

5860
----------------------------
5961
-- Emit_Buffers_List_Unit --
6062
----------------------------
6163

6264
procedure Emit_Buffers_List_Unit
63-
(IC : in out Inst_Context;
65+
(Self : C_Family_Instrumenter_Type;
66+
IC : in out Inst_Context;
6467
Root_Project_Info : in out Project_Info) is
6568
begin
6669
raise Program_Error with Error_Msg;
6770
end Emit_Buffers_List_Unit;
6871

69-
---------------------
70-
-- Instrument_Unit --
71-
---------------------
72-
73-
procedure Instrument_Unit
74-
(CU_Name : Compilation_Unit_Name;
75-
IC : in out Inst_Context;
76-
Unit_Info : in out Instrumented_Unit_Info) is
77-
begin
78-
raise Program_Error with Error_Msg;
79-
end Instrument_Unit;
80-
8172
end Instrument.C;

tools/gnatcov/instrument-c__stub.ads

+40-21
Original file line numberDiff line numberDiff line change
@@ -24,38 +24,57 @@
2424
-- units, using the procedures defined here, which will result in a crash (all
2525
-- the procedures are empty stubs raising an error).
2626

27+
with GNATCOLL.Projects; use GNATCOLL.Projects;
28+
2729
with Instrument.Base_Types; use Instrument.Base_Types;
2830
with Instrument.Common; use Instrument.Common;
31+
with Switches; use Switches;
2932

3033
private package Instrument.C is
31-
type C_Source_Decision is null record;
3234

33-
type C_Source_Condition is null record;
35+
type C_Family_Instrumenter_Type is
36+
abstract new Language_Instrumenter with null record;
37+
-- Common instrumentation primitives for C/C++
3438

35-
type C_Unit_Inst_Context is null record;
39+
overriding function Skip_Source_File
40+
(Self : C_Family_Instrumenter_Type;
41+
Source_File : GNATCOLL.Projects.File_Info) return Boolean;
3642

37-
type C_Source_Rewriter is tagged limited null record;
43+
overriding procedure Instrument_Unit
44+
(Self : C_Family_Instrumenter_Type;
45+
CU_Name : Compilation_Unit_Name;
46+
IC : in out Inst_Context;
47+
Unit_Info : in out Instrumented_Unit_Info);
3848

39-
procedure Add_Auto_Dump_Buffers
40-
(IC : Inst_Context;
41-
Info : in out Project_Info;
42-
Main : Compilation_Unit_Name;
43-
Rew : C_Source_Rewriter);
49+
overriding procedure Auto_Dump_Buffers_In_Main
50+
(Self : C_Family_Instrumenter_Type;
51+
IC : in out Inst_Context;
52+
Main : Compilation_Unit_Name;
53+
Filename : String;
54+
Info : in out Project_Info);
4455

45-
procedure Apply (Self : in out C_Source_Rewriter);
56+
overriding procedure Emit_Buffers_List_Unit
57+
(Self : C_Family_Instrumenter_Type;
58+
IC : in out Inst_Context;
59+
Root_Project_Info : in out Project_Info);
4660

47-
procedure Start_Rewriting
48-
(Self : out C_Source_Rewriter;
49-
Info : in out Project_Info;
50-
Input_Filename : String);
61+
type C_Instrumenter_Type is
62+
new C_Family_Instrumenter_Type with null record;
63+
-- Instrumentation primitives for C
5164

52-
procedure Emit_Buffers_List_Unit
53-
(IC : in out Inst_Context;
54-
Root_Project_Info : in out Project_Info);
65+
overriding function Language
66+
(Self : C_Instrumenter_Type) return Src_Supported_Language
67+
is (C_Language);
5568

56-
procedure Instrument_Unit
57-
(CU_Name : Compilation_Unit_Name;
58-
IC : in out Inst_Context;
59-
Unit_Info : in out Instrumented_Unit_Info);
69+
type CPP_Instrumenter_Type is
70+
new C_Family_Instrumenter_Type with null record;
71+
-- Instrumentation primitives for C++
72+
73+
overriding function Language
74+
(Self : CPP_Instrumenter_Type) return Src_Supported_Language
75+
is (CPP_Language);
76+
77+
C_Instrumenter : aliased constant C_Instrumenter_Type := (null record);
78+
CPP_Instrumenter : aliased constant CPP_Instrumenter_Type := (null record);
6079

6180
end Instrument.C;

0 commit comments

Comments
 (0)