OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [insight/] [gdb/] [doc/] [stabs.info-2] - Blame information for rev 1767

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 578 markom
This is stabs.info, produced by makeinfo version 4.0 from
2
./stabs.texinfo.
3
 
4
START-INFO-DIR-ENTRY
5
* Stabs: (stabs).                 The "stabs" debugging information format.
6
END-INFO-DIR-ENTRY
7
 
8
   This document describes the stabs debugging symbol tables.
9
 
10
   Copyright 1992,1993,1994,1995,1997,1998,2000,2001    Free Software
11
Foundation, Inc.  Contributed by Cygnus Support.  Written by Julia
12
Menapace, Jim Kingdon, and David MacKenzie.
13
 
14
   Permission is granted to copy, distribute and/or modify this document
15
under the terms of the GNU Free Documentation License, Version 1.1 or
16
any later version published by the Free Software Foundation; with the
17
Invariant Sections being "Stabs Types" and "Stabs Sections", with the
18
Front-Cover texts being "A GNU Manual," and with the Back-Cover Texts
19
as in (a) below.
20
 
21
   (a) The FSF's Back-Cover Text is: "You have freedom to copy and
22
modify this GNU Manual, like GNU software.  Copies published by the Free
23
Software Foundation raise funds for GNU development."
24
 
25

26
File: stabs.info,  Node: Conformant Arrays,  Prev: Reference Parameters,  Up: Parameters
27
 
28
Passing Conformant Array Parameters
29
-----------------------------------
30
 
31
   Conformant arrays are a feature of Modula-2, and perhaps other
32
languages, in which the size of an array parameter is not known to the
33
called function until run-time.  Such parameters have two stabs: a `x'
34
for the array itself, and a `C', which represents the size of the
35
array.  The value of the `x' stab is the offset in the argument list
36
where the address of the array is stored (it this right?  it is a
37
guess); the value of the `C' stab is the offset in the argument list
38
where the size of the array (in elements? in bytes?) is stored.
39
 
40

41
File: stabs.info,  Node: Types,  Next: Symbol Tables,  Prev: Variables,  Up: Top
42
 
43
Defining Types
44
**************
45
 
46
   The examples so far have described types as references to previously
47
defined types, or defined in terms of subranges of or pointers to
48
previously defined types.  This chapter describes the other type
49
descriptors that may follow the `=' in a type definition.
50
 
51
* Menu:
52
 
53
* Builtin Types::               Integers, floating point, void, etc.
54
* Miscellaneous Types::         Pointers, sets, files, etc.
55
* Cross-References::            Referring to a type not yet defined.
56
* Subranges::                   A type with a specific range.
57
* Arrays::                      An aggregate type of same-typed elements.
58
* Strings::                     Like an array but also has a length.
59
* Enumerations::                Like an integer but the values have names.
60
* Structures::                  An aggregate type of different-typed elements.
61
* Typedefs::                    Giving a type a name.
62
* Unions::                      Different types sharing storage.
63
* Function Types::
64
 
65

66
File: stabs.info,  Node: Builtin Types,  Next: Miscellaneous Types,  Up: Types
67
 
68
Builtin Types
69
=============
70
 
71
   Certain types are built in (`int', `short', `void', `float', etc.);
72
the debugger recognizes these types and knows how to handle them.
73
Thus, don't be surprised if some of the following ways of specifying
74
builtin types do not specify everything that a debugger would need to
75
know about the type--in some cases they merely specify enough
76
information to distinguish the type from other types.
77
 
78
   The traditional way to define builtin types is convoluted, so new
