Skip to content

Commit

Permalink
Fix build with C_SUPPORT=False
Browse files Browse the repository at this point in the history
Adapt the stub after Instrument.C specification changes.

Change-Id: I548d8f04093b8bb77c705f25d939e5fd86952972
TN: V927-039
(cherry picked from commit 0c9cb7a)
  • Loading branch information
Jugst3r committed Sep 29, 2022
1 parent 56d00a5 commit b2569e9
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 58 deletions.
65 changes: 28 additions & 37 deletions tools/gnatcov/instrument-c__stub.adb
Original file line number Diff line number Diff line change
Expand Up @@ -21,61 +21,52 @@ package body Instrument.C is
Error_Msg : constant String :=
"GNATcoverage not built with C support.";

---------------------------
-- Add_Auto_Dump_Buffers --
---------------------------
----------------------
-- Skip_Source_File --
----------------------

procedure Add_Auto_Dump_Buffers
(IC : Inst_Context;
Info : in out Project_Info;
Main : Compilation_Unit_Name;
Rew : C_Source_Rewriter) is
begin
raise Program_Error with Error_Msg;
end Add_Auto_Dump_Buffers;
function Skip_Source_File
(Self : C_Family_Instrumenter_Type;
Source_File : GNATCOLL.Projects.File_Info) return Boolean
is (raise Program_Error with Error_Msg);

-----------
-- Apply --
-----------
---------------------
-- Instrument_Unit --
---------------------

procedure Apply (Self : in out C_Source_Rewriter) is
procedure Instrument_Unit
(Self : C_Family_Instrumenter_Type;
CU_Name : Compilation_Unit_Name;
IC : in out Inst_Context;
Unit_Info : in out Instrumented_Unit_Info) is
begin
raise Program_Error with Error_Msg;
end Apply;
end Instrument_Unit;

---------------------
-- Start_Rewriting --
---------------------
-------------------------------
-- Auto_Dump_Buffers_In_Main --
-------------------------------

procedure Start_Rewriting
(Self : out C_Source_Rewriter;
Info : in out Project_Info;
Input_Filename : String) is
procedure Auto_Dump_Buffers_In_Main
(Self : C_Family_Instrumenter_Type;
IC : in out Inst_Context;
Main : Compilation_Unit_Name;
Filename : String;
Info : in out Project_Info) is
begin
raise Program_Error with Error_Msg;
end Start_Rewriting;
end Auto_Dump_Buffers_In_Main;

----------------------------
-- Emit_Buffers_List_Unit --
----------------------------

procedure Emit_Buffers_List_Unit
(IC : in out Inst_Context;
(Self : C_Family_Instrumenter_Type;
IC : in out Inst_Context;
Root_Project_Info : in out Project_Info) is
begin
raise Program_Error with Error_Msg;
end Emit_Buffers_List_Unit;

---------------------
-- Instrument_Unit --
---------------------

procedure Instrument_Unit
(CU_Name : Compilation_Unit_Name;
IC : in out Inst_Context;
Unit_Info : in out Instrumented_Unit_Info) is
begin
raise Program_Error with Error_Msg;
end Instrument_Unit;

end Instrument.C;
61 changes: 40 additions & 21 deletions tools/gnatcov/instrument-c__stub.ads
Original file line number Diff line number Diff line change
Expand Up @@ -24,38 +24,57 @@
-- units, using the procedures defined here, which will result in a crash (all
-- the procedures are empty stubs raising an error).

with GNATCOLL.Projects; use GNATCOLL.Projects;

with Instrument.Base_Types; use Instrument.Base_Types;
with Instrument.Common; use Instrument.Common;
with Switches; use Switches;

private package Instrument.C is
type C_Source_Decision is null record;

type C_Source_Condition is null record;
type C_Family_Instrumenter_Type is
abstract new Language_Instrumenter with null record;
-- Common instrumentation primitives for C/C++

type C_Unit_Inst_Context is null record;
overriding function Skip_Source_File
(Self : C_Family_Instrumenter_Type;
Source_File : GNATCOLL.Projects.File_Info) return Boolean;

type C_Source_Rewriter is tagged limited null record;
overriding procedure Instrument_Unit
(Self : C_Family_Instrumenter_Type;
CU_Name : Compilation_Unit_Name;
IC : in out Inst_Context;
Unit_Info : in out Instrumented_Unit_Info);

procedure Add_Auto_Dump_Buffers
(IC : Inst_Context;
Info : in out Project_Info;
Main : Compilation_Unit_Name;
Rew : C_Source_Rewriter);
overriding procedure Auto_Dump_Buffers_In_Main
(Self : C_Family_Instrumenter_Type;
IC : in out Inst_Context;
Main : Compilation_Unit_Name;
Filename : String;
Info : in out Project_Info);

procedure Apply (Self : in out C_Source_Rewriter);
overriding procedure Emit_Buffers_List_Unit
(Self : C_Family_Instrumenter_Type;
IC : in out Inst_Context;
Root_Project_Info : in out Project_Info);

procedure Start_Rewriting
(Self : out C_Source_Rewriter;
Info : in out Project_Info;
Input_Filename : String);
type C_Instrumenter_Type is
new C_Family_Instrumenter_Type with null record;
-- Instrumentation primitives for C

procedure Emit_Buffers_List_Unit
(IC : in out Inst_Context;
Root_Project_Info : in out Project_Info);
overriding function Language
(Self : C_Instrumenter_Type) return Src_Supported_Language
is (C_Language);

procedure Instrument_Unit
(CU_Name : Compilation_Unit_Name;
IC : in out Inst_Context;
Unit_Info : in out Instrumented_Unit_Info);
type CPP_Instrumenter_Type is
new C_Family_Instrumenter_Type with null record;
-- Instrumentation primitives for C++

overriding function Language
(Self : CPP_Instrumenter_Type) return Src_Supported_Language
is (CPP_Language);

C_Instrumenter : aliased constant C_Instrumenter_Type := (null record);
CPP_Instrumenter : aliased constant CPP_Instrumenter_Type := (null record);

end Instrument.C;

0 comments on commit b2569e9

Please sign in to comment.