1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . T R A C E S . S E N D --
9 -- Copyright (C) 2001-2016, Free Software Foundation, Inc. --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This version is for all targets, provided that System.IO.Put_Line is
33 -- functional. It prints debug information to Standard Output
35 with System
.IO
; use System
.IO
;
36 with System
.Regpat
; use System
.Regpat
;
42 -- Prints debug information both in a human readable form
43 -- and in the form they are sent from upper layers.
45 separate (System
.Traces
.Format
)
46 procedure Send_Trace
(Id
: Trace_T
; Info
: String) is
56 -- Type of parameter found in the message
58 Info_Trace
: String_Trace
:= Format_Trace
(Info
);
61 (Input
: String_Trace
;
65 -- Extract a parameter from the given input string
72 (Input
: String_Trace
;
77 pragma Unreferenced
(How_Many
);
79 Matches
: Match_Array
(1 .. 2);
81 -- We need comments here ???
85 Match
("/N:([\w]+)", Input
, Matches
);
88 Match
("/C:([\w]+)", Input
, Matches
);
91 Match
("/E:([\s]*) +([0-9 ,]+)", Input
, Matches
);
94 Match
("/T:([\s]*) +([0-9]+.[0-9]+)", Input
, Matches
);
96 when Acceptor_Param
=>
97 Match
("/A:([\w]+)", Input
, Matches
);
100 Match
("/P:([\w]+)", Input
, Matches
);
103 Match
("/#:([\s]*) +([0-9]+)", Input
, Matches
);
106 if Matches
(1).First
< Input
'First then
115 return Input
(Matches
(2).First
.. Matches
(2).Last
);
118 return Input
(Matches
(1).First
.. Matches
(1).Last
);
122 -- Start of processing for Send_Trace
126 Put_Line
("- Trace Debug Info ----------------");
127 Put
("Caught event Id : ");
130 when M_Accept_Complete
=> Put
("M_Accept_Complete");
132 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
133 & " completes accept on entry "
134 & Get_Param
(Info_Trace
, Entry_Param
, 1) & " with "
135 & Get_Param
(Info_Trace
, Caller_Param
, 1));
137 when M_Select_Else
=> Put
("M_Select_Else");
139 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
140 & " selects else statement");
142 when M_RDV_Complete
=> Put
("M_RDV_Complete");
144 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
145 & " completes rendezvous with "
146 & Get_Param
(Info_Trace
, Caller_Param
, 1));
148 when M_Call_Complete
=> Put
("M_Call_Complete");
150 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
151 & " completes call");
153 when M_Delay
=> Put
("M_Delay");
155 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
156 & " completes delay "
157 & Get_Param
(Info_Trace
, Timeout_Param
, 1));
159 when E_Missed
=> Put
("E_Missed");
161 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
162 & " got an invalid acceptor "
163 & Get_Param
(Info_Trace
, Acceptor_Param
, 1));
165 when E_Timeout
=> Put
("E_Timeout");
167 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
168 & " ends select due to timeout ");
170 when E_Kill
=> Put
("E_Kill");
172 Put_Line
("Asynchronous Transfer of Control on task "
173 & Get_Param
(Info_Trace
, Name_Param
, 1));
175 when W_Delay
=> Put
("W_Delay");
177 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
179 & Get_Param
(Info_Trace
, Timeout_Param
, 1)
182 when WU_Delay
=> Put
("WU_Delay");
184 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
186 & Get_Param
(Info_Trace
, Timeout_Param
, 1));
188 when W_Call
=> Put
("W_Call");
190 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
192 & Get_Param
(Info_Trace
, Entry_Param
, 1)
193 & " of " & Get_Param
(Info_Trace
, Acceptor_Param
, 1));
195 when W_Accept
=> Put
("W_Accept");
197 Put
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
199 & Get_Param
(Info_Trace
, Number_Param
, 1)
201 & ", " & Get_Param
(Info_Trace
, Entry_Param
, 1));
204 when W_Select
=> Put
("W_Select");
206 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
208 & Get_Param
(Info_Trace
, Number_Param
, 1)
210 & ", " & Get_Param
(Info_Trace
, Entry_Param
, 1));
213 when W_Completion
=> Put
("W_Completion");
215 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
216 & " waiting for completion ");
218 when WT_Select
=> Put
("WT_Select");
220 Put
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
221 & " waiting " & Get_Param
(Info_Trace
, Timeout_Param
, 1)
223 & Get_Param
(Info_Trace
, Number_Param
, 1)
226 if Get_Param
(Info_Trace
, Number_Param
, 1) /= "" then
227 Put
(", " & Get_Param
(Info_Trace
, Entry_Param
, 1));
232 when WT_Call
=> Put
("WT_Call");
234 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
236 & Get_Param
(Info_Trace
, Entry_Param
, 1)
237 & " of " & Get_Param
(Info_Trace
, Acceptor_Param
, 1)
239 & Get_Param
(Info_Trace
, Timeout_Param
, 1));
241 when WT_Completion
=> Put
("WT_Completion");
243 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
245 & Get_Param
(Info_Trace
, Timeout_Param
, 1)
246 & " for call completion");
248 when PO_Call
=> Put
("PO_Call");
250 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
251 & " calling protected entry "
252 & Get_Param
(Info_Trace
, Entry_Param
, 1));
254 when POT_Call
=> Put
("POT_Call");
256 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
257 & " calling protected entry "
258 & Get_Param
(Info_Trace
, Entry_Param
, 1)
260 & Get_Param
(Info_Trace
, Timeout_Param
, 1));
262 when PO_Run
=> Put
("PO_Run");
264 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
266 & Get_Param
(Info_Trace
, Entry_Param
, 1)
268 & Get_Param
(Info_Trace
, Caller_Param
, 1));
270 when PO_Done
=> Put
("PO_Done");
272 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
273 & " finished call from "
274 & Get_Param
(Info_Trace
, Caller_Param
, 1));
276 when PO_Lock
=> Put
("PO_Lock");
278 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
281 when PO_Unlock
=> Put
("PO_Unlock");
283 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
286 when T_Create
=> Put
("T_Create");
288 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
291 when T_Activate
=> Put
("T_Activate");
293 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
296 when T_Abort
=> Put
("T_Abort");
298 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
300 & Get_Param
(Info_Trace
, Parent_Param
, 1));
302 when T_Terminate
=> Put
("T_Terminate");
304 Put_Line
("Task " & Get_Param
(Info_Trace
, Name_Param
, 1)
308 => Put
("Invalid Id");
311 Put_Line
(" --> " & Info_Trace
);
312 Put_Line
("-----------------------------------");