79
ways have been invented to describe them.  Sun's `acc' uses special
80
builtin type descriptors (`b' and `R'), and IBM uses negative type
81
numbers.  GDB accepts all three ways, as of version 4.8; dbx just
82
accepts the traditional builtin types and perhaps one of the other two
83
formats.  The following sections describe each of these formats.
84
 
85
* Menu:
86
 
87
* Traditional Builtin Types::   Put on your seat belts and prepare for kludgery
88
* Builtin Type Descriptors::    Builtin types with special type descriptors
89
* Negative Type Numbers::       Builtin types using negative type numbers
90
 
91

92
File: stabs.info,  Node: Traditional Builtin Types,  Next: Builtin Type Descriptors,  Up: Builtin Types
93
 
94
Traditional Builtin Types
95
-------------------------
96
 
97
   This is the traditional, convoluted method for defining builtin
98
types.  There are several classes of such type definitions: integer,
99
floating point, and `void'.
100
 
101
* Menu:
102
 
103
* Traditional Integer Types::
104
* Traditional Other Types::
105
 
106

107
File: stabs.info,  Node: Traditional Integer Types,  Next: Traditional Other Types,  Up: Traditional Builtin Types
108
 
109
Traditional Integer Types
110
.........................
111
 
112
   Often types are defined as subranges of themselves.  If the bounding
113
values fit within an `int', then they are given normally.  For example:
114
 
115
     .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0    # 128 is N_LSYM
116
     .stabs "char:t2=r2;0;127;",128,0,0,0
117
 
118
   Builtin types can also be described as subranges of `int':
119
 
120
     .stabs "unsigned short:t6=r1;0;65535;",128,0,0,0
121
 
122
   If the lower bound of a subrange is 0 and the upper bound is -1, the
123
type is an unsigned integral type whose bounds are too big to describe
124
in an `int'.  Traditionally this is only used for `unsigned int' and
125
`unsigned long':
126
 
127
     .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
128
 
129
   For larger types, GCC 2.4.5 puts out bounds in octal, with one or
130
more leading zeroes.  In this case a negative bound consists of a number
131
which is a 1 bit (for the sign bit) followed by a 0 bit for each bit in
132
the number (except the sign bit), and a positive bound is one which is a
133
1 bit for each bit in the number (except possibly the sign bit).  All
134
known versions of dbx and GDB version 4 accept this (at least in the
135
sense of not refusing to process the file), but GDB 3.5 refuses to read
136
the whole file containing such symbols.  So GCC 2.3.3 did not output the
137
proper size for these types.  As an example of octal bounds, the string
138
fields of the stabs for 64 bit integer types look like:
139
 
140
     long int:t3=r1;001000000000000000000000;000777777777777777777777;
141
     long unsigned int:t5=r1;000000000000000000000000;001777777777777777777777;
142
 
143
   If the lower bound of a subrange is 0 and the upper bound is
144
negative, the type is an unsigned integral type whose size in bytes is
145
the absolute value of the upper bound.  I believe this is a Convex
146
convention for `unsigned long long'.
147
 
148
   If the lower bound of a subrange is negative and the upper bound is
149
0, the type is a signed integral type whose size in bytes is the
150
absolute value of the lower bound.  I believe this is a Convex
151
convention for `long long'.  To distinguish this from a legitimate
152
subrange, the type should be a subrange of itself.  I'm not sure whether
153
this is the case for Convex.
154
 
155

156
File: stabs.info,  Node: Traditional Other Types,  Prev: Traditional Integer Types,  Up: Traditional Builtin Types
157
 
158
Traditional Other Types
159
.......................
160
 
161
   If the upper bound of a subrange is 0 and the lower bound is
162
positive, the type is a floating point type, and the lower bound of the
163
subrange indicates the number of bytes in the type:
164
 
165
     .stabs "float:t12=r1;4;0;",128,0,0,0
166
     .stabs "double:t13=r1;8;0;",128,0,0,0
167
 
168
   However, GCC writes `long double' the same way it writes `double',
169
so there is no way to distinguish.
170
 
171
     .stabs "long double:t14=r1;8;0;",128,0,0,0
172
 
173
   Complex types are defined the same way as floating-point types;
174
there is no way to distinguish a single-precision complex from a
175
double-precision floating-point type.
176
 
177
   The C `void' type is defined as itself:
178
 
179
     .stabs "void:t15=15",128,0,0,0
180
 
181
   I'm not sure how a boolean type is represented.
182
 
183

184
File: stabs.info,  Node: Builtin Type Descriptors,  Next: Negative Type Numbers,  Prev: Traditional Builtin Types,  Up: Builtin Types
185
 
186
Defining Builtin Types Using Builtin Type Descriptors
187
-----------------------------------------------------
188
 
189
   This is the method used by Sun's `acc' for defining builtin types.
190
These are the type descriptors to define builtin types:
191
 
192
`b SIGNED CHAR-FLAG WIDTH ; OFFSET ; NBITS ;'
193
     Define an integral type.  SIGNED is `u' for unsigned or `s' for
194
     signed.  CHAR-FLAG is `c' which indicates this is a character
195
     type, or is omitted.  I assume this is to distinguish an integral
196
     type from a character type of the same size, for example it might
197
     make sense to set it for the C type `wchar_t' so the debugger can
198
     print such variables differently (Solaris does not do this).  Sun
199
     sets it on the C types `signed char' and `unsigned char' which
200
     arguably is wrong.  WIDTH and OFFSET appear to be for small
201
     objects stored in larger ones, for example a `short' in an `int'
202
     register.  WIDTH is normally the number of bytes in the type.
203
     OFFSET seems to always be zero.  NBITS is the number of bits in
204
     the type.
205
 
206
     Note that type descriptor `b' used for builtin types conflicts with
207
     its use for Pascal space types (*note Miscellaneous Types::); they
208
     can be distinguished because the character following the type
209
     descriptor will be a digit, `(', or `-' for a Pascal space type, or
210
     `u' or `s' for a builtin type.
211
 
212
`w'
213
     Documented by AIX to define a wide character type, but their
214
     compiler actually uses negative type numbers (*note Negative Type
215
     Numbers::).
216
 
217
`R FP-TYPE ; BYTES ;'
218
     Define a floating point type.  FP-TYPE has one of the following
219
     values:
220
 
221
    `1 (NF_SINGLE)'
222
          IEEE 32-bit (single precision) floating point format.
223
 
224
    `2 (NF_DOUBLE)'
225
          IEEE 64-bit (double precision) floating point format.
226
 
227
    `3 (NF_COMPLEX)'
228
 
229
    `4 (NF_COMPLEX16)'
230
 
231
    `5 (NF_COMPLEX32)'
232
          These are for complex numbers.  A comment in the GDB source
233
          describes them as Fortran `complex', `double complex', and
234
          `complex*16', respectively, but what does that mean?  (i.e.,
235
          Single precision?  Double precision?).
236
 
237
    `6 (NF_LDOUBLE)'
238
          Long double.  This should probably only be used for Sun format
239
          `long double', and new codes should be used for other floating
240
          point formats (`NF_DOUBLE' can be used if a `long double' is
241
          really just an IEEE double, of course).
242
 
243
     BYTES is the number of bytes occupied by the type.  This allows a
244
     debugger to perform some operations with the type even if it
245
     doesn't understand FP-TYPE.
246
 
247
`g TYPE-INFORMATION ; NBITS'
248
     Documented by AIX to define a floating type, but their compiler
249
     actually uses negative type numbers (*note Negative Type
250
     Numbers::).
251
 
252
`c TYPE-INFORMATION ; NBITS'
253
     Documented by AIX to define a complex type, but their compiler
254
     actually uses negative type numbers (*note Negative Type
255
     Numbers::).
256
 
257
   The C `void' type is defined as a signed integral type 0 bits long:
258
     .stabs "void:t19=bs0;0;0",128,0,0,0
259
   The Solaris compiler seems to omit the trailing semicolon in this
260
case.  Getting sloppy in this way is not a swift move because if a type
261
is embedded in a more complex expression it is necessary to be able to
262
tell where it ends.
263
 
264
   I'm not sure how a boolean type is represented.
265
 
266

267
File: stabs.info,  Node: Negative Type Numbers,  Prev: Builtin Type Descriptors,  Up: Builtin Types
268
 
269
Negative Type Numbers
270
---------------------
271
 
272
   This is the method used in XCOFF for defining builtin types.  Since
273
the debugger knows about the builtin types anyway, the idea of negative
274
type numbers is simply to give a special type number which indicates
275
the builtin type.  There is no stab defining these types.
276
 
277
   There are several subtle issues with negative type numbers.
278
 
279
   One is the size of the type.  A builtin type (for example the C types
280
`int' or `long') might have different sizes depending on compiler
281
options, the target architecture, the ABI, etc.  This issue doesn't
282
come up for IBM tools since (so far) they just target the RS/6000; the
283
sizes indicated below for each size are what the IBM RS/6000 tools use.
284
To deal with differing sizes, either define separate negative type
285
numbers for each size (which works but requires changing the debugger,
286
and, unless you get both AIX dbx and GDB to accept the change,
287
introduces an incompatibility), or use a type attribute (*note String
288
Field::) to define a new type with the appropriate size (which merely
289
requires a debugger which understands type attributes, like AIX dbx or
290
GDB).  For example,
291
 
292
     .stabs "boolean:t10=@s8;-16",128,0,0,0
293
 
294
   defines an 8-bit boolean type, and
295
 
296
     .stabs "boolean:t10=@s64;-16",128,0,0,0
297
 
298
   defines a 64-bit boolean type.
299
 
300
   A similar issue is the format of the type.  This comes up most often
