1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
9 -- Copyright (C) 2002-2003, Free Software Foundation, Inc. --
11 -- GNAT 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. 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. 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 GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- GNAT was originally developed by the GNAT team at New York University. --
23 -- Extensive contributions were provided by Ada Core Technologies Inc. --
25 ------------------------------------------------------------------------------
27 with Osint
; use Osint
;
28 with Osint
.C
; use Osint
.C
;
30 package body Sinput
.D
is
32 Dfile
: Source_File_Index
;
33 -- Index of currently active debug source file
35 ------------------------
36 -- Close_Debug_Source --
37 ------------------------
39 procedure Close_Debug_Source
is
40 S
: Source_File_Record
renames Source_File
.Table
(Dfile
);
41 Src
: Source_Buffer_Ptr
;
44 Trim_Lines_Table
(Dfile
);
47 -- Now we need to read the file that we wrote and store it
48 -- in memory for subsequent access.
51 (S
.Full_Debug_Name
, S
.Source_First
, S
.Source_Last
, Src
);
53 Set_Source_File_Index_Table
(Dfile
);
54 end Close_Debug_Source
;
56 -------------------------
57 -- Create_Debug_Source --
58 -------------------------
60 procedure Create_Debug_Source
61 (Source
: Source_File_Index
;
65 Loc
:= Source_File
.Table
(Source_File
.Last
).Source_Last
+ 1;
66 Source_File
.Increment_Last
;
67 Dfile
:= Source_File
.Last
;
70 S
: Source_File_Record
renames Source_File
.Table
(Dfile
);
73 S
:= Source_File
.Table
(Source
);
74 S
.Full_Debug_Name
:= Create_Debug_File
(S
.File_Name
);
75 S
.Debug_Source_Name
:= Strip_Directory
(S
.Full_Debug_Name
);
76 S
.Source_First
:= Loc
;
78 S
.Lines_Table
:= null;
79 S
.Last_Source_Line
:= 1;
81 -- Allocate lines table, guess that it needs to be three times
82 -- bigger than the original source (in number of lines).
85 (S
, Int
(Source_File
.Table
(Source
).Last_Source_Line
* 3));
86 S
.Lines_Table
(1) := Loc
;
88 end Create_Debug_Source
;
90 ----------------------
91 -- Write_Debug_Line --
92 ----------------------
94 procedure Write_Debug_Line
(Str
: String; Loc
: in out Source_Ptr
) is
95 S
: Source_File_Record
renames Source_File
.Table
(Dfile
);
98 -- Ignore write request if null line at start of file
100 if Str
'Length = 0 and then Loc
= S
.Source_First
then
103 -- Here we write the line, compute the source location for the
104 -- following line, allocate its table entry, and update the source
108 Write_Debug_Info
(Str
(Str
'First .. Str
'Last - 1));
109 Loc
:= Loc
- 1 + Source_Ptr
(Str
'Length + Debug_File_Eol_Length
);
110 Add_Line_Tables_Entry
(S
, Loc
);
111 S
.Source_Last
:= Loc
;
113 end Write_Debug_Line
;