-
Notifications
You must be signed in to change notification settings - Fork 9
/
diagnostics.ads
138 lines (122 loc) · 5.28 KB
/
diagnostics.ads
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
------------------------------------------------------------------------------
-- --
-- GNATcoverage --
-- --
-- Copyright (C) 2009-2024, AdaCore --
-- --
-- GNATcoverage is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This software is distributed in the hope that it will be useful --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
-- This package is used for multiple kinds of reporting, and uses a somewhat
-- generic message structure to fill that purpose. It is used to:
--
-- * Display verbose messages
--
-- * Report warnings / errors during execution
--
-- * Report coverage analysis results (e.g. coverage violation messages)
--
-- Every message emitted that is attached to a line (i.e. for which a sloc is
-- reported, most notably: coverage violation messages) is stored into gnatcov
-- internal tables, and is (in most cases) not displayed by report procedures,
-- but rather included during coverage report production.
--
-- Other messages (most warnings, errors) are simply displayed on the standard
-- output at the time the report procedure is called.
with Ada.Containers.Vectors;
with Coverage; use Coverage;
with Logging;
with SC_Obligations; use SC_Obligations;
with Slocs; use Slocs;
with Strings; use Strings;
with Traces; use Traces;
with Traces_Elf; use Traces_Elf;
package Diagnostics is
Diagnostics_Trace : constant Logging.GNATCOLL_Trace :=
Logging.Create_Trace ("DIAGNOSTICS");
type Report_Kind is
(Notice,
Low_Warning,
Warning,
Error,
Info,
Violation,
Undetermined_Cov,
Exclusion);
subtype Coverage_Kind is Report_Kind range Info .. Exclusion;
type Message is record
Kind : Report_Kind;
Exe : Exe_File_Acc;
PC : Pc_Type;
Sloc : Source_Location;
Violation_Sloc : Source_Location;
SCO : SCO_Id;
Tag : SC_Tag;
Msg : Unbounded_String;
end record;
package Message_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural, Element_Type => Message);
procedure Report
(Exe : Exe_File_Acc;
PC : Pc_Type;
Msg : String;
SCO : SCO_Id := No_SCO_Id;
Kind : Report_Kind := Error);
procedure Report
(Sloc : Source_Location;
Msg : String;
Kind : Report_Kind := Error);
procedure Report_Coverage
(SCO : SCO_Id;
Tag : SC_Tag;
Msg : String;
Kind : Coverage_Kind);
-- Report coverage messages. Common processing for Report_Violation and
-- Report_Exclusion.
procedure Report_Violation
(SCO : SCO_Id;
Tag : SC_Tag;
Msg : String);
-- Report a violation of a source coverage obligation. Note: the SCO kind
-- will be prepended to Msg in reports, unless Msg starts with ^ (caret).
-- A violation message has message kind Violation.
procedure Report_Exclusion
(SCO : SCO_Id;
Tag : SC_Tag;
Msg : String);
-- Report exclusion of a SCO from coverage analysis. No coverage status
-- will be reported for SCO/Tag. Note: the SCO kind will be prepended to
-- Msg in reports, unless Msg starts with ^ (caret). A violation message
-- has message kind Exclusion.
procedure Report
(Msg : String;
Exe : Exe_File_Acc := null;
PC : Pc_Type := No_PC;
Sloc : Source_Location := No_Location;
Violation_Sloc : Source_Location := No_Location;
SCO : SCO_Id := No_SCO_Id;
Tag : SC_Tag := No_SC_Tag;
Kind : Report_Kind := Error);
-- Output diagnostic message during coverage analysis. Messages with Notice
-- kind are omitted unless global flag Verbose is set. A prefix is
-- prepended depending on message kind:
-- --- notice
-- *** warning
-- !!! error
-- .C. coverage info
-- !C! coverage violation
-- -C- coverage exclusion
-- The message is also recorded in the source line information for its sloc
-- or in the Detached_Messages vector, if there is no such source line
-- information. If SCO is not No_SCO_Id, the message denotes a violation
-- of the denoted Source Coverage Obligation.
function Image (M : Message) return String;
end Diagnostics;