301
for floating-point types, which could have various formats (particularly
302
extended doubles, which vary quite a bit even among IEEE systems).
303
Again, it is best to define a new negative type number for each
304
different format; changing the format based on the target system has
305
various problems.  One such problem is that the Alpha has both VAX and
306
IEEE floating types.  One can easily imagine one library using the VAX
307
types and another library in the same executable using the IEEE types.
308
Another example is that the interpretation of whether a boolean is true
309
or false can be based on the least significant bit, most significant
310
bit, whether it is zero, etc., and different compilers (or different
311
options to the same compiler) might provide different kinds of boolean.
312
 
313
   The last major issue is the names of the types.  The name of a given
314
type depends _only_ on the negative type number given; these do not
315
vary depending on the language, the target system, or anything else.
316
One can always define separate type numbers--in the following list you
317
will see for example separate `int' and `integer*4' types which are
318
identical except for the name.  But compatibility can be maintained by
319
not inventing new negative type numbers and instead just defining a new
320
type with a new name.  For example:
321
 
322
     .stabs "CARDINAL:t10=-8",128,0,0,0
323
 
324
   Here is the list of negative type numbers.  The phrase "integral
325
type" is used to mean twos-complement (I strongly suspect that all
326
machines which use stabs use twos-complement; most machines use
327
twos-complement these days).
328
 
329
`-1'
330
     `int', 32 bit signed integral type.
331
 
332
`-2'
333
     `char', 8 bit type holding a character.   Both GDB and dbx on AIX
334
     treat this as signed.  GCC uses this type whether `char' is signed
335
     or not, which seems like a bad idea.  The AIX compiler (`xlc')
336
     seems to avoid this type; it uses -5 instead for `char'.
337
 
338
`-3'
339
     `short', 16 bit signed integral type.
340
 
341
`-4'
342
     `long', 32 bit signed integral type.
343
 
344
`-5'
345
     `unsigned char', 8 bit unsigned integral type.
346
 
347
`-6'
348
     `signed char', 8 bit signed integral type.
349
 
350
`-7'
351
     `unsigned short', 16 bit unsigned integral type.
352
 
353
`-8'
354
     `unsigned int', 32 bit unsigned integral type.
355
 
356
`-9'
357
     `unsigned', 32 bit unsigned integral type.
358
 
359
`-10'
360
     `unsigned long', 32 bit unsigned integral type.
361
 
362
`-11'
363
     `void', type indicating the lack of a value.
364
 
365
`-12'
366
     `float', IEEE single precision.
367
 
368
`-13'
369
     `double', IEEE double precision.
370
 
371
`-14'
372
     `long double', IEEE double precision.  The compiler claims the size
373
     will increase in a future release, and for binary compatibility
374
     you have to avoid using `long double'.  I hope when they increase
375
     it they use a new negative type number.
376
 
377
`-15'
378
     `integer'.  32 bit signed integral type.
379
 
380
`-16'
381
     `boolean'.  32 bit type.  GDB and GCC assume that zero is false,
382
     one is true, and other values have unspecified meaning.  I hope
383
     this agrees with how the IBM tools use the type.
384
 
385
`-17'
386
     `short real'.  IEEE single precision.
387
 
388
`-18'
389
     `real'.  IEEE double precision.
390
 
391
`-19'
392
     `stringptr'.  *Note Strings::.
393
 
394
`-20'
395
     `character', 8 bit unsigned character type.
396
 
397
`-21'
398
     `logical*1', 8 bit type.  This Fortran type has a split
399
     personality in that it is used for boolean variables, but can also
400
     be used for unsigned integers.  0 is false, 1 is true, and other
401
     values are non-boolean.
402
 
403
`-22'
404
     `logical*2', 16 bit type.  This Fortran type has a split
405
     personality in that it is used for boolean variables, but can also
406
     be used for unsigned integers.  0 is false, 1 is true, and other
407
     values are non-boolean.
408
 
409
`-23'
410
     `logical*4', 32 bit type.  This Fortran type has a split
411
     personality in that it is used for boolean variables, but can also
412
     be used for unsigned integers.  0 is false, 1 is true, and other
413
     values are non-boolean.
414
 
415
`-24'
416
     `logical', 32 bit type.  This Fortran type has a split personality
417
     in that it is used for boolean variables, but can also be used for
418
     unsigned integers.  0 is false, 1 is true, and other values are
419
     non-boolean.
420
 
421
`-25'
422
     `complex'.  A complex type consisting of two IEEE single-precision
423
     floating point values.
424
 
425
`-26'
426
     `complex'.  A complex type consisting of two IEEE double-precision
427
     floating point values.
428
 
429
`-27'
430
     `integer*1', 8 bit signed integral type.
431
 
432
`-28'
433
     `integer*2', 16 bit signed integral type.
434
 
435
`-29'
436
     `integer*4', 32 bit signed integral type.
437
 
438
`-30'
439
     `wchar'.  Wide character, 16 bits wide, unsigned (what format?
440
     Unicode?).
441
 
442
`-31'
443
     `long long', 64 bit signed integral type.
444
 
445
`-32'
446
     `unsigned long long', 64 bit unsigned integral type.
447
 
448
`-33'
449
     `logical*8', 64 bit unsigned integral type.
450
 
451
`-34'
452
     `integer*8', 64 bit signed integral type.
453
 
454

455
File: stabs.info,  Node: Miscellaneous Types,  Next: Cross-References,  Prev: Builtin Types,  Up: Types
456
 
457
Miscellaneous Types
458
===================
459
 
460
`b TYPE-INFORMATION ; BYTES'
461
     Pascal space type.  This is documented by IBM; what does it mean?
462
 
463
     This use of the `b' type descriptor can be distinguished from its
464
     use for builtin integral types (*note Builtin Type Descriptors::)
465
     because the character following the type descriptor is always a
466
     digit, `(', or `-'.
467
 
468
`B TYPE-INFORMATION'
469
     A volatile-qualified version of TYPE-INFORMATION.  This is a Sun
470
     extension.  References and stores to a variable with a
471
     volatile-qualified type must not be optimized or cached; they must
472
     occur as the user specifies them.
473
 
474
`d TYPE-INFORMATION'
475
     File of type TYPE-INFORMATION.  As far as I know this is only used
476
     by Pascal.
477
 
478
`k TYPE-INFORMATION'
479
     A const-qualified version of TYPE-INFORMATION.  This is a Sun
480
     extension.  A variable with a const-qualified type cannot be
481
     modified.
482
 
483
`M TYPE-INFORMATION ; LENGTH'
484
     Multiple instance type.  The type seems to composed of LENGTH
485
     repetitions of TYPE-INFORMATION, for example `character*3' is
486
     represented by `M-2;3', where `-2' is a reference to a character
487
     type (*note Negative Type Numbers::).  I'm not sure how this
488
     differs from an array.  This appears to be a Fortran feature.
