~ubuntu-branches/debian/lenny/fpc/lenny

« back to all changes in this revision

Viewing changes to compiler/gdb.pas

  • Committer: Bazaar Package Importer
  • Author(s): Mazen Neifer, Torsten Werner, Mazen Neifer
  • Date: 2008-05-17 17:12:11 UTC
  • mfrom: (3.1.9 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080517171211-9qi33xhd9evfa0kg
Tags: 2.2.0-dfsg1-9
[ Torsten Werner ]
* Add Mazen Neifer to Uploaders field.

[ Mazen Neifer ]
* Moved FPC sources into a version dependent directory from /usr/share/fpcsrc
  to /usr/share/fpcsrc/${FPCVERSION}. This allow installing more than on FPC
  release.
* Fixed far call issue in compiler preventing building huge binearies.
  (closes: #477743)
* Updated building dependencies, recomennded and suggested packages.
* Moved fppkg to fp-utils as it is just a helper tool and is not required by
  compiler.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
{
2
 
    $Id: gdb.pas,v 1.18 2004/03/08 22:07:46 peter Exp $
3
 
    Copyright (c) 1998-2002 by Florian Klaempfl
4
 
 
5
 
    This units contains special support for the GDB
6
 
 
7
 
    This program is free software; you can redistribute it and/or modify
8
 
    it under the terms of the GNU General Public License as published by
9
 
    the Free Software Foundation; either version 2 of the License, or
10
 
    (at your option) any later version.
11
 
 
12
 
    This program is distributed in the hope that it will be useful,
13
 
    but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 
    GNU General Public License for more details.
16
 
 
17
 
    You should have received a copy of the GNU General Public License
18
 
    along with this program; if not, write to the Free Software
19
 
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
 
 
21
 
 ****************************************************************************
22
 
}
23
 
unit gdb;
24
 
 
25
 
{$i fpcdefs.inc}
26
 
 
27
 
interface
28
 
 
29
 
uses
30
 
{$ifdef delphi}
31
 
  sysutils,
32
 
{$else}
33
 
  strings,
34
 
{$endif}
35
 
  globtype,
36
 
  aasmtai;
37
 
 
38
 
{stab constants }
39
 
Const
40
 
    N_GSYM = $20;
41
 
    N_STSYM = 38; {initialized const }
42
 
    N_LCSYM = 40; {non initialized variable}
43
 
    N_Function = $24; {function or const }
44
 
    N_TextLine = $44;
45
 
    N_DataLine = $46;
46
 
    N_BssLine = $48;
47
 
    N_RSYM = $40; { register variable }
48
 
    N_LSYM = $80;
49
 
    N_tsym = 160;
50
 
    N_SourceFile = $64;
51
 
    N_IncludeFile = $84;
52
 
    N_BINCL = $82;
53
 
    N_EINCL = $A2;
54
 
    N_EXCL  = $C2;
55
 
 
56
 
    type
57
 
       tai_stabs = class(tai)
58
 
          str : pchar;
59
 
          constructor Create(_str : pchar);
60
 
          destructor Destroy;override;
61
 
       end;
62
 
 
63
 
       tai_stabn = class(tai)
64
 
          str : pchar;
65
 
          constructor Create(_str : pchar);
66
 
          destructor Destroy;override;
67
 
       end;
68
 
 
69
 
       { insert a cut to split into several smaller files }
70
 
       tai_force_line = class(tailineinfo)
71
 
          constructor Create;
72
 
       end;
73
 
 
74
 
       tai_stab_function_name = class(tai)
75
 
          str : pchar;
76
 
          constructor create(_str : pchar);
77
 
          destructor destroy;override;
78
 
       end;
79
 
 
80
 
    const
81
 
       DBX_counter : plongint = nil;
82
 
       do_count_dbx : boolean = false;
83
 
 
84
 
 
85
 
  implementation
86
 
 
87
 
uses fmodule;
88
 
 
89
 
{ to use N_EXCL we have to count the character in the stabs for
90
 
N_BINCL to N_EINCL
91
 
  Code comes from stabs.c for ld
92
 
      if (type == N_BINCL)
93
 
    (
94
 
      bfd_vma val;
95
 
      int nest;
96
 
      bfd_byte *incl_sym;
97
 
      struct stab_link_includes_entry *incl_entry;
98
 
      struct stab_link_includes_totals *t;
99
 
      struct stab_excl_list *ne;
100
 
 
101
 
      val = 0;
102
 
      nest = 0;
103
 
      for (incl_sym = sym + STABSIZE;
104
 
           incl_sym < symend;
105
 
           incl_sym += STABSIZE)
106
 
        (
107
 
          int incl_type;
108
 
 
109
 
          incl_type = incl_sym[TYPEOFF];
110
 
          if (incl_type == 0)
111
 
        break;
112
 
          else if (incl_type == N_EINCL)
113
 
        (
114
 
          if (nest == 0)
115
 
            break;
116
 
          --nest;
117
 
        )
118
 
          else if (incl_type == N_BINCL)
119
 
        ++nest;
120
 
          else if (nest == 0)
121
 
        (
122
 
          const char *str;
123
 
 
124
 
          str = ((char *) stabstrbuf
125
 
             + stroff
126
 
             + bfd_get_32 (abfd, incl_sym + STRDXOFF));
127
 
          for (; *str != '\0'; str++)
128
 
            (
129
 
              val += *str;
130
 
              if *str == '('
131
 
            (
132
 
               Skip the file number.
133
 
              ++str;
134
 
              while (isdigit ((unsigned char) *str))
135
 
                ++str;
136
 
              --str;
137
 
            )
138
 
            )
139
 
        )
140
 
        ) }
141
 
 
142
 
 
143
 
   procedure count_dbx(st : pchar);
144
 
     var i : longint;
145
 
         do_count : boolean;
146
 
     begin
147
 
     do_count := false;
148
 
     if assigned(dbx_counter) then
149
 
       begin
150
 
{$IfDef ExtDebugDbx }
151
 
        Comment(V_Info,'Counting '+st);
152
 
        Comment(V_Info,'count =  '+tostr(dbx_counter^));
153
 
        Comment(V_Info,'addr = '+tostr(longint(dbx_counter)));
154
 
{$EndIf ExtDebugDbx }
155
 
          i:=0;
156
 
          while i<=strlen(st) do
157
 
            begin
158
 
               if st[i] = '"' then
159
 
                 if do_count then exit
160
 
                 else do_count := true
161
 
               else
162
 
               if do_count then
163
 
                 begin
164
 
                   dbx_counter^ := dbx_counter^+byte(st[i]);
165
 
                   { skip file number }
166
 
                   if st[i] = '(' then
167
 
                     begin
168
 
                        inc(i);
169
 
                        while st[i] in ['0'..'9'] do inc(i);
170
 
                        dec(i);
171
 
                     end;
172
 
                 end;
173
 
               inc(i);
174
 
            end;
175
 
       end;
176
 
     end;
177
 
 
178
 
 
179
 
    constructor tai_stabs.create(_str : pchar);
180
 
 
181
 
      begin
182
 
         inherited create;
183
 
         typ:=ait_stabs;
184
 
 
185
 
if current_module.modulename^='NCNV' then
186
 
  current_module:=current_module;
187
 
 
188
 
         str:=_str;
189
 
         if do_count_dbx then
190
 
           begin
191
 
              count_dbx(str);
192
 
           end;
193
 
      end;
194
 
 
195
 
    destructor tai_stabs.destroy;
196
 
 
197
 
      begin
198
 
         strdispose(str);
199
 
         inherited destroy;
200
 
      end;
201
 
 
202
 
    constructor tai_stabn.create(_str : pchar);
203
 
 
204
 
      begin
205
 
         inherited create;
206
 
         typ:=ait_stabn;
207
 
         str:=_str;
208
 
      end;
209
 
 
210
 
    destructor tai_stabn.destroy;
211
 
 
212
 
      begin
213
 
         strdispose(str);
214
 
         inherited destroy;
215
 
      end;
216
 
 
217
 
    constructor tai_force_line.create;
218
 
 
219
 
      begin
220
 
         inherited create;
221
 
         typ:=ait_force_line;
222
 
      end;
223
 
 
224
 
    constructor tai_stab_function_name.create(_str : pchar);
225
 
 
226
 
      begin
227
 
         inherited create;
228
 
         typ:=ait_stab_function_name;
229
 
         str:=_str;
230
 
      end;
231
 
 
232
 
    destructor tai_stab_function_name.destroy;
233
 
 
234
 
      begin
235
 
         strdispose(str);
236
 
         inherited destroy;
237
 
      end;
238
 
end.
239
 
 
240
 
{
241
 
  $Log: gdb.pas,v $
242
 
  Revision 1.18  2004/03/08 22:07:46  peter
243
 
    * stabs updates to write stabs for def for all implictly used
244
 
      units
245
 
 
246
 
  Revision 1.17  2003/10/22 15:22:33  peter
247
 
    * fixed unitsym-globalsymtable relation so the uses of a unit
248
 
      is counted correctly
249
 
 
250
 
  Revision 1.16  2002/11/17 16:31:56  carl
251
 
    * memory optimization (3-4%) : cleanup of tai fields,
252
 
       cleanup of tdef and tsym fields.
253
 
    * make it work for m68k
254
 
 
255
 
  Revision 1.15  2002/08/12 15:08:39  carl
256
 
    + stab register indexes for powerpc (moved from gdb to cpubase)
257
 
    + tprocessor enumeration moved to cpuinfo
258
 
    + linker in target_info is now a class
259
 
    * many many updates for m68k (will soon start to compile)
260
 
    - removed some ifdef or correct them for correct cpu
261
 
 
262
 
  Revision 1.14  2002/07/01 18:46:22  peter
263
 
    * internal linker
264
 
    * reorganized aasm layer
265
 
 
266
 
  Revision 1.13  2002/05/18 13:34:08  peter
267
 
    * readded missing revisions
268
 
 
269
 
  Revision 1.12  2002/05/16 19:46:36  carl
270
 
  + defines.inc -> fpcdefs.inc to avoid conflicts if compiling by hand
271
 
  + try to fix temp allocation (still in ifdef)
272
 
  + generic constructor calls
273
 
  + start of tassembler / tmodulebase class cleanup
274
 
 
275
 
  Revision 1.10  2002/05/06 19:49:26  carl
276
 
  + added more patches from Mazen for SPARC port
277
 
 
278
 
}