1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . T R A C E S . F O R M A T --
9 -- Copyright (C) 2001 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 2, or (at your option) any later ver- --
14 -- sion. GNARL 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 with System
.Parameters
;
36 package body System
.Traces
.Format
is
38 procedure Send_Trace
(Id
: Trace_T
; Info
: String) is separate;
44 function Format_Trace
(Source
: in String) return String_Trace
is
45 Length
: Integer := Source
'Length;
46 Result
: String_Trace
:= (others => ' ');
49 -- If run-time tracing active, then fill the string
51 if Parameters
.Runtime_Traces
then
52 if Max_Size
- Length
> 0 then
53 Result
(1 .. Length
) := Source
(1 .. Length
);
54 Result
(Length
+ 1 .. Max_Size
) := (others => ' ');
55 Result
(Length
+ 1) := ASCII
.NUL
;
57 Result
(1 .. Max_Size
- 1) := Source
(1 .. Max_Size
- 1);
58 Result
(Max_Size
) := ASCII
.NUL
;
70 (Source
: String_Trace
;
74 Result
: String_Trace
:= (others => ' ');
75 Source_Length
: Integer := 1;
76 Annex_Length
: Integer := Annex
'Length;
79 if Parameters
.Runtime_Traces
then
81 -- First we determine the size used, without the spaces at the
82 -- end, if a String_Trace is present. Look at
83 -- System.Traces.Tasking for examples.
85 while Source
(Source_Length
) /= ASCII
.NUL
loop
86 Source_Length
:= Source_Length
+ 1;
89 -- Then we fill the string.
91 if Source_Length
- 1 + Annex_Length
<= Max_Size
then
92 Result
(1 .. Source_Length
- 1) :=
93 Source
(1 .. Source_Length
- 1);
95 Result
(Source_Length
.. Source_Length
- 1 + Annex_Length
) :=
96 Annex
(1 .. Annex_Length
);
98 Result
(Source_Length
+ Annex_Length
) := ASCII
.NUL
;
100 Result
(Source_Length
+ Annex_Length
+ 1 .. Max_Size
) :=
103 Result
(1 .. Source_Length
- 1) := Source
(1 .. Source_Length
- 1);
104 Result
(Source_Length
.. Max_Size
- 1) :=
105 Annex
(1 .. Max_Size
- Source_Length
);
106 Result
(Max_Size
) := ASCII
.NUL
;
113 end System
.Traces
.Format
;