489
     LENGTH is a bound, like those in range types; see *Note
490
     Subranges::.
491
 
492
`S TYPE-INFORMATION'
493
     Pascal set type.  TYPE-INFORMATION must be a small type such as an
494
     enumeration or a subrange, and the type is a bitmask whose length
495
     is specified by the number of elements in TYPE-INFORMATION.
496
 
497
     In CHILL, if it is a bitstring instead of a set, also use the `S'
498
     type attribute (*note String Field::).
499
 
500
`* TYPE-INFORMATION'
501
     Pointer to TYPE-INFORMATION.
502
 
503

504
File: stabs.info,  Node: Cross-References,  Next: Subranges,  Prev: Miscellaneous Types,  Up: Types
505
 
506
Cross-References to Other Types
507
===============================
508
 
509
   A type can be used before it is defined; one common way to deal with
510
that situation is just to use a type reference to a type which has not
511
yet been defined.
512
 
513
   Another way is with the `x' type descriptor, which is followed by
514
`s' for a structure tag, `u' for a union tag, or `e' for a enumerator
515
tag, followed by the name of the tag, followed by `:'.  If the name
516
contains `::' between a `<' and `>' pair (for C++ templates), such a
517
`::' does not end the name--only a single `:' ends the name; see *Note
518
Nested Symbols::.
519
 
520
   For example, the following C declarations:
521
 
522
     struct foo;
523
     struct foo *bar;
524
 
525
produce:
526
 
527
     .stabs "bar:G16=*17=xsfoo:",32,0,0,0
528
 
529
   Not all debuggers support the `x' type descriptor, so on some
530
machines GCC does not use it.  I believe that for the above example it
531
would just emit a reference to type 17 and never define it, but I
532
haven't verified that.
533
 
534
   Modula-2 imported types, at least on AIX, use the `i' type
535
descriptor, which is followed by the name of the module from which the
536
type is imported, followed by `:', followed by the name of the type.
537
There is then optionally a comma followed by type information for the
538
type.  This differs from merely naming the type (*note Typedefs::) in
539
that it identifies the module; I don't understand whether the name of
540
the type given here is always just the same as the name we are giving
541
it, or whether this type descriptor is used with a nameless stab (*note
542
String Field::), or what.  The symbol ends with `;'.
543
 
544

545
File: stabs.info,  Node: Subranges,  Next: Arrays,  Prev: Cross-References,  Up: Types
546
 
547
Subrange Types
548
==============
549
 
550
   The `r' type descriptor defines a type as a subrange of another
551
type.  It is followed by type information for the type of which it is a
552
subrange, a semicolon, an integral lower bound, a semicolon, an
553
integral upper bound, and a semicolon.  The AIX documentation does not
554
specify the trailing semicolon, in an effort to specify array indexes
555
more cleanly, but a subrange which is not an array index has always
556
included a trailing semicolon (*note Arrays::).
557
 
558
   Instead of an integer, either bound can be one of the following:
559
 
560
`A OFFSET'
561
     The bound is passed by reference on the stack at offset OFFSET
562
     from the argument list.  *Note Parameters::, for more information
563
     on such offsets.
564
 
565
`T OFFSET'
566
     The bound is passed by value on the stack at offset OFFSET from
567
     the argument list.
568
 
569
`a REGISTER-NUMBER'
570
     The bound is passed by reference in register number
571
     REGISTER-NUMBER.
572
 
573
`t REGISTER-NUMBER'
574
     The bound is passed by value in register number REGISTER-NUMBER.
575
 
576
`J'
577
     There is no bound.
578
 
579
   Subranges are also used for builtin types; see *Note Traditional
580
Builtin Types::.
581
 
582

583
File: stabs.info,  Node: Arrays,  Next: Strings,  Prev: Subranges,  Up: Types
584
 
585
Array Types
586
===========
587
 
588
   Arrays use the `a' type descriptor.  Following the type descriptor
589
is the type of the index and the type of the array elements.  If the
590
index type is a range type, it ends in a semicolon; otherwise (for
591
example, if it is a type reference), there does not appear to be any
592
way to tell where the types are separated.  In an effort to clean up
593
this mess, IBM documents the two types as being separated by a
594
semicolon, and a range type as not ending in a semicolon (but this is
595
not right for range types which are not array indexes, *note
596
Subranges::).  I think probably the best solution is to specify that a
597
semicolon ends a range type, and that the index type and element type
598
of an array are separated by a semicolon, but that if the index type is
599
a range type, the extra semicolon can be omitted.  GDB (at least
600
through version 4.9) doesn't support any kind of index type other than a
601
range anyway; I'm not sure about dbx.
602
 
603
   It is well established, and widely used, that the type of the index,
604
unlike most types found in the stabs, is merely a type definition, not
605
type information (*note String Field::) (that is, it need not start with
606
`TYPE-NUMBER=' if it is defining a new type).  According to a comment
607
in GDB, this is also true of the type of the array elements; it gives
608
`ar1;1;10;ar1;1;10;4' as a legitimate way to express a two dimensional
609
array.  According to AIX documentation, the element type must be type
610
information.  GDB accepts either.
611
 
612
   The type of the index is often a range type, expressed as the type
613
descriptor `r' and some parameters.  It defines the size of the array.
614
In the example below, the range `r1;0;2;' defines an index type which
615
is a subrange of type 1 (integer), with a lower bound of 0 and an upper
616
bound of 2.  This defines the valid range of subscripts of a
617
three-element C array.
618
 
619
   For example, the definition:
620
 
621
     char char_vec[3] = {'a','b','c'};
622
 
623
produces the output:
624
 
625
     .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
626
          .global _char_vec
627
          .align 4
628
     _char_vec:
629
          .byte 97
630
          .byte 98
631
          .byte 99
632
 
633
   If an array is "packed", the elements are spaced more closely than
634
normal, saving memory at the expense of speed.  For example, an array
635
of 3-byte objects might, if unpacked, have each element aligned on a
636
4-byte boundary, but if packed, have no padding.  One way to specify
637
that something is packed is with type attributes (*note String
638
Field::).  In the case of arrays, another is to use the `P' type
639
descriptor instead of `a'.  Other than specifying a packed array, `P'
640
is identical to `a'.
641
 
642
   An open array is represented by the `A' type descriptor followed by
643
type information specifying the type of the array elements.
644
 
645
   An N-dimensional dynamic array is represented by
646
 
647
     D DIMENSIONS ; TYPE-INFORMATION
648
 
649
   DIMENSIONS is the number of dimensions; TYPE-INFORMATION specifies
650
the type of the array elements.
651
 
652
   A subarray of an N-dimensional array is represented by
653
 
654
     E DIMENSIONS ; TYPE-INFORMATION
655
 
656
   DIMENSIONS is the number of dimensions; TYPE-INFORMATION specifies
657
the type of the array elements.
658
 
659

660
File: stabs.info,  Node: Strings,  Next: Enumerations,  Prev: Arrays,  Up: Types
661
 
662
Strings
663
=======
664
 
665
   Some languages, like C or the original Pascal, do not have string
666
types, they just have related things like arrays of characters.  But
667
most Pascals and various other languages have string types, which are
668
indicated as follows:
669
 
670
`n TYPE-INFORMATION ; BYTES'
671
     BYTES is the maximum length.  I'm not sure what TYPE-INFORMATION
672
     is; I suspect that it means that this is a string of
673
     TYPE-INFORMATION (thus allowing a string of integers, a string of
674
     wide characters, etc., as well as a string of characters).  Not
675
     sure what the format of this type is.  This is an AIX feature.
676
 
677
`z TYPE-INFORMATION ; BYTES'
678
     Just like `n' except that this is a gstring, not an ordinary
679
     string.  I don't know the difference.
680
 
681
`N'
682
     Pascal Stringptr.  What is this?  This is an AIX feature.
683
 
684
   Languages, such as CHILL which have a string type which is basically
685
just an array of characters use the `S' type attribute (*note String
686
Field::).
687
 
688

689
File: stabs.info,  Node: Enumerations,  Next: Structures,  Prev: Strings,  Up: Types
690
 
691
Enumerations
692
============
693
 
694
   Enumerations are defined with the `e' type descriptor.
695
 
696
   The source line below declares an enumeration type at file scope.
697
The type definition is located after the `N_RBRAC' that marks the end of
698
the previous procedure's block scope, and before the `N_FUN' that marks
699
the beginning of the next procedure's block scope.  Therefore it does
700
not describe a block local symbol, but a file local one.
701
 
702
   The source line:
703
 
704
     enum e_places {first,second=3,last};
705
 
706
generates the following stab:
707
 
708
     .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0
709
 
710
   The symbol descriptor (`T') says that the stab describes a
711
structure, enumeration, or union tag.  The type descriptor `e',
712
following the `22=' of the type definition narrows it down to an
713
enumeration type.  Following the `e' is a list of the elements of the
714
enumeration.  The format is `NAME:VALUE,'.  The list of elements ends
715
with `;'.  The fact that VALUE is specified as an integer can cause
716
problems if the value is large.  GCC 2.5.2 tries to output it in octal
717
in that case with a leading zero, which is probably a good thing,
718
although GDB 4.11 supports octal only in cases where decimal is
719
perfectly good.  Negative decimal values are supported by both GDB and
720
dbx.
721
 
722
   There is no standard way to specify the size of an enumeration type;
723
it is determined by the architecture (normally all enumerations types
724
are 32 bits).  Type attributes can be used to specify an enumeration
725
type of another size for debuggers which support them; see *Note String
726
Field::.
727
 
728
   Enumeration types are unusual in that they define symbols for the
729
enumeration values (`first', `second', and `third' in the above
730
example), and even though these symbols are visible in the file as a
731
whole (rather than being in a more local namespace like structure
732
member names), they are defined in the type definition for the
733
enumeration type rather than each having their own symbol.  In order to
734
be fast, GDB will only get symbols from such types (in its initial scan
735
of the stabs) if the type is the first thing defined after a `T' or `t'
736
symbol descriptor (the above example fulfills this requirement).  If
737
the type does not have a name, the compiler should emit it in a
738
nameless stab (*note String Field::); GCC does this.
739
 
740

741
File: stabs.info,  Node: Structures,  Next: Typedefs,  Prev: Enumerations,  Up: Types
742
 
743
Structures
744
==========
745
 
746
   The encoding of structures in stabs can be shown with an example.
747
 
748
   The following source code declares a structure tag and defines an
749
instance of the structure in global scope. Then a `typedef' equates the
750
structure tag with a new type.  Separate stabs are generated for the
751
structure tag, the structure `typedef', and the structure instance.  The
752
stabs for the tag and the `typedef' are emitted when the definitions are
753
encountered.  Since the structure elements are not initialized, the
754
stab and code for the structure variable itself is located at the end
755
of the program in the bss section.
756
 
757
     struct s_tag {
758
       int   s_int;
759
       float s_float;
760
       char  s_char_vec[8];
761
       struct s_tag* s_next;
762
     } g_an_s;
763
 
764
     typedef struct s_tag s_typedef;
765
 
766
   The structure tag has an `N_LSYM' stab type because, like the
767
enumeration, the symbol has file scope.  Like the enumeration, the
768
symbol descriptor is `T', for enumeration, structure, or tag type.  The
769
type descriptor `s' following the `16=' of the type definition narrows
770
the symbol type to structure.
771
 
772
   Following the `s' type descriptor is the number of bytes the
773
structure occupies, followed by a description of each structure element.
774
The structure element descriptions are of the form NAME:TYPE, BIT
775
OFFSET FROM THE START OF THE STRUCT, NUMBER OF BITS IN THE ELEMENT.
776
 
777
     # 128 is N_LSYM
778
     .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;
779
             s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
780
 
781
   In this example, the first two structure elements are previously
782
defined types.  For these, the type following the `NAME:' part of the
783
element description is a simple type reference.  The other two structure
784
elements are new types.  In this case there is a type definition
785
embedded after the `NAME:'.  The type definition for the array element
786
looks just like a type definition for a stand-alone array.  The
787
`s_next' field is a pointer to the same kind of structure that the
788
field is an element of.  So the definition of structure type 16
789
contains a type definition for an element which is a pointer to type 16.
790
 
791
   If a field is a static member (this is a C++ feature in which a
792
single variable appears to be a field of every structure of a given
793
type) it still starts out with the field name, a colon, and the type,
794
but then instead of a comma, bit position, comma, and bit size, there
795
is a colon followed by the name of the variable which each such field
796
refers to.
797
 
798
   If the structure has methods (a C++ feature), they follow the
799
non-method fields; see *Note Cplusplus::.
800
 
801

802
File: stabs.info,  Node: Typedefs,  Next: Unions,  Prev: Structures,  Up: Types
803
 
804
Giving a Type a Name
805
====================
806
 
807
   To give a type a name, use the `t' symbol descriptor.  The type is
808
specified by the type information (*note String Field::) for the stab.
809
For example,
810
 
811
     .stabs "s_typedef:t16",128,0,0,0     # 128 is N_LSYM
812
 
813
   specifies that `s_typedef' refers to type number 16.  Such stabs
814
have symbol type `N_LSYM' (or `C_DECL' for XCOFF).  (The Sun
815
documentation mentions using `N_GSYM' in some cases).
816
 
817
   If you are specifying the tag name for a structure, union, or
818
enumeration, use the `T' symbol descriptor instead.  I believe C is the
819
only language with this feature.
820
 
821
   If the type is an opaque type (I believe this is a Modula-2 feature),
822
AIX provides a type descriptor to specify it.  The type descriptor is
823
`o' and is followed by a name.  I don't know what the name means--is it
824
always the same as the name of the type, or is this type descriptor
825
used with a nameless stab (*note String Field::)?  There optionally
826
follows a comma followed by type information which defines the type of
827
this type.  If omitted, a semicolon is used in place of the comma and
828
the type information, and the type is much like a generic pointer
829
type--it has a known size but little else about it is specified.
830
 
831

832
File: stabs.info,  Node: Unions,  Next: Function Types,  Prev: Typedefs,  Up: Types
833
 
834
Unions
835
======
836
 
837
     union u_tag {
838
       int  u_int;
839
       float u_float;
840
       char* u_char;
841
     } an_u;
842
 
843
   This code generates a stab for a union tag and a stab for a union
844
variable.  Both use the `N_LSYM' stab type.  If a union variable is
845
scoped locally to the procedure in which it is defined, its stab is
846
located immediately preceding the `N_LBRAC' for the procedure's block
847
start.
848
 
849
   The stab for the union tag, however, is located preceding the code
850
for the procedure in which it is defined.  The stab type is `N_LSYM'.
851
This would seem to imply that the union type is file scope, like the
852
struct type `s_tag'.  This is not true.  The contents and position of
853
the stab for `u_type' do not convey any information about its procedure
854
local scope.
855
 
856
     # 128 is N_LSYM
857
     .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;",
858
            128,0,0,0
859
 
860
   The symbol descriptor `T', following the `name:' means that the stab
861
describes an enumeration, structure, or union tag.  The type descriptor
862
`u', following the `23=' of the type definition, narrows it down to a
863
union type definition.  Following the `u' is the number of bytes in the
864
union.  After that is a list of union element descriptions.  Their
865
format is NAME:TYPE, BIT OFFSET INTO THE UNION, NUMBER OF BYTES FOR THE
866
ELEMENT;.
867
 
868
   The stab for the union variable is:
869
 
870
     .stabs "an_u:23",128,0,0,-20     # 128 is N_LSYM
871
 
872
   `-20' specifies where the variable is stored (*note Stack
873
Variables::).
874
 
875

876
File: stabs.info,  Node: Function Types,  Prev: Unions,  Up: Types
877
 
878
Function Types
879
==============
880
 
881
   Various types can be defined for function variables.  These types are
882
not used in defining functions (*note Procedures::); they are used for
883
things like pointers to functions.
884
 
885
   The simple, traditional, type is type descriptor `f' is followed by
886
type information for the return type of the function, followed by a
887
semicolon.
888
 
889
   This does not deal with functions for which the number and types of
890
the parameters are part of the type, as in Modula-2 or ANSI C.  AIX
891
provides extensions to specify these, using the `f', `F', `p', and `R'
892
type descriptors.
893
 
894
   First comes the type descriptor.  If it is `f' or `F', this type
895
involves a function rather than a procedure, and the type information
896
for the return type of the function follows, followed by a comma.  Then
897
comes the number of parameters to the function and a semicolon.  Then,
898
for each parameter, there is the name of the parameter followed by a
899
colon (this is only present for type descriptors `R' and `F' which
900
represent Pascal function or procedure parameters), type information
901
for the parameter, a comma, 0 if passed by reference or 1 if passed by
902
value, and a semicolon.  The type definition ends with a semicolon.
903
 
904
   For example, this variable definition:
905
 
906
     int (*g_pf)();
907
 
908
generates the following code:
909
 
910
     .stabs "g_pf:G24=*25=f1",32,0,0,0
911
         .common _g_pf,4,"bss"
912
 
913
   The variable defines a new type, 24, which is a pointer to another
914
new type, 25, which is a function returning `int'.
915
 
916

917
File: stabs.info,  Node: Symbol Tables,  Next: Cplusplus,  Prev: Types,  Up: Top
918
 
919
Symbol Information in Symbol Tables
920
***********************************
921
 
922
   This chapter describes the format of symbol table entries and how
923
stab assembler directives map to them.  It also describes the
924
transformations that the assembler and linker make on data from stabs.
925
 
926
* Menu:
927
 
928
* Symbol Table Format::
929
* Transformations On Symbol Tables::
930
 
931

932
File: stabs.info,  Node: Symbol Table Format,  Next: Transformations On Symbol Tables,  Up: Symbol Tables
933
 
934
Symbol Table Format
935
===================
936
 
937
   Each time the assembler encounters a stab directive, it puts each
938
field of the stab into a corresponding field in a symbol table entry of
939
its output file.  If the stab contains a string field, the symbol table
940
entry for that stab points to a string table entry containing the
941
string data from the stab.  Assembler labels become relocatable
942
addresses.  Symbol table entries in a.out have the format:
943
 
944
     struct internal_nlist {
945
       unsigned long n_strx;         /* index into string table of name */
946
       unsigned char n_type;         /* type of symbol */
947
       unsigned char n_other;        /* misc info (usually empty) */
948
       unsigned short n_desc;        /* description field */
949
       bfd_vma n_value;              /* value of symbol */
950
     };
951
 
952
   If the stab has a string, the `n_strx' field holds the offset in
953
bytes of the string within the string table.  The string is terminated
954
by a NUL character.  If the stab lacks a string (for example, it was
955
produced by a `.stabn' or `.stabd' directive), the `n_strx' field is
956
zero.
957
 
958
   Symbol table entries with `n_type' field values greater than 0x1f
959
originated as stabs generated by the compiler (with one random
960
exception).  The other entries were placed in the symbol table of the
961
executable by the assembler or the linker.
962
 
963

964
File: stabs.info,  Node: Transformations On Symbol Tables,  Prev: Symbol Table Format,  Up: Symbol Tables
965
 
966
Transformations on Symbol Tables
967
================================
968
 
969
   The linker concatenates object files and does fixups of externally
970
defined symbols.
971
 
972
   You can see the transformations made on stab data by the assembler
973
and linker by examining the symbol table after each pass of the build.
974
To do this, use `nm -ap', which dumps the symbol table, including
975
debugging information, unsorted.  For stab entries the columns are:
976
VALUE, OTHER, DESC, TYPE, STRING.  For assembler and linker symbols,
977
the columns are: VALUE, TYPE, STRING.
978
 
979
   The low 5 bits of the stab type tell the linker how to relocate the
980
value of the stab.  Thus for stab types like `N_RSYM' and `N_LSYM',
981
where the value is an offset or a register number, the low 5 bits are
982
`N_ABS', which tells the linker not to relocate the value.
983
 
984
   Where the value of a stab contains an assembly language label, it is
985
transformed by each build step.  The assembler turns it into a
986
relocatable address and the linker turns it into an absolute address.
987
 
988
* Menu:
989
 
990
* Transformations On Static Variables::
991
* Transformations On Global Variables::
992
* Stab Section Transformations::           For some object file formats,
993
                                           things are a bit different.
994
 
995

996
File: stabs.info,  Node: Transformations On Static Variables,  Next: Transformations On Global Variables,  Up: Transformations On Symbol Tables
997
 
998
Transformations on Static Variables
999
-----------------------------------
1000
 
1001
   This source line defines a static variable at file scope:
1002
 
1003
     static int s_g_repeat
1004
 
1005
The following stab describes the symbol:
1006
 
1007
     .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
1008
 
1009
The assembler transforms the stab into this symbol table entry in the
1010
`.o' file.  The location is expressed as a data segment offset.
1011
 
1012
     00000084 - 00 0000 STSYM s_g_repeat:S1
1013
 
1014
In the symbol table entry from the executable, the linker has made the
1015
relocatable address absolute.
1016
 
1017
     0000e00c - 00 0000 STSYM s_g_repeat:S1
1018
 
1019

1020
File: stabs.info,  Node: Transformations On Global Variables,  Next: Stab Section Transformations,  Prev: Transformations On Static Variables,  Up: Transformations On Symbol Tables
1021
 
1022
Transformations on Global Variables
1023
-----------------------------------
1024
 
1025
   Stabs for global variables do not contain location information. In
1026
this case, the debugger finds location information in the assembler or
1027
linker symbol table entry describing the variable.  The source line:
1028
 
1029
     char g_foo = 'c';
1030
 
1031
generates the stab:
1032
 
1033
     .stabs "g_foo:G2",32,0,0,0
1034
 
1035
   The variable is represented by two symbol table entries in the object
1036
file (see below).  The first one originated as a stab.  The second one
1037
is an external symbol.  The upper case `D' signifies that the `n_type'
1038
field of the symbol table contains 7, `N_DATA' with local linkage.  The
1039
stab's value is zero since the value is not used for `N_GSYM' stabs.
1040
The value of the linker symbol is the relocatable address corresponding
1041
to the variable.
1042
 
1043
     00000000 - 00 0000  GSYM g_foo:G2
1044
     00000080 D _g_foo
1045
 
1046
These entries as transformed by the linker.  The linker symbol table
1047
entry now holds an absolute address:
1048
 
1049
     00000000 - 00 0000  GSYM g_foo:G2
1050
     ...
1051
     0000e008 D _g_foo
1052
 
1053

1054
File: stabs.info,  Node: Stab Section Transformations,  Prev: Transformations On Global Variables,  Up: Transformations On Symbol Tables
1055
 
1056
Transformations of Stabs in separate sections
1057
---------------------------------------------
1058
 
1059
   For object file formats using stabs in separate sections (*note Stab
1060
Sections::), use `objdump --stabs' instead of `nm' to show the stabs in
1061
an object or executable file.  `objdump' is a GNU utility; Sun does not
1062
provide any equivalent.
1063
 
1064
   The following example is for a stab whose value is an address is
1065
relative to the compilation unit (*note ELF Linker Relocation::).  For
1066
example, if the source line
1067
 
1068
     static int ld = 5;
1069
 
1070
   appears within a function, then the assembly language output from the
1071
compiler contains:
1072
 
1073
     .Ddata.data:
1074
     ...
1075
             .stabs "ld:V(0,3)",0x26,0,4,.L18-Ddata.data    # 0x26 is N_STSYM
1076
     ...
1077
     .L18:
1078
             .align 4
1079
             .word 0x5
1080
 
1081
   Because the value is formed by subtracting one symbol from another,
1082
the value is absolute, not relocatable, and so the object file contains
1083
 
1084
     Symnum n_type n_othr n_desc n_value  n_strx String
1085
     31     STSYM  0      4      00000004 680    ld:V(0,3)
1086
 
1087
   without any relocations, and the executable file also contains
1088
 
1089
     Symnum n_type n_othr n_desc n_value  n_strx String
1090
     31     STSYM  0      4      00000004 680    ld:V(0,3)
1091
 
1092

1093
File: stabs.info,  Node: Cplusplus,  Next: Stab Types,  Prev: Symbol Tables,  Up: Top
1094
 
1095
GNU C++ Stabs
1096
*************
1097
 
1098
* Menu:
1099
 
1100
* Class Names::                 C++ class names are both tags and typedefs.
1101
* Nested Symbols::              C++ symbol names can be within other types.
1102
* Basic Cplusplus Types::
1103
* Simple Classes::
1104
* Class Instance::
1105
* Methods::                     Method definition
1106
* Method Type Descriptor::      The `#' type descriptor
1107
* Member Type Descriptor::      The `@' type descriptor
1108
* Protections::
1109
* Method Modifiers::
1110
* Virtual Methods::
1111
* Inheritance::
1112
* Virtual Base Classes::
1113
* Static Members::
1114
 
1115

1116
File: stabs.info,  Node: Class Names,  Next: Nested Symbols,  Up: Cplusplus
1117
 
1118
C++ Class Names
1119
===============
1120
 
1121
   In C++, a class name which is declared with `class', `struct', or
1122
`union', is not only a tag, as in C, but also a type name.  Thus there
1123
should be stabs with both `t' and `T' symbol descriptors (*note
1124
Typedefs::).
1125
 
1126
   To save space, there is a special abbreviation for this case.  If the
1127
`T' symbol descriptor is followed by `t', then the stab defines both a
1128
type name and a tag.
1129
 
1130
   For example, the C++ code
1131
 
1132
     struct foo {int x;};
1133
 
1134
   can be represented as either
1135
 
1136
     .stabs "foo:T19=s4x:1,0,32;;",128,0,0,0       # 128 is N_LSYM
1137
     .stabs "foo:t19",128,0,0,0
1138
 
1139
   or
1140
 
1141
     .stabs "foo:Tt19=s4x:1,0,32;;",128,0,0,0
1142
 
1143

1144
File: stabs.info,  Node: Nested Symbols,  Next: Basic Cplusplus Types,  Prev: Class Names,  Up: Cplusplus
1145
 
1146
Defining a Symbol Within Another Type
1147
=====================================
1148
 
1149
   In C++, a symbol (such as a type name) can be defined within another
1150
type.
1151
 
1152
   In stabs, this is sometimes represented by making the name of a
1153
symbol which contains `::'.  Such a pair of colons does not end the name
1154
of the symbol, the way a single colon would (*note String Field::).  I'm
1155
not sure how consistently used or well thought out this mechanism is.
1156
So that a pair of colons in this position always has this meaning, `:'
1157
cannot be used as a symbol descriptor.
1158
 
1159
   For example, if the string for a stab is `foo::bar::baz:t5=*6', then
1160
`foo::bar::baz' is the name of the symbol, `t' is the symbol
1161
descriptor, and `5=*6' is the type information.
1162
 
1163

1164
File: stabs.info,  Node: Basic Cplusplus Types,  Next: Simple Classes,  Prev: Nested Symbols,  Up: Cplusplus
1165
 
1166
Basic Types For C++
1167
===================
1168
 
1169
   << the examples that follow are based on a01.C >>
1170
 
1171
   C++ adds two more builtin types to the set defined for C.  These are
1172
the unknown type and the vtable record type.  The unknown type, type
1173
16, is defined in terms of itself like the void type.
1174
 
1175
   The vtable record type, type 17, is defined as a structure type and
1176
then as a structure tag.  The structure has four fields: delta, index,
1177
pfn, and delta2.  pfn is the function pointer.
1178
 
1179
   << In boilerplate $vtbl_ptr_type, what are the fields delta, index,
1180
and delta2 used for? >>
1181
 
1182
   This basic type is present in all C++ programs even if there are no
1183
virtual methods defined.
1184
 
1185
     .stabs "struct_name:sym_desc(type)type_def(17)=type_desc(struct)struct_bytes(8)
1186
             elem_name(delta):type_ref(short int),bit_offset(0),field_bits(16);
1187
             elem_name(index):type_ref(short int),bit_offset(16),field_bits(16);
1188
             elem_name(pfn):type_def(18)=type_desc(ptr to)type_ref(void),
1189
                                         bit_offset(32),field_bits(32);
1190
             elem_name(delta2):type_def(short int);bit_offset(32),field_bits(16);;"
1191
             N_LSYM, NIL, NIL
1192
 
1193
     .stabs "$vtbl_ptr_type:t17=s8
1194
             delta:6,0,16;index:6,16,16;pfn:18=*15,32,32;delta2:6,32,16;;"
1195
             ,128,0,0,0
1196
 
1197
     .stabs "name:sym_dec(struct tag)type_ref($vtbl_ptr_type)",N_LSYM,NIL,NIL,NIL
1198
 
1199
     .stabs "$vtbl_ptr_type:T17",128,0,0,0
1200
 
1201

1202
File: stabs.info,  Node: Simple Classes,  Next: Class Instance,  Prev: Basic Cplusplus Types,  Up: Cplusplus
1203
 
1204
Simple Class Definition
1205
=======================
1206
 
1207
   The stabs describing C++ language features are an extension of the
1208
stabs describing C.  Stabs representing C++ class types elaborate
1209
extensively on the stab format used to describe structure types in C.
1210
Stabs representing class type variables look just like stabs
1211
representing C language variables.
1212
 
1213
   Consider the following very simple class definition.
1214
 
1215
     class baseA {
1216
     public:
1217
             int Adat;
1218
             int Ameth(int in, char other);
1219
     };
1220
 
1221
   The class `baseA' is represented by two stabs.  The first stab
1222
describes the class as a structure type.  The second stab describes a
1223
structure tag of the class type.  Both stabs are of stab type `N_LSYM'.
1224
Since the stab is not located between an `N_FUN' and an `N_LBRAC' stab
1225
this indicates that the class is defined at file scope.  If it were,
1226
then the `N_LSYM' would signify a local variable.
1227
 
1228
   A stab describing a C++ class type is similar in format to a stab
1229
describing a C struct, with each class member shown as a field in the
1230
structure.  The part of the struct format describing fields is expanded
1231
to include extra information relevant to C++ class members.  In
1232
addition, if the class has multiple base classes or virtual functions
1233
the struct format outside of the field parts is also augmented.
1234
 
1235
   In this simple example the field part of the C++ class stab
1236
representing member data looks just like the field part of a C struct
1237
stab.  The section on protections describes how its format is sometimes
1238
extended for member data.
1239
 
1240
   The field part of a C++ class stab representing a member function
1241
differs substantially from the field part of a C struct stab.  It still
1242
begins with `name:' but then goes on to define a new type number for
1243
the member function, describe its return type, its argument types, its
1244
protection level, any qualifiers applied to the method definition, and
1245
whether the method is virtual or not.  If the method is virtual then
1246
the method description goes on to give the vtable index of the method,
1247
and the type number of the first base class defining the method.
1248
 
1249
   When the field name is a method name it is followed by two colons
1250
rather than one.  This is followed by a new type definition for the
1251
method.  This is a number followed by an equal sign and the type of the
1252
method.  Normally this will be a type declared using the `#' type
1253
descriptor; see *Note Method Type Descriptor::; static member functions
1254
are declared using the `f' type descriptor instead; see *Note Function
1255
Types::.
1256
 
1257
   The format of an overloaded operator method name differs from that of
1258
other methods.  It is `op$::OPERATOR-NAME.' where OPERATOR-NAME is the
1259
operator name such as `+' or `+='.  The name ends with a period, and
1260
any characters except the period can occur in the OPERATOR-NAME string.
1261
 
1262
   The next part of the method description represents the arguments to
1263
the method, preceded by a colon and ending with a semi-colon.  The
1264
types of the arguments are expressed in the same way argument types are
1265
expressed in C++ name mangling.  In this example an `int' and a `char'
1266
map to `ic'.
1267
 
1268
   This is followed by a number, a letter, and an asterisk or period,
1269
followed by another semicolon.  The number indicates the protections
1270
that apply to the member function.  Here the 2 means public.  The
1271
letter encodes any qualifier applied to the method definition.  In this
1272
case, `A' means that it is a normal function definition.  The dot shows
1273
that the method is not virtual.  The sections that follow elaborate
1274
further on these fields and describe the additional information present
1275
for virtual methods.
1276
 
1277
     .stabs "class_name:sym_desc(type)type_def(20)=type_desc(struct)struct_bytes(4)
1278
             field_name(Adat):type(int),bit_offset(0),field_bits(32);
1279
 
1280
             method_name(Ameth)::type_def(21)=type_desc(method)return_type(int);
1281
             :arg_types(int char);
1282
             protection(public)qualifier(normal)virtual(no);;"
1283
             N_LSYM,NIL,NIL,NIL
1284
 
1285
     .stabs "baseA:t20=s4Adat:1,0,32;Ameth::21=##1;:ic;2A.;;",128,0,0,0
1286
 
1287
     .stabs "class_name:sym_desc(struct tag)",N_LSYM,NIL,NIL,NIL
1288
 
1289
     .stabs "baseA:T20",128,0,0,0
1290
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.