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

Subversion Repositories altor32

[/] [altor32/] [trunk/] [gcc-x64/] [or1knd-elf/] [share/] [info/] [stabs.info] - Blame information for rev 35

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 35 ultra_embe
This is stabs.info, produced by makeinfo version 4.13 from
2
./stabs.texinfo.
3
 
4
INFO-DIR-SECTION Software development
5
START-INFO-DIR-ENTRY
6
* Stabs: (stabs).                 The "stabs" debugging information format.
7
END-INFO-DIR-ENTRY
8
 
9
   Copyright (C) 1992-1995, 1997-1998, 2000-2007, 2009-2012 Free
10
Software Foundation, Inc.  Contributed by Cygnus Support.  Written by
11
Julia Menapace, Jim Kingdon, and David MacKenzie.
12
 
13
   Permission is granted to copy, distribute and/or modify this document
14
under the terms of the GNU Free Documentation License, Version 1.3 or
15
any later version published by the Free Software Foundation; with no
16
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
17
Texts.  A copy of the license is included in the section entitled "GNU
18
Free Documentation License".
19
 
20
   This document describes the stabs debugging symbol tables.
21
 
22
   Copyright (C) 1992-1995, 1997-1998, 2000-2007, 2009-2012 Free
23
Software Foundation, Inc.  Contributed by Cygnus Support.  Written by
24
Julia Menapace, Jim Kingdon, and David MacKenzie.
25
 
26
   Permission is granted to copy, distribute and/or modify this document
27
under the terms of the GNU Free Documentation License, Version 1.3 or
28
any later version published by the Free Software Foundation; with no
29
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
30
Texts.  A copy of the license is included in the section entitled "GNU
31
Free Documentation License".
32
 
33

34
File: stabs.info,  Node: Top,  Next: Overview,  Up: (dir)
35
 
36
The "stabs" representation of debugging information
37
***************************************************
38
 
39
This document describes the stabs debugging format.
40
 
41
* Menu:
42
 
43
* Overview::                    Overview of stabs
44
* Program Structure::           Encoding of the structure of the program
45
* Constants::                   Constants
46
* Variables::
47
* Types::                       Type definitions
48
* Macro define and undefine::   Representation of #define and #undef
49
* Symbol Tables::               Symbol information in symbol tables
50
* Cplusplus::                   Stabs specific to C++
51
* Stab Types::                  Symbol types in a.out files
52
* Symbol Descriptors::          Table of symbol descriptors
53
* Type Descriptors::            Table of type descriptors
54
* Expanded Reference::          Reference information by stab type
55
* Questions::                   Questions and anomalies
56
* Stab Sections::               In some object file formats, stabs are
57
                                in sections.
58
* GNU Free Documentation License::  The license for this documentation
59
* Symbol Types Index::          Index of symbolic stab symbol type names.
60
 
61

62
File: stabs.info,  Node: Overview,  Next: Program Structure,  Prev: Top,  Up: Top
63
 
64
1 Overview of Stabs
65
*******************
66
 
67
"Stabs" refers to a format for information that describes a program to
68
a debugger.  This format was apparently invented by Peter Kessler at
69
the University of California at Berkeley, for the `pdx' Pascal
70
debugger; the format has spread widely since then.
71
 
72
   This document is one of the few published sources of documentation on
73
stabs.  It is believed to be comprehensive for stabs used by C.  The
74
lists of symbol descriptors (*note Symbol Descriptors::) and type
75
descriptors (*note Type Descriptors::) are believed to be completely
76
comprehensive.  Stabs for COBOL-specific features and for variant
77
records (used by Pascal and Modula-2) are poorly documented here.
78
 
79
   Other sources of information on stabs are `Dbx and Dbxtool
80
Interfaces', 2nd edition, by Sun, 1988, and `AIX Version 3.2 Files
81
Reference', Fourth Edition, September 1992, "dbx Stabstring Grammar" in
82
the a.out section, page 2-31.  This document is believed to incorporate
83
the information from those two sources except where it explicitly
84
directs you to them for more information.
85
 
86
* Menu:
87
 
88
* Flow::                        Overview of debugging information flow
89
* Stabs Format::                Overview of stab format
90
* String Field::                The string field
91
* C Example::                   A simple example in C source
92
* Assembly Code::               The simple example at the assembly level
93
 
94

95
File: stabs.info,  Node: Flow,  Next: Stabs Format,  Up: Overview
96
 
97
1.1 Overview of Debugging Information Flow
98
==========================================
99
 
100
The GNU C compiler compiles C source in a `.c' file into assembly
101
language in a `.s' file, which the assembler translates into a `.o'
102
file, which the linker combines with other `.o' files and libraries to
103
produce an executable file.
104
 
105
   With the `-g' option, GCC puts in the `.s' file additional debugging
106
information, which is slightly transformed by the assembler and linker,
107
and carried through into the final executable.  This debugging
108
information describes features of the source file like line numbers,
109
the types and scopes of variables, and function names, parameters, and
110
scopes.
111
 
112
   For some object file formats, the debugging information is
113
encapsulated in assembler directives known collectively as "stab"
114
(symbol table) directives, which are interspersed with the generated
115
code.  Stabs are the native format for debugging information in the
116
a.out and XCOFF object file formats.  The GNU tools can also emit stabs
117
in the COFF and ECOFF object file formats.
118
 
119
   The assembler adds the information from stabs to the symbol
120
information it places by default in the symbol table and the string
121
table of the `.o' file it is building.  The linker consolidates the `.o'
122
files into one executable file, with one symbol table and one string
123
table.  Debuggers use the symbol and string tables in the executable as
124
a source of debugging information about the program.
125
 
126

127
File: stabs.info,  Node: Stabs Format,  Next: String Field,  Prev: Flow,  Up: Overview
128
 
129
1.2 Overview of Stab Format
130
===========================
131
 
132
There are three overall formats for stab assembler directives,
133
differentiated by the first word of the stab.  The name of the directive
134
describes which combination of four possible data fields follows.  It is
135
either `.stabs' (string), `.stabn' (number), or `.stabd' (dot).  IBM's
136
XCOFF assembler uses `.stabx' (and some other directives such as
137
`.file' and `.bi') instead of `.stabs', `.stabn' or `.stabd'.
138
 
139
   The overall format of each class of stab is:
140
 
141
     .stabs "STRING",TYPE,OTHER,DESC,VALUE
142
     .stabn TYPE,OTHER,DESC,VALUE
143
     .stabd TYPE,OTHER,DESC
144
     .stabx "STRING",VALUE,TYPE,SDB-TYPE
145
 
146
   For `.stabn' and `.stabd', there is no STRING (the `n_strx' field is
147
zero; see *note Symbol Tables::).  For `.stabd', the VALUE field is
148
implicit and has the value of the current file location.  For `.stabx',
149
the SDB-TYPE field is unused for stabs and can always be set to zero.
150
The OTHER field is almost always unused and can be set to zero.
151
 
152
   The number in the TYPE field gives some basic information about
153
which type of stab this is (or whether it _is_ a stab, as opposed to an
154
ordinary symbol).  Each valid type number defines a different stab
155
type; further, the stab type defines the exact interpretation of, and
156
possible values for, any remaining STRING, DESC, or VALUE fields
157
present in the stab.  *Note Stab Types::, for a list in numeric order
158
of the valid TYPE field values for stab directives.
159
 
160

161
File: stabs.info,  Node: String Field,  Next: C Example,  Prev: Stabs Format,  Up: Overview
162
 
163
1.3 The String Field
164
====================
165
 
166
For most stabs the string field holds the meat of the debugging
167
information.  The flexible nature of this field is what makes stabs
168
extensible.  For some stab types the string field contains only a name.
169
For other stab types the contents can be a great deal more complex.
170
 
171
   The overall format of the string field for most stab types is:
172
 
173
     "NAME:SYMBOL-DESCRIPTOR TYPE-INFORMATION"
174
 
175
   NAME is the name of the symbol represented by the stab; it can
176
contain a pair of colons (*note Nested Symbols::).  NAME can be
177
omitted, which means the stab represents an unnamed object.  For
178
example, `:t10=*2' defines type 10 as a pointer to type 2, but does not
179
give the type a name.  Omitting the NAME field is supported by AIX dbx
180
and GDB after about version 4.8, but not other debuggers.  GCC
181
sometimes uses a single space as the name instead of omitting the name
182
altogether; apparently that is supported by most debuggers.
183
 
184
   The SYMBOL-DESCRIPTOR following the `:' is an alphabetic character
185
that tells more specifically what kind of symbol the stab represents.
186
If the SYMBOL-DESCRIPTOR is omitted, but type information follows, then
187
the stab represents a local variable.  For a list of symbol
188
descriptors, see *note Symbol Descriptors::.  The `c' symbol descriptor
189
is an exception in that it is not followed by type information.  *Note
190
Constants::.
191
 
192
   TYPE-INFORMATION is either a TYPE-NUMBER, or `TYPE-NUMBER='.  A
193
TYPE-NUMBER alone is a type reference, referring directly to a type
194
that has already been defined.
195
 
196
   The `TYPE-NUMBER=' form is a type definition, where the number
197
represents a new type which is about to be defined.  The type
198
definition may refer to other types by number, and those type numbers
199
may be followed by `=' and nested definitions.  Also, the Lucid
200
compiler will repeat `TYPE-NUMBER=' more than once if it wants to
201
define several type numbers at once.
202
 
203
   In a type definition, if the character that follows the equals sign
204
is non-numeric then it is a TYPE-DESCRIPTOR, and tells what kind of
205
type is about to be defined.  Any other values following the
206
TYPE-DESCRIPTOR vary, depending on the TYPE-DESCRIPTOR.  *Note Type
207
Descriptors::, for a list of TYPE-DESCRIPTOR values.  If a number
208
follows the `=' then the number is a TYPE-REFERENCE.  For a full
209
description of types, *note Types::.
210
 
211
   A TYPE-NUMBER is often a single number.  The GNU and Sun tools
212
additionally permit a TYPE-NUMBER to be a pair
213
(FILE-NUMBER,FILETYPE-NUMBER) (the parentheses appear in the string,
214
and serve to distinguish the two cases).  The FILE-NUMBER is 0 for the
215
base source file, 1 for the first included file, 2 for the next, and so
216
on.  The FILETYPE-NUMBER is a number starting with 1 which is
217
incremented for each new type defined in the file.  (Separating the
218
file number and the type number permits the `N_BINCL' optimization to
219
succeed more often; see *note Include Files::).
220
 
221
   There is an AIX extension for type attributes.  Following the `='
222
are any number of type attributes.  Each one starts with `@' and ends
223
with `;'.  Debuggers, including AIX's dbx and GDB 4.10, skip any type
224
attributes they do not recognize.  GDB 4.9 and other versions of dbx
225
may not do this.  Because of a conflict with C++ (*note Cplusplus::),
226
new attributes should not be defined which begin with a digit, `(', or
227
`-'; GDB may be unable to distinguish those from the C++ type
228
descriptor `@'.  The attributes are:
229
 
230
`aBOUNDARY'
231
     BOUNDARY is an integer specifying the alignment.  I assume it
232
     applies to all variables of this type.
233
 
234
`pINTEGER'
235
     Pointer class (for checking).  Not sure what this means, or how
236
     INTEGER is interpreted.
237
 
238
`P'
239
     Indicate this is a packed type, meaning that structure fields or
240
     array elements are placed more closely in memory, to save memory
241
     at the expense of speed.
242
 
243
`sSIZE'
244
     Size in bits of a variable of this type.  This is fully supported
245
     by GDB 4.11 and later.
246
 
247
`S'
248
     Indicate that this type is a string instead of an array of
249
     characters, or a bitstring instead of a set.  It doesn't change
250
     the layout of the data being represented, but does enable the
251
     debugger to know which type it is.
252
 
253
`V'
254
     Indicate that this type is a vector instead of an array.  The only
255
     major difference between vectors and arrays is that vectors are
256
     passed by value instead of by reference (vector coprocessor
257
     extension).
258
 
259
 
260
   All of this can make the string field quite long.  All versions of
261
GDB, and some versions of dbx, can handle arbitrarily long strings.
262
But many versions of dbx (or assemblers or linkers, I'm not sure which)
263
cretinously limit the strings to about 80 characters, so compilers which
264
must work with such systems need to split the `.stabs' directive into
265
several `.stabs' directives.  Each stab duplicates every field except
266
the string field.  The string field of every stab except the last is
267
marked as continued with a backslash at the end (in the assembly code
268
this may be written as a double backslash, depending on the assembler).
269
Removing the backslashes and concatenating the string fields of each
270
stab produces the original, long string.  Just to be incompatible (or so
271
they don't have to worry about what the assembler does with
272
backslashes), AIX can use `?' instead of backslash.
273
 
274

275
File: stabs.info,  Node: C Example,  Next: Assembly Code,  Prev: String Field,  Up: Overview
276
 
277
1.4 A Simple Example in C Source
278
================================
279
 
280
To get the flavor of how stabs describe source information for a C
281
program, let's look at the simple program:
282
 
283
     main()
284
     {
285
             printf("Hello world");
286
     }
287
 
288
   When compiled with `-g', the program above yields the following `.s'
289
file.  Line numbers have been added to make it easier to refer to parts
290
of the `.s' file in the description of the stabs that follows.
291
 
292

293
File: stabs.info,  Node: Assembly Code,  Prev: C Example,  Up: Overview
294
 
295
1.5 The Simple Example at the Assembly Level
296
============================================
297
 
298
This simple "hello world" example demonstrates several of the stab
299
types used to describe C language source files.
300
 
301
     1  gcc2_compiled.:
302
     2  .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
303
     3  .stabs "hello.c",100,0,0,Ltext0
304
     4  .text
305
     5  Ltext0:
306
     6  .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
307
     7  .stabs "char:t2=r2;0;127;",128,0,0,0
308
     8  .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
309
     9  .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
310
     10 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
311
     11 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0
312
     12 .stabs "long long int:t7=r1;0;-1;",128,0,0,0
313
     13 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
314
     14 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
315
     15 .stabs "signed char:t10=r1;-128;127;",128,0,0,0
316
     16 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0
317
     17 .stabs "float:t12=r1;4;0;",128,0,0,0
318
     18 .stabs "double:t13=r1;8;0;",128,0,0,0
319
     19 .stabs "long double:t14=r1;8;0;",128,0,0,0
320
     20 .stabs "void:t15=15",128,0,0,0
321
     21      .align 4
322
     22 LC0:
323
     23      .ascii "Hello, world!\12\0"
324
     24      .align 4
325
     25      .global _main
326
     26      .proc 1
327
     27 _main:
328
     28 .stabn 68,0,4,LM1
329
     29 LM1:
330
     30      !#PROLOGUE# 0
331
     31      save %sp,-136,%sp
332
     32      !#PROLOGUE# 1
333
     33      call ___main,0
334
     34      nop
335
     35 .stabn 68,0,5,LM2
336
     36 LM2:
337
     37 LBB2:
338
     38      sethi %hi(LC0),%o1
339
     39      or %o1,%lo(LC0),%o0
340
     40      call _printf,0
341
     41      nop
342
     42 .stabn 68,0,6,LM3
343
     43 LM3:
344
     44 LBE2:
345
     45 .stabn 68,0,6,LM4
346
     46 LM4:
347
     47 L1:
348
     48      ret
349
     49      restore
350
     50 .stabs "main:F1",36,0,0,_main
351
     51 .stabn 192,0,0,LBB2
352
     52 .stabn 224,0,0,LBE2
353
 
354

355
File: stabs.info,  Node: Program Structure,  Next: Constants,  Prev: Overview,  Up: Top
356
 
357
2 Encoding the Structure of the Program
358
***************************************
359
 
360
The elements of the program structure that stabs encode include the name
361
of the main function, the names of the source and include files, the
362
line numbers, procedure names and types, and the beginnings and ends of
363
blocks of code.
364
 
365
* Menu:
366
 
367
* Main Program::                Indicate what the main program is
368
* Source Files::                The path and name of the source file
369
* Include Files::               Names of include files
370
* Line Numbers::
371
* Procedures::
372
* Nested Procedures::
373
* Block Structure::
374
* Alternate Entry Points::      Entering procedures except at the beginning.
375
 
376

377
File: stabs.info,  Node: Main Program,  Next: Source Files,  Up: Program Structure
378
 
379
2.1 Main Program
380
================
381
 
382
Most languages allow the main program to have any name.  The `N_MAIN'
383
stab type tells the debugger the name that is used in this program.
384
Only the string field is significant; it is the name of a function
385
which is the main program.  Most C compilers do not use this stab (they
386
expect the debugger to assume that the name is `main'), but some C
387
compilers emit an `N_MAIN' stab for the `main' function.  I'm not sure
388
how XCOFF handles this.
389
 
390

391
File: stabs.info,  Node: Source Files,  Next: Include Files,  Prev: Main Program,  Up: Program Structure
392
 
393
2.2 Paths and Names of the Source Files
394
=======================================
395
 
396
Before any other stabs occur, there must be a stab specifying the source
397
file.  This information is contained in a symbol of stab type `N_SO';
398
the string field contains the name of the file.  The value of the
399
symbol is the start address of the portion of the text section
400
corresponding to that file.
401
 
402
   Some compilers use the desc field to indicate the language of the
403
source file.  Sun's compilers started this usage, and the first
404
constants are derived from their documentation.  Languages added by
405
gcc/gdb start at 0x32 to avoid conflict with languages Sun may add in
406
the future.  A desc field with a value 0 indicates that no language has
407
been specified via this mechanism.
408
 
409
`N_SO_AS' (0x1)
410
     Assembly language
411
 
412
`N_SO_C'  (0x2)
413
     K&R traditional C
414
 
415
`N_SO_ANSI_C' (0x3)
416
     ANSI C
417
 
418
`N_SO_CC'  (0x4)
419
     C++
420
 
421
`N_SO_FORTRAN' (0x5)
422
     Fortran
423
 
424
`N_SO_PASCAL' (0x6)
425
     Pascal
426
 
427
`N_SO_FORTRAN90' (0x7)
428
     Fortran90
429
 
430
`N_SO_OBJC' (0x32)
431
     Objective-C
432
 
433
`N_SO_OBJCPLUS' (0x33)
434
     Objective-C++
435
 
436
   Some compilers (for example, GCC2 and SunOS4 `/bin/cc') also include
437
the directory in which the source was compiled, in a second `N_SO'
438
symbol preceding the one containing the file name.  This symbol can be
439
distinguished by the fact that it ends in a slash.  Code from the
440
`cfront' C++ compiler can have additional `N_SO' symbols for
441
nonexistent source files after the `N_SO' for the real source file;
442
these are believed to contain no useful information.
443
 
444
   For example:
445
 
446
     .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0     # 100 is N_SO
447
     .stabs "hello.c",100,0,0,Ltext0
448
             .text
449
     Ltext0:
450
 
451
   Instead of `N_SO' symbols, XCOFF uses a `.file' assembler directive
452
which assembles to a `C_FILE' symbol; explaining this in detail is
453
outside the scope of this document.
454
 
455
   If it is useful to indicate the end of a source file, this is done
456
with an `N_SO' symbol with an empty string for the name.  The value is
457
the address of the end of the text section for the file.  For some
458
systems, there is no indication of the end of a source file, and you
459
just need to figure it ended when you see an `N_SO' for a different
460
source file, or a symbol ending in `.o' (which at least some linkers
461
insert to mark the start of a new `.o' file).
462
 
463

464
File: stabs.info,  Node: Include Files,  Next: Line Numbers,  Prev: Source Files,  Up: Program Structure
465
 
466
2.3 Names of Include Files
467
==========================
468
 
469
There are several schemes for dealing with include files: the
470
traditional `N_SOL' approach, Sun's `N_BINCL' approach, and the XCOFF
471
`C_BINCL' approach (which despite the similar name has little in common
472
with `N_BINCL').
473
 
474
   An `N_SOL' symbol specifies which include file subsequent symbols
475
refer to.  The string field is the name of the file and the value is the
476
text address corresponding to the end of the previous include file and
477
the start of this one.  To specify the main source file again, use an
478
`N_SOL' symbol with the name of the main source file.
479
 
480
   The `N_BINCL' approach works as follows.  An `N_BINCL' symbol
481
specifies the start of an include file.  In an object file, only the
482
string is significant; the linker puts data into some of the other
483
fields.  The end of the include file is marked by an `N_EINCL' symbol
484
(which has no string field).  In an object file, there is no
485
significant data in the `N_EINCL' symbol.  `N_BINCL' and `N_EINCL' can
486
be nested.
487
 
488
   If the linker detects that two source files have identical stabs
489
between an `N_BINCL' and `N_EINCL' pair (as will generally be the case
490
for a header file), then it only puts out the stabs once.  Each
491
additional occurrence is replaced by an `N_EXCL' symbol.  I believe the
492
GNU linker and the Sun (both SunOS4 and Solaris) linker are the only
493
ones which supports this feature.
494
 
495
   A linker which supports this feature will set the value of a
496
`N_BINCL' symbol to the total of all the characters in the stabs
497
strings included in the header file, omitting any file numbers.  The
498
value of an `N_EXCL' symbol is the same as the value of the `N_BINCL'
499
symbol it replaces.  This information can be used to match up `N_EXCL'
500
and `N_BINCL' symbols which have the same filename.  The `N_EINCL'
501
value, and the values of the other and description fields for all
502
three, appear to always be zero.
503
 
504
   For the start of an include file in XCOFF, use the `.bi' assembler
505
directive, which generates a `C_BINCL' symbol.  A `.ei' directive,
506
which generates a `C_EINCL' symbol, denotes the end of the include
507
file.  Both directives are followed by the name of the source file in
508
quotes, which becomes the string for the symbol.  The value of each
509
symbol, produced automatically by the assembler and linker, is the
510
offset into the executable of the beginning (inclusive, as you'd
511
expect) or end (inclusive, as you would not expect) of the portion of
512
the COFF line table that corresponds to this include file.  `C_BINCL'
513
and `C_EINCL' do not nest.
514
 
515

516
File: stabs.info,  Node: Line Numbers,  Next: Procedures,  Prev: Include Files,  Up: Program Structure
517
 
518
2.4 Line Numbers
519
================
520
 
521
An `N_SLINE' symbol represents the start of a source line.  The desc
522
field contains the line number and the value contains the code address
523
for the start of that source line.  On most machines the address is
524
absolute; for stabs in sections (*note Stab Sections::), it is relative
525
to the function in which the `N_SLINE' symbol occurs.
526
 
527
   GNU documents `N_DSLINE' and `N_BSLINE' symbols for line numbers in
528
the data or bss segments, respectively.  They are identical to
529
`N_SLINE' but are relocated differently by the linker.  They were
530
intended to be used to describe the source location of a variable
531
declaration, but I believe that GCC2 actually puts the line number in
532
the desc field of the stab for the variable itself.  GDB has been
533
ignoring these symbols (unless they contain a string field) since at
534
least GDB 3.5.
535
 
536
   For single source lines that generate discontiguous code, such as
537
flow of control statements, there may be more than one line number
538
entry for the same source line.  In this case there is a line number
539
entry at the start of each code range, each with the same line number.
540
 
541
   XCOFF does not use stabs for line numbers.  Instead, it uses COFF
542
line numbers (which are outside the scope of this document).  Standard
543
COFF line numbers cannot deal with include files, but in XCOFF this is
544
fixed with the `C_BINCL' method of marking include files (*note Include
545
Files::).
546
 
547

548
File: stabs.info,  Node: Procedures,  Next: Nested Procedures,  Prev: Line Numbers,  Up: Program Structure
549
 
550
2.5 Procedures
551
==============
552
 
553
All of the following stabs normally use the `N_FUN' symbol type.
554
However, Sun's `acc' compiler on SunOS4 uses `N_GSYM' and `N_STSYM',
555
which means that the value of the stab for the function is useless and
556
the debugger must get the address of the function from the non-stab
557
symbols instead.  On systems where non-stab symbols have leading
558
underscores, the stabs will lack underscores and the debugger needs to
559
know about the leading underscore to match up the stab and the non-stab
560
symbol.  BSD Fortran is said to use `N_FNAME' with the same
561
restriction; the value of the symbol is not useful (I'm not sure it
562
really does use this, because GDB doesn't handle this and no one has
563
complained).
564
 
565
   A function is represented by an `F' symbol descriptor for a global
566
(extern) function, and `f' for a static (local) function.  For a.out,
567
the value of the symbol is the address of the start of the function; it
568
is already relocated.  For stabs in ELF, the SunPRO compiler version
569
2.0.1 and GCC put out an address which gets relocated by the linker.
570
In a future release SunPRO is planning to put out zero, in which case
571
the address can be found from the ELF (non-stab) symbol.  Because
572
looking things up in the ELF symbols would probably be slow, I'm not
573
sure how to find which symbol of that name is the right one, and this
574
doesn't provide any way to deal with nested functions, it would
575
probably be better to make the value of the stab an address relative to
576
the start of the file, or just absolute.  See *note ELF Linker
577
Relocation:: for more information on linker relocation of stabs in ELF
578
files.  For XCOFF, the stab uses the `C_FUN' storage class and the
579
value of the stab is meaningless; the address of the function can be
580
found from the csect symbol (XTY_LD/XMC_PR).
581
 
582
   The type information of the stab represents the return type of the
583
function; thus `foo:f5' means that foo is a function returning type 5.
584
There is no need to try to get the line number of the start of the
585
function from the stab for the function; it is in the next `N_SLINE'
586
symbol.
587
 
588
   Some compilers (such as Sun's Solaris compiler) support an extension
589
for specifying the types of the arguments.  I suspect this extension is
590
not used for old (non-prototyped) function definitions in C.  If the
591
extension is in use, the type information of the stab for the function
592
is followed by type information for each argument, with each argument
593
preceded by `;'.  An argument type of 0 means that additional arguments
594
are being passed, whose types and number may vary (`...' in ANSI C).
595
GDB has tolerated this extension (parsed the syntax, if not necessarily
596
used the information) since at least version 4.8; I don't know whether
597
all versions of dbx tolerate it.  The argument types given here are not
598
redundant with the symbols for the formal parameters (*note
599
Parameters::); they are the types of the arguments as they are passed,
600
before any conversions might take place.  For example, if a C function
601
which is declared without a prototype takes a `float' argument, the
602
value is passed as a `double' but then converted to a `float'.
603
Debuggers need to use the types given in the arguments when printing
604
values, but when calling the function they need to use the types given
605
in the symbol defining the function.
606
 
607
   If the return type and types of arguments of a function which is
608
defined in another source file are specified (i.e., a function
609
prototype in ANSI C), traditionally compilers emit no stab; the only
610
way for the debugger to find the information is if the source file
611
where the function is defined was also compiled with debugging symbols.
612
As an extension the Solaris compiler uses symbol descriptor `P'
613
followed by the return type of the function, followed by the arguments,
614
each preceded by `;', as in a stab with symbol descriptor `f' or `F'.
615
This use of symbol descriptor `P' can be distinguished from its use for
616
register parameters (*note Register Parameters::) by the fact that it
617
has symbol type `N_FUN'.
618
 
619
   The AIX documentation also defines symbol descriptor `J' as an
620
internal function.  I assume this means a function nested within another
621
function.  It also says symbol descriptor `m' is a module in Modula-2
622
or extended Pascal.
623
 
624
   Procedures (functions which do not return values) are represented as
625
functions returning the `void' type in C.  I don't see why this couldn't
626
be used for all languages (inventing a `void' type for this purpose if
627
necessary), but the AIX documentation defines `I', `P', and `Q' for
628
internal, global, and static procedures, respectively.  These symbol
629
descriptors are unusual in that they are not followed by type
630
information.
631
 
632
   The following example shows a stab for a function `main' which
633
returns type number `1'.  The `_main' specified for the value is a
634
reference to an assembler label which is used to fill in the start
635
address of the function.
636
 
637
     .stabs "main:F1",36,0,0,_main      # 36 is N_FUN
638
 
639
   The stab representing a procedure is located immediately following
640
the code of the procedure.  This stab is in turn directly followed by a
641
group of other stabs describing elements of the procedure.  These other
642
stabs describe the procedure's parameters, its block local variables,
643
and its block structure.
644
 
645
   If functions can appear in different sections, then the debugger may
646
not be able to find the end of a function.  Recent versions of GCC will
647
mark the end of a function with an `N_FUN' symbol with an empty string
648
for the name.  The value is the address of the end of the current
649
function.  Without such a symbol, there is no indication of the address
650
of the end of a function, and you must assume that it ended at the
651
starting address of the next function or at the end of the text section
652
for the program.
653
 
654

655
File: stabs.info,  Node: Nested Procedures,  Next: Block Structure,  Prev: Procedures,  Up: Program Structure
656
 
657
2.6 Nested Procedures
658
=====================
659
 
660
For any of the symbol descriptors representing procedures, after the
661
symbol descriptor and the type information is optionally a scope
662
specifier.  This consists of a comma, the name of the procedure, another
663
comma, and the name of the enclosing procedure.  The first name is local
664
to the scope specified, and seems to be redundant with the name of the
665
symbol (before the `:').  This feature is used by GCC, and presumably
666
Pascal, Modula-2, etc., compilers, for nested functions.
667
 
668
   If procedures are nested more than one level deep, only the
669
immediately containing scope is specified.  For example, this code:
670
 
671
     int
672
     foo (int x)
673
     {
674
       int bar (int y)
675
         {
676
           int baz (int z)
677
             {
678
               return x + y + z;
679
             }
680
           return baz (x + 2 * y);
681
         }
682
       return x + bar (3 * x);
683
     }
684
 
685
produces the stabs:
686
 
687
     .stabs "baz:f1,baz,bar",36,0,0,_baz.15         # 36 is N_FUN
688
     .stabs "bar:f1,bar,foo",36,0,0,_bar.12
689
     .stabs "foo:F1",36,0,0,_foo
690
 
691

692
File: stabs.info,  Node: Block Structure,  Next: Alternate Entry Points,  Prev: Nested Procedures,  Up: Program Structure
693
 
694
2.7 Block Structure
695
===================
696
 
697
The program's block structure is represented by the `N_LBRAC' (left
698
brace) and the `N_RBRAC' (right brace) stab types.  The variables
699
defined inside a block precede the `N_LBRAC' symbol for most compilers,
700
including GCC.  Other compilers, such as the Convex, Acorn RISC
701
machine, and Sun `acc' compilers, put the variables after the `N_LBRAC'
702
symbol.  The values of the `N_LBRAC' and `N_RBRAC' symbols are the
703
start and end addresses of the code of the block, respectively.  For
704
most machines, they are relative to the starting address of this source
705
file.  For the Gould NP1, they are absolute.  For stabs in sections
706
(*note Stab Sections::), they are relative to the function in which
707
they occur.
708
 
709
   The `N_LBRAC' and `N_RBRAC' stabs that describe the block scope of a
710
procedure are located after the `N_FUN' stab that represents the
711
procedure itself.
712
 
713
   Sun documents the desc field of `N_LBRAC' and `N_RBRAC' symbols as
714
containing the nesting level of the block.  However, dbx seems to not
715
care, and GCC always sets desc to zero.
716
 
717
   For XCOFF, block scope is indicated with `C_BLOCK' symbols.  If the
718
name of the symbol is `.bb', then it is the beginning of the block; if
719
the name of the symbol is `.be'; it is the end of the block.
720
 
721

722
File: stabs.info,  Node: Alternate Entry Points,  Prev: Block Structure,  Up: Program Structure
723
 
724
2.8 Alternate Entry Points
725
==========================
726
 
727
Some languages, like Fortran, have the ability to enter procedures at
728
some place other than the beginning.  One can declare an alternate entry
729
point.  The `N_ENTRY' stab is for this; however, the Sun FORTRAN
730
compiler doesn't use it.  According to AIX documentation, only the name
731
of a `C_ENTRY' stab is significant; the address of the alternate entry
732
point comes from the corresponding external symbol.  A previous
733
revision of this document said that the value of an `N_ENTRY' stab was
734
the address of the alternate entry point, but I don't know the source
735
for that information.
736
 
737

738
File: stabs.info,  Node: Constants,  Next: Variables,  Prev: Program Structure,  Up: Top
739
 
740
3 Constants
741
***********
742
 
743
The `c' symbol descriptor indicates that this stab represents a
744
constant.  This symbol descriptor is an exception to the general rule
745
that symbol descriptors are followed by type information.  Instead, it
746
is followed by `=' and one of the following:
747
 
748
`b VALUE'
749
     Boolean constant.  VALUE is a numeric value; I assume it is 0 for
750
     false or 1 for true.
751
 
752
`c VALUE'
753
     Character constant.  VALUE is the numeric value of the constant.
754
 
755
`e TYPE-INFORMATION , VALUE'
756
     Constant whose value can be represented as integral.
757
     TYPE-INFORMATION is the type of the constant, as it would appear
758
     after a symbol descriptor (*note String Field::).  VALUE is the
759
     numeric value of the constant.  GDB 4.9 does not actually get the
760
     right value if VALUE does not fit in a host `int', but it does not
761
     do anything violent, and future debuggers could be extended to
762
     accept integers of any size (whether unsigned or not).  This
763
     constant type is usually documented as being only for enumeration
764
     constants, but GDB has never imposed that restriction; I don't
765
     know about other debuggers.
766
 
767
`i VALUE'
768
     Integer constant.  VALUE is the numeric value.  The type is some
769
     sort of generic integer type (for GDB, a host `int'); to specify
770
     the type explicitly, use `e' instead.
771
 
772
`r VALUE'
773
     Real constant.  VALUE is the real value, which can be `INF'
774
     (optionally preceded by a sign) for infinity, `QNAN' for a quiet
775
     NaN (not-a-number), or `SNAN' for a signalling NaN.  If it is a
776
     normal number the format is that accepted by the C library function
777
     `atof'.
778
 
779
`s STRING'
780
     String constant.  STRING is a string enclosed in either `'' (in
781
     which case `'' characters within the string are represented as
782
     `\'' or `"' (in which case `"' characters within the string are
783
     represented as `\"').
784
 
785
`S TYPE-INFORMATION , ELEMENTS , BITS , PATTERN'
786
     Set constant.  TYPE-INFORMATION is the type of the constant, as it
787
     would appear after a symbol descriptor (*note String Field::).
788
     ELEMENTS is the number of elements in the set (does this means how
789
     many bits of PATTERN are actually used, which would be redundant
790
     with the type, or perhaps the number of bits set in PATTERN?  I
791
     don't get it), BITS is the number of bits in the constant (meaning
792
     it specifies the length of PATTERN, I think), and PATTERN is a
793
     hexadecimal representation of the set.  AIX documentation refers
794
     to a limit of 32 bytes, but I see no reason why this limit should
795
     exist.  This form could probably be used for arbitrary constants,
796
     not just sets; the only catch is that PATTERN should be understood
797
     to be target, not host, byte order and format.
798
 
799
   The boolean, character, string, and set constants are not supported
800
by GDB 4.9, but it ignores them.  GDB 4.8 and earlier gave an error
801
message and refused to read symbols from the file containing the
802
constants.
803
 
804
   The above information is followed by `;'.
805
 
806

807
File: stabs.info,  Node: Variables,  Next: Types,  Prev: Constants,  Up: Top
808
 
809
4 Variables
810
***********
811
 
812
Different types of stabs describe the various ways that variables can be
813
allocated: on the stack, globally, in registers, in common blocks,
814
statically, or as arguments to a function.
815
 
816
* Menu:
817
 
818
* Stack Variables::             Variables allocated on the stack.
819
* Global Variables::            Variables used by more than one source file.
820
* Register Variables::          Variables in registers.
821
* Common Blocks::               Variables statically allocated together.
822
* Statics::                     Variables local to one source file.
823
* Based Variables::             Fortran pointer based variables.
824
* Parameters::                  Variables for arguments to functions.
825
 
826

827
File: stabs.info,  Node: Stack Variables,  Next: Global Variables,  Up: Variables
828
 
829
4.1 Automatic Variables Allocated on the Stack
830
==============================================
831
 
832
If a variable's scope is local to a function and its lifetime is only as
833
long as that function executes (C calls such variables "automatic"), it
834
can be allocated in a register (*note Register Variables::) or on the
835
stack.
836
 
837
   Each variable allocated on the stack has a stab with the symbol
838
descriptor omitted.  Since type information should begin with a digit,
839
`-', or `(', only those characters precluded from being used for symbol
840
descriptors.  However, the Acorn RISC machine (ARM) is said to get this
841
wrong: it puts out a mere type definition here, without the preceding
842
`TYPE-NUMBER='.  This is a bad idea; there is no guarantee that type
843
descriptors are distinct from symbol descriptors.  Stabs for stack
844
variables use the `N_LSYM' stab type, or `C_LSYM' for XCOFF.
845
 
846
   The value of the stab is the offset of the variable within the local
847
variables.  On most machines this is an offset from the frame pointer
848
and is negative.  The location of the stab specifies which block it is
849
defined in; see *note Block Structure::.
850
 
851
   For example, the following C code:
852
 
853
     int
854
     main ()
855
     {
856
       int x;
857
     }
858
 
859
   produces the following stabs:
860
 
861
     .stabs "main:F1",36,0,0,_main   # 36 is N_FUN
862
     .stabs "x:1",128,0,0,-12        # 128 is N_LSYM
863
     .stabn 192,0,0,LBB2             # 192 is N_LBRAC
864
     .stabn 224,0,0,LBE2             # 224 is N_RBRAC
865
 
866
   See *note Procedures:: for more information on the `N_FUN' stab, and
867
*note Block Structure:: for more information on the `N_LBRAC' and
868
`N_RBRAC' stabs.
869
 
870

871
File: stabs.info,  Node: Global Variables,  Next: Register Variables,  Prev: Stack Variables,  Up: Variables
872
 
873
4.2 Global Variables
874
====================
875
 
876
A variable whose scope is not specific to just one source file is
877
represented by the `G' symbol descriptor.  These stabs use the `N_GSYM'
878
stab type (C_GSYM for XCOFF).  The type information for the stab (*note
879
String Field::) gives the type of the variable.
880
 
881
   For example, the following source code:
882
 
883
     char g_foo = 'c';
884
 
885
yields the following assembly code:
886
 
887
     .stabs "g_foo:G2",32,0,0,0     # 32 is N_GSYM
888
          .global _g_foo
889
          .data
890
     _g_foo:
891
          .byte 99
892
 
893
   The address of the variable represented by the `N_GSYM' is not
894
contained in the `N_GSYM' stab.  The debugger gets this information
895
from the external symbol for the global variable.  In the example above,
896
the `.global _g_foo' and `_g_foo:' lines tell the assembler to produce
897
an external symbol.
898
 
899
   Some compilers, like GCC, output `N_GSYM' stabs only once, where the
900
variable is defined.  Other compilers, like SunOS4 /bin/cc, output a
901
`N_GSYM' stab for each compilation unit which references the variable.
902
 
903

904
File: stabs.info,  Node: Register Variables,  Next: Common Blocks,  Prev: Global Variables,  Up: Variables
905
 
906
4.3 Register Variables
907
======================
908
 
909
Register variables have their own stab type, `N_RSYM' (`C_RSYM' for
910
XCOFF), and their own symbol descriptor, `r'.  The stab's value is the
911
number of the register where the variable data will be stored.
912
 
913
   AIX defines a separate symbol descriptor `d' for floating point
914
registers.  This seems unnecessary; why not just just give floating
915
point registers different register numbers?  I have not verified whether
916
the compiler actually uses `d'.
917
 
918
   If the register is explicitly allocated to a global variable, but not
919
initialized, as in:
920
 
921
     register int g_bar asm ("%g5");
922
 
923
then the stab may be emitted at the end of the object file, with the
924
other bss symbols.
925
 
926

927
File: stabs.info,  Node: Common Blocks,  Next: Statics,  Prev: Register Variables,  Up: Variables
928
 
929
4.4 Common Blocks
930
=================
931
 
932
A common block is a statically allocated section of memory which can be
933
referred to by several source files.  It may contain several variables.
934
I believe Fortran is the only language with this feature.
935
 
936
   A `N_BCOMM' stab begins a common block and an `N_ECOMM' stab ends
937
it.  The only field that is significant in these two stabs is the
938
string, which names a normal (non-debugging) symbol that gives the
939
address of the common block.  According to IBM documentation, only the
940
`N_BCOMM' has the name of the common block (even though their compiler
941
actually puts it both places).
942
 
943
   The stabs for the members of the common block are between the
944
`N_BCOMM' and the `N_ECOMM'; the value of each stab is the offset
945
within the common block of that variable.  IBM uses the `C_ECOML' stab
946
type, and there is a corresponding `N_ECOML' stab type, but Sun's
947
Fortran compiler uses `N_GSYM' instead.  The variables within a common
948
block use the `V' symbol descriptor (I believe this is true of all
949
Fortran variables).  Other stabs (at least type declarations using
950
`C_DECL') can also be between the `N_BCOMM' and the `N_ECOMM'.
951
 
952

953
File: stabs.info,  Node: Statics,  Next: Based Variables,  Prev: Common Blocks,  Up: Variables
954
 
955
4.5 Static Variables
956
====================
957
 
958
Initialized static variables are represented by the `S' and `V' symbol
959
descriptors.  `S' means file scope static, and `V' means procedure
960
scope static.  One exception: in XCOFF, IBM's xlc compiler always uses
961
`V', and whether it is file scope or not is distinguished by whether
962
the stab is located within a function.
963
 
964
   In a.out files, `N_STSYM' means the data section, `N_FUN' means the
965
text section, and `N_LCSYM' means the bss section.  For those systems
966
with a read-only data section separate from the text section (Solaris),
967
`N_ROSYM' means the read-only data section.
968
 
969
   For example, the source lines:
970
 
971
     static const int var_const = 5;
972
     static int var_init = 2;
973
     static int var_noinit;
974
 
975
yield the following stabs:
976
 
977
     .stabs "var_const:S1",36,0,0,_var_const      # 36 is N_FUN
978
     ...
979
     .stabs "var_init:S1",38,0,0,_var_init        # 38 is N_STSYM
980
     ...
981
     .stabs "var_noinit:S1",40,0,0,_var_noinit    # 40 is N_LCSYM
982
 
983
   In XCOFF files, the stab type need not indicate the section;
984
`C_STSYM' can be used for all statics.  Also, each static variable is
985
enclosed in a static block.  A `C_BSTAT' (emitted with a `.bs'
986
assembler directive) symbol begins the static block; its value is the
987
symbol number of the csect symbol whose value is the address of the
988
static block, its section is the section of the variables in that
989
static block, and its name is `.bs'.  A `C_ESTAT' (emitted with a `.es'
990
assembler directive) symbol ends the static block; its name is `.es'
991
and its value and section are ignored.
992
 
993
   In ECOFF files, the storage class is used to specify the section, so
994
the stab type need not indicate the section.
995
 
996
   In ELF files, for the SunPRO compiler version 2.0.1, symbol
997
descriptor `S' means that the address is absolute (the linker relocates
998
it) and symbol descriptor `V' means that the address is relative to the
999
start of the relevant section for that compilation unit.  SunPRO has
1000
plans to have the linker stop relocating stabs; I suspect that their the
1001
debugger gets the address from the corresponding ELF (not stab) symbol.
1002
I'm not sure how to find which symbol of that name is the right one.
1003
The clean way to do all this would be to have the value of a symbol
1004
descriptor `S' symbol be an offset relative to the start of the file,
1005
just like everything else, but that introduces obvious compatibility
1006
problems.  For more information on linker stab relocation, *Note ELF
1007
Linker Relocation::.
1008
 
1009

1010
File: stabs.info,  Node: Based Variables,  Next: Parameters,  Prev: Statics,  Up: Variables
1011
 
1012
4.6 Fortran Based Variables
1013
===========================
1014
 
1015
Fortran (at least, the Sun and SGI dialects of FORTRAN-77) has a feature
1016
which allows allocating arrays with `malloc', but which avoids blurring
1017
the line between arrays and pointers the way that C does.  In stabs
1018
such a variable uses the `b' symbol descriptor.
1019
 
1020
   For example, the Fortran declarations
1021
 
1022
     real foo, foo10(10), foo10_5(10,5)
1023
     pointer (foop, foo)
1024
     pointer (foo10p, foo10)
1025
     pointer (foo105p, foo10_5)
1026
 
1027
   produce the stabs
1028
 
1029
     foo:b6
1030
     foo10:bar3;1;10;6
1031
     foo10_5:bar3;1;5;ar3;1;10;6
1032
 
1033
   In this example, `real' is type 6 and type 3 is an integral type
1034
which is the type of the subscripts of the array (probably `integer').
1035
 
1036
   The `b' symbol descriptor is like `V' in that it denotes a
1037
statically allocated symbol whose scope is local to a function; see
1038
*Note Statics::.  The value of the symbol, instead of being the address
1039
of the variable itself, is the address of a pointer to that variable.
1040
So in the above example, the value of the `foo' stab is the address of
1041
a pointer to a real, the value of the `foo10' stab is the address of a
1042
pointer to a 10-element array of reals, and the value of the `foo10_5'
1043
stab is the address of a pointer to a 5-element array of 10-element
1044
arrays of reals.
1045
 
1046

1047
File: stabs.info,  Node: Parameters,  Prev: Based Variables,  Up: Variables
1048
 
1049
4.7 Parameters
1050
==============
1051
 
1052
Formal parameters to a function are represented by a stab (or sometimes
1053
two; see below) for each parameter.  The stabs are in the order in which
1054
the debugger should print the parameters (i.e., the order in which the
1055
parameters are declared in the source file).  The exact form of the stab
1056
depends on how the parameter is being passed.
1057
 
1058
   Parameters passed on the stack use the symbol descriptor `p' and the
1059
`N_PSYM' symbol type (or `C_PSYM' for XCOFF).  The value of the symbol
1060
is an offset used to locate the parameter on the stack; its exact
1061
meaning is machine-dependent, but on most machines it is an offset from
1062
the frame pointer.
1063
 
1064
   As a simple example, the code:
1065
 
1066
     main (argc, argv)
1067
          int argc;
1068
          char **argv;
1069
 
1070
   produces the stabs:
1071
 
1072
     .stabs "main:F1",36,0,0,_main                 # 36 is N_FUN
1073
     .stabs "argc:p1",160,0,0,68                   # 160 is N_PSYM
1074
     .stabs "argv:p20=*21=*2",160,0,0,72
1075
 
1076
   The type definition of `argv' is interesting because it contains
1077
several type definitions.  Type 21 is pointer to type 2 (char) and
1078
`argv' (type 20) is pointer to type 21.
1079
 
1080
   The following symbol descriptors are also said to go with `N_PSYM'.
1081
The value of the symbol is said to be an offset from the argument
1082
pointer (I'm not sure whether this is true or not).
1083
 
1084
     pP (<>)
1085
     pF Fortran function parameter
1086
     X  (function result variable)
1087
 
1088
* Menu:
1089
 
1090
* Register Parameters::
1091
* Local Variable Parameters::
1092
* Reference Parameters::
1093
* Conformant Arrays::
1094
 
1095

1096
File: stabs.info,  Node: Register Parameters,  Next: Local Variable Parameters,  Up: Parameters
1097
 
1098
4.7.1 Passing Parameters in Registers
1099
-------------------------------------
1100
 
1101
If the parameter is passed in a register, then traditionally there are
1102
two symbols for each argument:
1103
 
1104
     .stabs "arg:p1" . . .       ; N_PSYM
1105
     .stabs "arg:r1" . . .       ; N_RSYM
1106
 
1107
   Debuggers use the second one to find the value, and the first one to
1108
know that it is an argument.
1109
 
1110
   Because that approach is kind of ugly, some compilers use symbol
1111
descriptor `P' or `R' to indicate an argument which is in a register.
1112
Symbol type `C_RPSYM' is used in XCOFF and `N_RSYM' is used otherwise.
1113
The symbol's value is the register number.  `P' and `R' mean the same
1114
thing; the difference is that `P' is a GNU invention and `R' is an IBM
1115
(XCOFF) invention.  As of version 4.9, GDB should handle either one.
1116
 
1117
   There is at least one case where GCC uses a `p' and `r' pair rather
1118
than `P'; this is where the argument is passed in the argument list and
1119
then loaded into a register.
1120
 
1121
   According to the AIX documentation, symbol descriptor `D' is for a
1122
parameter passed in a floating point register.  This seems
1123
unnecessary--why not just use `R' with a register number which
1124
indicates that it's a floating point register?  I haven't verified
1125
whether the system actually does what the documentation indicates.
1126
 
1127
   On the sparc and hppa, for a `P' symbol whose type is a structure or
1128
union, the register contains the address of the structure.  On the
1129
sparc, this is also true of a `p' and `r' pair (using Sun `cc') or a
1130
`p' symbol.  However, if a (small) structure is really in a register,
1131
`r' is used.  And, to top it all off, on the hppa it might be a
1132
structure which was passed on the stack and loaded into a register and
1133
for which there is a `p' and `r' pair!  I believe that symbol
1134
descriptor `i' is supposed to deal with this case (it is said to mean
1135
"value parameter by reference, indirect access"; I don't know the
1136
source for this information), but I don't know details or what
1137
compilers or debuggers use it, if any (not GDB or GCC).  It is not
1138
clear to me whether this case needs to be dealt with differently than
1139
parameters passed by reference (*note Reference Parameters::).
1140
 
1141

1142
File: stabs.info,  Node: Local Variable Parameters,  Next: Reference Parameters,  Prev: Register Parameters,  Up: Parameters
1143
 
1144
4.7.2 Storing Parameters as Local Variables
1145
-------------------------------------------
1146
 
1147
There is a case similar to an argument in a register, which is an
1148
argument that is actually stored as a local variable.  Sometimes this
1149
happens when the argument was passed in a register and then the compiler
1150
stores it as a local variable.  If possible, the compiler should claim
1151
that it's in a register, but this isn't always done.
1152
 
1153
   If a parameter is passed as one type and converted to a smaller type
1154
by the prologue (for example, the parameter is declared as a `float',
1155
but the calling conventions specify that it is passed as a `double'),
1156
then GCC2 (sometimes) uses a pair of symbols.  The first symbol uses
1157
symbol descriptor `p' and the type which is passed.  The second symbol
1158
has the type and location which the parameter actually has after the
1159
prologue.  For example, suppose the following C code appears with no
1160
prototypes involved:
1161
 
1162
     void
1163
     subr (f)
1164
          float f;
1165
     {
1166
 
1167
   if `f' is passed as a double at stack offset 8, and the prologue
1168
converts it to a float in register number 0, then the stabs look like:
1169
 
1170
     .stabs "f:p13",160,0,3,8   # 160 is `N_PSYM', here 13 is `double'
1171
     .stabs "f:r12",64,0,3,0    # 64 is `N_RSYM', here 12 is `float'
1172
 
1173
   In both stabs 3 is the line number where `f' is declared (*note Line
1174
Numbers::).
1175
 
1176
   GCC, at least on the 960, has another solution to the same problem.
1177
It uses a single `p' symbol descriptor for an argument which is stored
1178
as a local variable but uses `N_LSYM' instead of `N_PSYM'.  In this
1179
case, the value of the symbol is an offset relative to the local
1180
variables for that function, not relative to the arguments; on some
1181
machines those are the same thing, but not on all.
1182
 
1183
   On the VAX or on other machines in which the calling convention
1184
includes the number of words of arguments actually passed, the debugger
1185
(GDB at least) uses the parameter symbols to keep track of whether it
1186
needs to print nameless arguments in addition to the formal parameters
1187
which it has printed because each one has a stab.  For example, in
1188
 
1189
     extern int fprintf (FILE *stream, char *format, ...);
1190
     ...
1191
     fprintf (stdout, "%d\n", x);
1192
 
1193
   there are stabs for `stream' and `format'.  On most machines, the
1194
debugger can only print those two arguments (because it has no way of
1195
knowing that additional arguments were passed), but on the VAX or other
1196
machines with a calling convention which indicates the number of words
1197
of arguments, the debugger can print all three arguments.  To do so,
1198
the parameter symbol (symbol descriptor `p') (not necessarily `r' or
1199
symbol descriptor omitted symbols) needs to contain the actual type as
1200
passed (for example, `double' not `float' if it is passed as a double
1201
and converted to a float).
1202
 
1203

1204
File: stabs.info,  Node: Reference Parameters,  Next: Conformant Arrays,  Prev: Local Variable Parameters,  Up: Parameters
1205
 
1206
4.7.3 Passing Parameters by Reference
1207
-------------------------------------
1208
 
1209
If the parameter is passed by reference (e.g., Pascal `VAR'
1210
parameters), then the symbol descriptor is `v' if it is in the argument
1211
list, or `a' if it in a register.  Other than the fact that these
1212
contain the address of the parameter rather than the parameter itself,
1213
they are identical to `p' and `R', respectively.  I believe `a' is an
1214
AIX invention; `v' is supported by all stabs-using systems as far as I
1215
know.
1216
 
1217

1218
File: stabs.info,  Node: Conformant Arrays,  Prev: Reference Parameters,  Up: Parameters
1219
 
1220
4.7.4 Passing Conformant Array Parameters
1221
-----------------------------------------
1222
 
1223
Conformant arrays are a feature of Modula-2, and perhaps other
1224
languages, in which the size of an array parameter is not known to the
1225
called function until run-time.  Such parameters have two stabs: a `x'
1226
for the array itself, and a `C', which represents the size of the
1227
array.  The value of the `x' stab is the offset in the argument list
1228
where the address of the array is stored (it this right?  it is a
1229
guess); the value of the `C' stab is the offset in the argument list
1230
where the size of the array (in elements? in bytes?) is stored.
1231
 
1232

1233
File: stabs.info,  Node: Types,  Next: Macro define and undefine,  Prev: Variables,  Up: Top
1234
 
1235
5 Defining Types
1236
****************
1237
 
1238
The examples so far have described types as references to previously
1239
defined types, or defined in terms of subranges of or pointers to
1240
previously defined types.  This chapter describes the other type
1241
descriptors that may follow the `=' in a type definition.
1242
 
1243
* Menu:
1244
 
1245
* Builtin Types::               Integers, floating point, void, etc.
1246
* Miscellaneous Types::         Pointers, sets, files, etc.
1247
* Cross-References::            Referring to a type not yet defined.
1248
* Subranges::                   A type with a specific range.
1249
* Arrays::                      An aggregate type of same-typed elements.
1250
* Strings::                     Like an array but also has a length.
1251
* Enumerations::                Like an integer but the values have names.
1252
* Structures::                  An aggregate type of different-typed elements.
1253
* Typedefs::                    Giving a type a name.
1254
* Unions::                      Different types sharing storage.
1255
* Function Types::
1256
 
1257

1258
File: stabs.info,  Node: Builtin Types,  Next: Miscellaneous Types,  Up: Types
1259
 
1260
5.1 Builtin Types
1261
=================
1262
 
1263
Certain types are built in (`int', `short', `void', `float', etc.); the
1264
debugger recognizes these types and knows how to handle them.  Thus,
1265
don't be surprised if some of the following ways of specifying builtin
1266
types do not specify everything that a debugger would need to know
1267
about the type--in some cases they merely specify enough information to
1268
distinguish the type from other types.
1269
 
1270
   The traditional way to define builtin types is convoluted, so new
1271
ways have been invented to describe them.  Sun's `acc' uses special
1272
builtin type descriptors (`b' and `R'), and IBM uses negative type
1273
numbers.  GDB accepts all three ways, as of version 4.8; dbx just
1274
accepts the traditional builtin types and perhaps one of the other two
1275
formats.  The following sections describe each of these formats.
1276
 
1277
* Menu:
1278
 
1279
* Traditional Builtin Types::   Put on your seat belts and prepare for kludgery
1280
* Builtin Type Descriptors::    Builtin types with special type descriptors
1281
* Negative Type Numbers::       Builtin types using negative type numbers
1282
 
1283

1284
File: stabs.info,  Node: Traditional Builtin Types,  Next: Builtin Type Descriptors,  Up: Builtin Types
1285
 
1286
5.1.1 Traditional Builtin Types
1287
-------------------------------
1288
 
1289
This is the traditional, convoluted method for defining builtin types.
1290
There are several classes of such type definitions: integer, floating
1291
point, and `void'.
1292
 
1293
* Menu:
1294
 
1295
* Traditional Integer Types::
1296
* Traditional Other Types::
1297
 
1298

1299
File: stabs.info,  Node: Traditional Integer Types,  Next: Traditional Other Types,  Up: Traditional Builtin Types
1300
 
1301
5.1.1.1 Traditional Integer Types
1302
.................................
1303
 
1304
Often types are defined as subranges of themselves.  If the bounding
1305
values fit within an `int', then they are given normally.  For example:
1306
 
1307
     .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0    # 128 is N_LSYM
1308
     .stabs "char:t2=r2;0;127;",128,0,0,0
1309
 
1310
   Builtin types can also be described as subranges of `int':
1311
 
1312
     .stabs "unsigned short:t6=r1;0;65535;",128,0,0,0
1313
 
1314
   If the lower bound of a subrange is 0 and the upper bound is -1, the
1315
type is an unsigned integral type whose bounds are too big to describe
1316
in an `int'.  Traditionally this is only used for `unsigned int' and
1317
`unsigned long':
1318
 
1319
     .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
1320
 
1321
   For larger types, GCC 2.4.5 puts out bounds in octal, with one or
1322
more leading zeroes.  In this case a negative bound consists of a number
1323
which is a 1 bit (for the sign bit) followed by a 0 bit for each bit in
1324
the number (except the sign bit), and a positive bound is one which is a
1325
1 bit for each bit in the number (except possibly the sign bit).  All
1326
known versions of dbx and GDB version 4 accept this (at least in the
1327
sense of not refusing to process the file), but GDB 3.5 refuses to read
1328
the whole file containing such symbols.  So GCC 2.3.3 did not output the
1329
proper size for these types.  As an example of octal bounds, the string
1330
fields of the stabs for 64 bit integer types look like:
1331
 
1332
     long int:t3=r1;001000000000000000000000;000777777777777777777777;
1333
     long unsigned int:t5=r1;000000000000000000000000;001777777777777777777777;
1334
 
1335
   If the lower bound of a subrange is 0 and the upper bound is
1336
negative, the type is an unsigned integral type whose size in bytes is
1337
the absolute value of the upper bound.  I believe this is a Convex
1338
convention for `unsigned long long'.
1339
 
1340
   If the lower bound of a subrange is negative and the upper bound is
1341
0, the type is a signed integral type whose size in bytes is the
1342
absolute value of the lower bound.  I believe this is a Convex
1343
convention for `long long'.  To distinguish this from a legitimate
1344
subrange, the type should be a subrange of itself.  I'm not sure whether
1345
this is the case for Convex.
1346
 
1347

1348
File: stabs.info,  Node: Traditional Other Types,  Prev: Traditional Integer Types,  Up: Traditional Builtin Types
1349
 
1350
5.1.1.2 Traditional Other Types
1351
...............................
1352
 
1353
If the upper bound of a subrange is 0 and the lower bound is positive,
1354
the type is a floating point type, and the lower bound of the subrange
1355
indicates the number of bytes in the type:
1356
 
1357
     .stabs "float:t12=r1;4;0;",128,0,0,0
1358
     .stabs "double:t13=r1;8;0;",128,0,0,0
1359
 
1360
   However, GCC writes `long double' the same way it writes `double',
1361
so there is no way to distinguish.
1362
 
1363
     .stabs "long double:t14=r1;8;0;",128,0,0,0
1364
 
1365
   Complex types are defined the same way as floating-point types;
1366
there is no way to distinguish a single-precision complex from a
1367
double-precision floating-point type.
1368
 
1369
   The C `void' type is defined as itself:
1370
 
1371
     .stabs "void:t15=15",128,0,0,0
1372
 
1373
   I'm not sure how a boolean type is represented.
1374
 
1375

1376
File: stabs.info,  Node: Builtin Type Descriptors,  Next: Negative Type Numbers,  Prev: Traditional Builtin Types,  Up: Builtin Types
1377
 
1378
5.1.2 Defining Builtin Types Using Builtin Type Descriptors
1379
-----------------------------------------------------------
1380
 
1381
This is the method used by Sun's `acc' for defining builtin types.
1382
These are the type descriptors to define builtin types:
1383
 
1384
`b SIGNED CHAR-FLAG WIDTH ; OFFSET ; NBITS ;'
1385
     Define an integral type.  SIGNED is `u' for unsigned or `s' for
1386
     signed.  CHAR-FLAG is `c' which indicates this is a character
1387
     type, or is omitted.  I assume this is to distinguish an integral
1388
     type from a character type of the same size, for example it might
1389
     make sense to set it for the C type `wchar_t' so the debugger can
1390
     print such variables differently (Solaris does not do this).  Sun
1391
     sets it on the C types `signed char' and `unsigned char' which
1392
     arguably is wrong.  WIDTH and OFFSET appear to be for small
1393
     objects stored in larger ones, for example a `short' in an `int'
1394
     register.  WIDTH is normally the number of bytes in the type.
1395
     OFFSET seems to always be zero.  NBITS is the number of bits in
1396
     the type.
1397
 
1398
     Note that type descriptor `b' used for builtin types conflicts with
1399
     its use for Pascal space types (*note Miscellaneous Types::); they
1400
     can be distinguished because the character following the type
1401
     descriptor will be a digit, `(', or `-' for a Pascal space type, or
1402
     `u' or `s' for a builtin type.
1403
 
1404
`w'
1405
     Documented by AIX to define a wide character type, but their
1406
     compiler actually uses negative type numbers (*note Negative Type
1407
     Numbers::).
1408
 
1409
`R FP-TYPE ; BYTES ;'
1410
     Define a floating point type.  FP-TYPE has one of the following
1411
     values:
1412
 
1413
    `1 (NF_SINGLE)'
1414
          IEEE 32-bit (single precision) floating point format.
1415
 
1416
    `2 (NF_DOUBLE)'
1417
          IEEE 64-bit (double precision) floating point format.
1418
 
1419
    `3 (NF_COMPLEX)'
1420
 
1421
    `4 (NF_COMPLEX16)'
1422
 
1423
    `5 (NF_COMPLEX32)'
1424
          These are for complex numbers.  A comment in the GDB source
1425
          describes them as Fortran `complex', `double complex', and
1426
          `complex*16', respectively, but what does that mean?  (i.e.,
1427
          Single precision?  Double precision?).
1428
 
1429
    `6 (NF_LDOUBLE)'
1430
          Long double.  This should probably only be used for Sun format
1431
          `long double', and new codes should be used for other floating
1432
          point formats (`NF_DOUBLE' can be used if a `long double' is
1433
          really just an IEEE double, of course).
1434
 
1435
     BYTES is the number of bytes occupied by the type.  This allows a
1436
     debugger to perform some operations with the type even if it
1437
     doesn't understand FP-TYPE.
1438
 
1439
`g TYPE-INFORMATION ; NBITS'
1440
     Documented by AIX to define a floating type, but their compiler
1441
     actually uses negative type numbers (*note Negative Type
1442
     Numbers::).
1443
 
1444
`c TYPE-INFORMATION ; NBITS'
1445
     Documented by AIX to define a complex type, but their compiler
1446
     actually uses negative type numbers (*note Negative Type
1447
     Numbers::).
1448
 
1449
   The C `void' type is defined as a signed integral type 0 bits long:
1450
     .stabs "void:t19=bs0;0;0",128,0,0,0
1451
   The Solaris compiler seems to omit the trailing semicolon in this
1452
case.  Getting sloppy in this way is not a swift move because if a type
1453
is embedded in a more complex expression it is necessary to be able to
1454
tell where it ends.
1455
 
1456
   I'm not sure how a boolean type is represented.
1457
 
1458

1459
File: stabs.info,  Node: Negative Type Numbers,  Prev: Builtin Type Descriptors,  Up: Builtin Types
1460
 
1461
5.1.3 Negative Type Numbers
1462
---------------------------
1463
 
1464
This is the method used in XCOFF for defining builtin types.  Since the
1465
debugger knows about the builtin types anyway, the idea of negative
1466
type numbers is simply to give a special type number which indicates
1467
the builtin type.  There is no stab defining these types.
1468
 
1469
   There are several subtle issues with negative type numbers.
1470
 
1471
   One is the size of the type.  A builtin type (for example the C types
1472
`int' or `long') might have different sizes depending on compiler
1473
options, the target architecture, the ABI, etc.  This issue doesn't
1474
come up for IBM tools since (so far) they just target the RS/6000; the
1475
sizes indicated below for each size are what the IBM RS/6000 tools use.
1476
To deal with differing sizes, either define separate negative type
1477
numbers for each size (which works but requires changing the debugger,
1478
and, unless you get both AIX dbx and GDB to accept the change,
1479
introduces an incompatibility), or use a type attribute (*note String
1480
Field::) to define a new type with the appropriate size (which merely
1481
requires a debugger which understands type attributes, like AIX dbx or
1482
GDB).  For example,
1483
 
1484
     .stabs "boolean:t10=@s8;-16",128,0,0,0
1485
 
1486
   defines an 8-bit boolean type, and
1487
 
1488
     .stabs "boolean:t10=@s64;-16",128,0,0,0
1489
 
1490
   defines a 64-bit boolean type.
1491
 
1492
   A similar issue is the format of the type.  This comes up most often
1493
for floating-point types, which could have various formats (particularly
1494
extended doubles, which vary quite a bit even among IEEE systems).
1495
Again, it is best to define a new negative type number for each
1496
different format; changing the format based on the target system has
1497
various problems.  One such problem is that the Alpha has both VAX and
1498
IEEE floating types.  One can easily imagine one library using the VAX
1499
types and another library in the same executable using the IEEE types.
1500
Another example is that the interpretation of whether a boolean is true
1501
or false can be based on the least significant bit, most significant
1502
bit, whether it is zero, etc., and different compilers (or different
1503
options to the same compiler) might provide different kinds of boolean.
1504
 
1505
   The last major issue is the names of the types.  The name of a given
1506
type depends _only_ on the negative type number given; these do not
1507
vary depending on the language, the target system, or anything else.
1508
One can always define separate type numbers--in the following list you
1509
will see for example separate `int' and `integer*4' types which are
1510
identical except for the name.  But compatibility can be maintained by
1511
not inventing new negative type numbers and instead just defining a new
1512
type with a new name.  For example:
1513
 
1514
     .stabs "CARDINAL:t10=-8",128,0,0,0
1515
 
1516
   Here is the list of negative type numbers.  The phrase "integral
1517
type" is used to mean twos-complement (I strongly suspect that all
1518
machines which use stabs use twos-complement; most machines use
1519
twos-complement these days).
1520
 
1521
`-1'
1522
     `int', 32 bit signed integral type.
1523
 
1524
`-2'
1525
     `char', 8 bit type holding a character.   Both GDB and dbx on AIX
1526
     treat this as signed.  GCC uses this type whether `char' is signed
1527
     or not, which seems like a bad idea.  The AIX compiler (`xlc')
1528
     seems to avoid this type; it uses -5 instead for `char'.
1529
 
1530
`-3'
1531
     `short', 16 bit signed integral type.
1532
 
1533
`-4'
1534
     `long', 32 bit signed integral type.
1535
 
1536
`-5'
1537
     `unsigned char', 8 bit unsigned integral type.
1538
 
1539
`-6'
1540
     `signed char', 8 bit signed integral type.
1541
 
1542
`-7'
1543
     `unsigned short', 16 bit unsigned integral type.
1544
 
1545
`-8'
1546
     `unsigned int', 32 bit unsigned integral type.
1547
 
1548
`-9'
1549
     `unsigned', 32 bit unsigned integral type.
1550
 
1551
`-10'
1552
     `unsigned long', 32 bit unsigned integral type.
1553
 
1554
`-11'
1555
     `void', type indicating the lack of a value.
1556
 
1557
`-12'
1558
     `float', IEEE single precision.
1559
 
1560
`-13'
1561
     `double', IEEE double precision.
1562
 
1563
`-14'
1564
     `long double', IEEE double precision.  The compiler claims the size
1565
     will increase in a future release, and for binary compatibility
1566
     you have to avoid using `long double'.  I hope when they increase
1567
     it they use a new negative type number.
1568
 
1569
`-15'
1570
     `integer'.  32 bit signed integral type.
1571
 
1572
`-16'
1573
     `boolean'.  32 bit type.  GDB and GCC assume that zero is false,
1574
     one is true, and other values have unspecified meaning.  I hope
1575
     this agrees with how the IBM tools use the type.
1576
 
1577
`-17'
1578
     `short real'.  IEEE single precision.
1579
 
1580
`-18'
1581
     `real'.  IEEE double precision.
1582
 
1583
`-19'
1584
     `stringptr'.  *Note Strings::.
1585
 
1586
`-20'
1587
     `character', 8 bit unsigned character type.
1588
 
1589
`-21'
1590
     `logical*1', 8 bit type.  This Fortran type has a split
1591
     personality in that it is used for boolean variables, but can also
1592
     be used for unsigned integers.  0 is false, 1 is true, and other
1593
     values are non-boolean.
1594
 
1595
`-22'
1596
     `logical*2', 16 bit type.  This Fortran type has a split
1597
     personality in that it is used for boolean variables, but can also
1598
     be used for unsigned integers.  0 is false, 1 is true, and other
1599
     values are non-boolean.
1600
 
1601
`-23'
1602
     `logical*4', 32 bit type.  This Fortran type has a split
1603
     personality in that it is used for boolean variables, but can also
1604
     be used for unsigned integers.  0 is false, 1 is true, and other
1605
     values are non-boolean.
1606
 
1607
`-24'
1608
     `logical', 32 bit type.  This Fortran type has a split personality
1609
     in that it is used for boolean variables, but can also be used for
1610
     unsigned integers.  0 is false, 1 is true, and other values are
1611
     non-boolean.
1612
 
1613
`-25'
1614
     `complex'.  A complex type consisting of two IEEE single-precision
1615
     floating point values.
1616
 
1617
`-26'
1618
     `complex'.  A complex type consisting of two IEEE double-precision
1619
     floating point values.
1620
 
1621
`-27'
1622
     `integer*1', 8 bit signed integral type.
1623
 
1624
`-28'
1625
     `integer*2', 16 bit signed integral type.
1626
 
1627
`-29'
1628
     `integer*4', 32 bit signed integral type.
1629
 
1630
`-30'
1631
     `wchar'.  Wide character, 16 bits wide, unsigned (what format?
1632
     Unicode?).
1633
 
1634
`-31'
1635
     `long long', 64 bit signed integral type.
1636
 
1637
`-32'
1638
     `unsigned long long', 64 bit unsigned integral type.
1639
 
1640
`-33'
1641
     `logical*8', 64 bit unsigned integral type.
1642
 
1643
`-34'
1644
     `integer*8', 64 bit signed integral type.
1645
 
1646

1647
File: stabs.info,  Node: Miscellaneous Types,  Next: Cross-References,  Prev: Builtin Types,  Up: Types
1648
 
1649
5.2 Miscellaneous Types
1650
=======================
1651
 
1652
`b TYPE-INFORMATION ; BYTES'
1653
     Pascal space type.  This is documented by IBM; what does it mean?
1654
 
1655
     This use of the `b' type descriptor can be distinguished from its
1656
     use for builtin integral types (*note Builtin Type Descriptors::)
1657
     because the character following the type descriptor is always a
1658
     digit, `(', or `-'.
1659
 
1660
`B TYPE-INFORMATION'
1661
     A volatile-qualified version of TYPE-INFORMATION.  This is a Sun
1662
     extension.  References and stores to a variable with a
1663
     volatile-qualified type must not be optimized or cached; they must
1664
     occur as the user specifies them.
1665
 
1666
`d TYPE-INFORMATION'
1667
     File of type TYPE-INFORMATION.  As far as I know this is only used
1668
     by Pascal.
1669
 
1670
`k TYPE-INFORMATION'
1671
     A const-qualified version of TYPE-INFORMATION.  This is a Sun
1672
     extension.  A variable with a const-qualified type cannot be
1673
     modified.
1674
 
1675
`M TYPE-INFORMATION ; LENGTH'
1676
     Multiple instance type.  The type seems to composed of LENGTH
1677
     repetitions of TYPE-INFORMATION, for example `character*3' is
1678
     represented by `M-2;3', where `-2' is a reference to a character
1679
     type (*note Negative Type Numbers::).  I'm not sure how this
1680
     differs from an array.  This appears to be a Fortran feature.
1681
     LENGTH is a bound, like those in range types; see *note
1682
     Subranges::.
1683
 
1684
`S TYPE-INFORMATION'
1685
     Pascal set type.  TYPE-INFORMATION must be a small type such as an
1686
     enumeration or a subrange, and the type is a bitmask whose length
1687
     is specified by the number of elements in TYPE-INFORMATION.
1688
 
1689
     In CHILL, if it is a bitstring instead of a set, also use the `S'
1690
     type attribute (*note String Field::).
1691
 
1692
`* TYPE-INFORMATION'
1693
     Pointer to TYPE-INFORMATION.
1694
 
1695

1696
File: stabs.info,  Node: Cross-References,  Next: Subranges,  Prev: Miscellaneous Types,  Up: Types
1697
 
1698
5.3 Cross-References to Other Types
1699
===================================
1700
 
1701
A type can be used before it is defined; one common way to deal with
1702
that situation is just to use a type reference to a type which has not
1703
yet been defined.
1704
 
1705
   Another way is with the `x' type descriptor, which is followed by
1706
`s' for a structure tag, `u' for a union tag, or `e' for a enumerator
1707
tag, followed by the name of the tag, followed by `:'.  If the name
1708
contains `::' between a `<' and `>' pair (for C++ templates), such a
1709
`::' does not end the name--only a single `:' ends the name; see *note
1710
Nested Symbols::.
1711
 
1712
   For example, the following C declarations:
1713
 
1714
     struct foo;
1715
     struct foo *bar;
1716
 
1717
produce:
1718
 
1719
     .stabs "bar:G16=*17=xsfoo:",32,0,0,0
1720
 
1721
   Not all debuggers support the `x' type descriptor, so on some
1722
machines GCC does not use it.  I believe that for the above example it
1723
would just emit a reference to type 17 and never define it, but I
1724
haven't verified that.
1725
 
1726
   Modula-2 imported types, at least on AIX, use the `i' type
1727
descriptor, which is followed by the name of the module from which the
1728
type is imported, followed by `:', followed by the name of the type.
1729
There is then optionally a comma followed by type information for the
1730
type.  This differs from merely naming the type (*note Typedefs::) in
1731
that it identifies the module; I don't understand whether the name of
1732
the type given here is always just the same as the name we are giving
1733
it, or whether this type descriptor is used with a nameless stab (*note
1734
String Field::), or what.  The symbol ends with `;'.
1735
 
1736

1737
File: stabs.info,  Node: Subranges,  Next: Arrays,  Prev: Cross-References,  Up: Types
1738
 
1739
5.4 Subrange Types
1740
==================
1741
 
1742
The `r' type descriptor defines a type as a subrange of another type.
1743
It is followed by type information for the type of which it is a
1744
subrange, a semicolon, an integral lower bound, a semicolon, an
1745
integral upper bound, and a semicolon.  The AIX documentation does not
1746
specify the trailing semicolon, in an effort to specify array indexes
1747
more cleanly, but a subrange which is not an array index has always
1748
included a trailing semicolon (*note Arrays::).
1749
 
1750
   Instead of an integer, either bound can be one of the following:
1751
 
1752
`A OFFSET'
1753
     The bound is passed by reference on the stack at offset OFFSET
1754
     from the argument list.  *Note Parameters::, for more information
1755
     on such offsets.
1756
 
1757
`T OFFSET'
1758
     The bound is passed by value on the stack at offset OFFSET from
1759
     the argument list.
1760
 
1761
`a REGISTER-NUMBER'
1762
     The bound is passed by reference in register number
1763
     REGISTER-NUMBER.
1764
 
1765
`t REGISTER-NUMBER'
1766
     The bound is passed by value in register number REGISTER-NUMBER.
1767
 
1768
`J'
1769
     There is no bound.
1770
 
1771
   Subranges are also used for builtin types; see *note Traditional
1772
Builtin Types::.
1773
 
1774

1775
File: stabs.info,  Node: Arrays,  Next: Strings,  Prev: Subranges,  Up: Types
1776
 
1777
5.5 Array Types
1778
===============
1779
 
1780
Arrays use the `a' type descriptor.  Following the type descriptor is
1781
the type of the index and the type of the array elements.  If the index
1782
type is a range type, it ends in a semicolon; otherwise (for example,
1783
if it is a type reference), there does not appear to be any way to tell
1784
where the types are separated.  In an effort to clean up this mess, IBM
1785
documents the two types as being separated by a semicolon, and a range
1786
type as not ending in a semicolon (but this is not right for range
1787
types which are not array indexes, *note Subranges::).  I think
1788
probably the best solution is to specify that a semicolon ends a range
1789
type, and that the index type and element type of an array are
1790
separated by a semicolon, but that if the index type is a range type,
1791
the extra semicolon can be omitted.  GDB (at least through version 4.9)
1792
doesn't support any kind of index type other than a range anyway; I'm
1793
not sure about dbx.
1794
 
1795
   It is well established, and widely used, that the type of the index,
1796
unlike most types found in the stabs, is merely a type definition, not
1797
type information (*note String Field::) (that is, it need not start with
1798
`TYPE-NUMBER=' if it is defining a new type).  According to a comment
1799
in GDB, this is also true of the type of the array elements; it gives
1800
`ar1;1;10;ar1;1;10;4' as a legitimate way to express a two dimensional
1801
array.  According to AIX documentation, the element type must be type
1802
information.  GDB accepts either.
1803
 
1804
   The type of the index is often a range type, expressed as the type
1805
descriptor `r' and some parameters.  It defines the size of the array.
1806
In the example below, the range `r1;0;2;' defines an index type which
1807
is a subrange of type 1 (integer), with a lower bound of 0 and an upper
1808
bound of 2.  This defines the valid range of subscripts of a
1809
three-element C array.
1810
 
1811
   For example, the definition:
1812
 
1813
     char char_vec[3] = {'a','b','c'};
1814
 
1815
produces the output:
1816
 
1817
     .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
1818
          .global _char_vec
1819
          .align 4
1820
     _char_vec:
1821
          .byte 97
1822
          .byte 98
1823
          .byte 99
1824
 
1825
   If an array is "packed", the elements are spaced more closely than
1826
normal, saving memory at the expense of speed.  For example, an array
1827
of 3-byte objects might, if unpacked, have each element aligned on a
1828
4-byte boundary, but if packed, have no padding.  One way to specify
1829
that something is packed is with type attributes (*note String
1830
Field::).  In the case of arrays, another is to use the `P' type
1831
descriptor instead of `a'.  Other than specifying a packed array, `P'
1832
is identical to `a'.
1833
 
1834
   An open array is represented by the `A' type descriptor followed by
1835
type information specifying the type of the array elements.
1836
 
1837
   An N-dimensional dynamic array is represented by
1838
 
1839
     D DIMENSIONS ; TYPE-INFORMATION
1840
 
1841
   DIMENSIONS is the number of dimensions; TYPE-INFORMATION specifies
1842
the type of the array elements.
1843
 
1844
   A subarray of an N-dimensional array is represented by
1845
 
1846
     E DIMENSIONS ; TYPE-INFORMATION
1847
 
1848
   DIMENSIONS is the number of dimensions; TYPE-INFORMATION specifies
1849
the type of the array elements.
1850
 
1851

1852
File: stabs.info,  Node: Strings,  Next: Enumerations,  Prev: Arrays,  Up: Types
1853
 
1854
5.6 Strings
1855
===========
1856
 
1857
Some languages, like C or the original Pascal, do not have string types,
1858
they just have related things like arrays of characters.  But most
1859
Pascals and various other languages have string types, which are
1860
indicated as follows:
1861
 
1862
`n TYPE-INFORMATION ; BYTES'
1863
     BYTES is the maximum length.  I'm not sure what TYPE-INFORMATION
1864
     is; I suspect that it means that this is a string of
1865
     TYPE-INFORMATION (thus allowing a string of integers, a string of
1866
     wide characters, etc., as well as a string of characters).  Not
1867
     sure what the format of this type is.  This is an AIX feature.
1868
 
1869
`z TYPE-INFORMATION ; BYTES'
1870
     Just like `n' except that this is a gstring, not an ordinary
1871
     string.  I don't know the difference.
1872
 
1873
`N'
1874
     Pascal Stringptr.  What is this?  This is an AIX feature.
1875
 
1876
   Languages, such as CHILL which have a string type which is basically
1877
just an array of characters use the `S' type attribute (*note String
1878
Field::).
1879
 
1880

1881
File: stabs.info,  Node: Enumerations,  Next: Structures,  Prev: Strings,  Up: Types
1882
 
1883
5.7 Enumerations
1884
================
1885
 
1886
Enumerations are defined with the `e' type descriptor.
1887
 
1888
   The source line below declares an enumeration type at file scope.
1889
The type definition is located after the `N_RBRAC' that marks the end of
1890
the previous procedure's block scope, and before the `N_FUN' that marks
1891
the beginning of the next procedure's block scope.  Therefore it does
1892
not describe a block local symbol, but a file local one.
1893
 
1894
   The source line:
1895
 
1896
     enum e_places {first,second=3,last};
1897
 
1898
generates the following stab:
1899
 
1900
     .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0
1901
 
1902
   The symbol descriptor (`T') says that the stab describes a
1903
structure, enumeration, or union tag.  The type descriptor `e',
1904
following the `22=' of the type definition narrows it down to an
1905
enumeration type.  Following the `e' is a list of the elements of the
1906
enumeration.  The format is `NAME:VALUE,'.  The list of elements ends
1907
with `;'.  The fact that VALUE is specified as an integer can cause
1908
problems if the value is large.  GCC 2.5.2 tries to output it in octal
1909
in that case with a leading zero, which is probably a good thing,
1910
although GDB 4.11 supports octal only in cases where decimal is
1911
perfectly good.  Negative decimal values are supported by both GDB and
1912
dbx.
1913
 
1914
   There is no standard way to specify the size of an enumeration type;
1915
it is determined by the architecture (normally all enumerations types
1916
are 32 bits).  Type attributes can be used to specify an enumeration
1917
type of another size for debuggers which support them; see *note String
1918
Field::.
1919
 
1920
   Enumeration types are unusual in that they define symbols for the
1921
enumeration values (`first', `second', and `third' in the above
1922
example), and even though these symbols are visible in the file as a
1923
whole (rather than being in a more local namespace like structure
1924
member names), they are defined in the type definition for the
1925
enumeration type rather than each having their own symbol.  In order to
1926
be fast, GDB will only get symbols from such types (in its initial scan
1927
of the stabs) if the type is the first thing defined after a `T' or `t'
1928
symbol descriptor (the above example fulfills this requirement).  If
1929
the type does not have a name, the compiler should emit it in a
1930
nameless stab (*note String Field::); GCC does this.
1931
 
1932

1933
File: stabs.info,  Node: Structures,  Next: Typedefs,  Prev: Enumerations,  Up: Types
1934
 
1935
5.8 Structures
1936
==============
1937
 
1938
The encoding of structures in stabs can be shown with an example.
1939
 
1940
   The following source code declares a structure tag and defines an
1941
instance of the structure in global scope. Then a `typedef' equates the
1942
structure tag with a new type.  Separate stabs are generated for the
1943
structure tag, the structure `typedef', and the structure instance.  The
1944
stabs for the tag and the `typedef' are emitted when the definitions are
1945
encountered.  Since the structure elements are not initialized, the
1946
stab and code for the structure variable itself is located at the end
1947
of the program in the bss section.
1948
 
1949
     struct s_tag {
1950
       int   s_int;
1951
       float s_float;
1952
       char  s_char_vec[8];
1953
       struct s_tag* s_next;
1954
     } g_an_s;
1955
 
1956
     typedef struct s_tag s_typedef;
1957
 
1958
   The structure tag has an `N_LSYM' stab type because, like the
1959
enumeration, the symbol has file scope.  Like the enumeration, the
1960
symbol descriptor is `T', for enumeration, structure, or tag type.  The
1961
type descriptor `s' following the `16=' of the type definition narrows
1962
the symbol type to structure.
1963
 
1964
   Following the `s' type descriptor is the number of bytes the
1965
structure occupies, followed by a description of each structure element.
1966
The structure element descriptions are of the form `NAME:TYPE, BIT
1967
OFFSET FROM THE START OF THE STRUCT, NUMBER OF BITS IN THE ELEMENT'.
1968
 
1969
     # 128 is N_LSYM
1970
     .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;
1971
             s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
1972
 
1973
   In this example, the first two structure elements are previously
1974
defined types.  For these, the type following the `NAME:' part of the
1975
element description is a simple type reference.  The other two structure
1976
elements are new types.  In this case there is a type definition
1977
embedded after the `NAME:'.  The type definition for the array element
1978
looks just like a type definition for a stand-alone array.  The
1979
`s_next' field is a pointer to the same kind of structure that the
1980
field is an element of.  So the definition of structure type 16
1981
contains a type definition for an element which is a pointer to type 16.
1982
 
1983
   If a field is a static member (this is a C++ feature in which a
1984
single variable appears to be a field of every structure of a given
1985
type) it still starts out with the field name, a colon, and the type,
1986
but then instead of a comma, bit position, comma, and bit size, there
1987
is a colon followed by the name of the variable which each such field
1988
refers to.
1989
 
1990
   If the structure has methods (a C++ feature), they follow the
1991
non-method fields; see *note Cplusplus::.
1992
 
1993

1994
File: stabs.info,  Node: Typedefs,  Next: Unions,  Prev: Structures,  Up: Types
1995
 
1996
5.9 Giving a Type a Name
1997
========================
1998
 
1999
To give a type a name, use the `t' symbol descriptor.  The type is
2000
specified by the type information (*note String Field::) for the stab.
2001
For example,
2002
 
2003
     .stabs "s_typedef:t16",128,0,0,0     # 128 is N_LSYM
2004
 
2005
   specifies that `s_typedef' refers to type number 16.  Such stabs
2006
have symbol type `N_LSYM' (or `C_DECL' for XCOFF).  (The Sun
2007
documentation mentions using `N_GSYM' in some cases).
2008
 
2009
   If you are specifying the tag name for a structure, union, or
2010
enumeration, use the `T' symbol descriptor instead.  I believe C is the
2011
only language with this feature.
2012
 
2013
   If the type is an opaque type (I believe this is a Modula-2 feature),
2014
AIX provides a type descriptor to specify it.  The type descriptor is
2015
`o' and is followed by a name.  I don't know what the name means--is it
2016
always the same as the name of the type, or is this type descriptor
2017
used with a nameless stab (*note String Field::)?  There optionally
2018
follows a comma followed by type information which defines the type of
2019
this type.  If omitted, a semicolon is used in place of the comma and
2020
the type information, and the type is much like a generic pointer
2021
type--it has a known size but little else about it is specified.
2022
 
2023

2024
File: stabs.info,  Node: Unions,  Next: Function Types,  Prev: Typedefs,  Up: Types
2025
 
2026
5.10 Unions
2027
===========
2028
 
2029
     union u_tag {
2030
       int  u_int;
2031
       float u_float;
2032
       char* u_char;
2033
     } an_u;
2034
 
2035
   This code generates a stab for a union tag and a stab for a union
2036
variable.  Both use the `N_LSYM' stab type.  If a union variable is
2037
scoped locally to the procedure in which it is defined, its stab is
2038
located immediately preceding the `N_LBRAC' for the procedure's block
2039
start.
2040
 
2041
   The stab for the union tag, however, is located preceding the code
2042
for the procedure in which it is defined.  The stab type is `N_LSYM'.
2043
This would seem to imply that the union type is file scope, like the
2044
struct type `s_tag'.  This is not true.  The contents and position of
2045
the stab for `u_type' do not convey any information about its procedure
2046
local scope.
2047
 
2048
     # 128 is N_LSYM
2049
     .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;",
2050
            128,0,0,0
2051
 
2052
   The symbol descriptor `T', following the `name:' means that the stab
2053
describes an enumeration, structure, or union tag.  The type descriptor
2054
`u', following the `23=' of the type definition, narrows it down to a
2055
union type definition.  Following the `u' is the number of bytes in the
2056
union.  After that is a list of union element descriptions.  Their
2057
format is `NAME:TYPE, BIT OFFSET INTO THE UNION, NUMBER OF BYTES FOR
2058
THE ELEMENT;'.
2059
 
2060
   The stab for the union variable is:
2061
 
2062
     .stabs "an_u:23",128,0,0,-20     # 128 is N_LSYM
2063
 
2064
   `-20' specifies where the variable is stored (*note Stack
2065
Variables::).
2066
 
2067

2068
File: stabs.info,  Node: Function Types,  Prev: Unions,  Up: Types
2069
 
2070
5.11 Function Types
2071
===================
2072
 
2073
Various types can be defined for function variables.  These types are
2074
not used in defining functions (*note Procedures::); they are used for
2075
things like pointers to functions.
2076
 
2077
   The simple, traditional, type is type descriptor `f' is followed by
2078
type information for the return type of the function, followed by a
2079
semicolon.
2080
 
2081
   This does not deal with functions for which the number and types of
2082
the parameters are part of the type, as in Modula-2 or ANSI C.  AIX
2083
provides extensions to specify these, using the `f', `F', `p', and `R'
2084
type descriptors.
2085
 
2086
   First comes the type descriptor.  If it is `f' or `F', this type
2087
involves a function rather than a procedure, and the type information
2088
for the return type of the function follows, followed by a comma.  Then
2089
comes the number of parameters to the function and a semicolon.  Then,
2090
for each parameter, there is the name of the parameter followed by a
2091
colon (this is only present for type descriptors `R' and `F' which
2092
represent Pascal function or procedure parameters), type information
2093
for the parameter, a comma, 0 if passed by reference or 1 if passed by
2094
value, and a semicolon.  The type definition ends with a semicolon.
2095
 
2096
   For example, this variable definition:
2097
 
2098
     int (*g_pf)();
2099
 
2100
generates the following code:
2101
 
2102
     .stabs "g_pf:G24=*25=f1",32,0,0,0
2103
         .common _g_pf,4,"bss"
2104
 
2105
   The variable defines a new type, 24, which is a pointer to another
2106
new type, 25, which is a function returning `int'.
2107
 
2108

2109
File: stabs.info,  Node: Macro define and undefine,  Next: Symbol Tables,  Prev: Types,  Up: Top
2110
 
2111
6 Representation of #define and #undef
2112
**************************************
2113
 
2114
This section describes the stabs support for macro define and undefine
2115
information, supported on some systems.  (e.g., with `-g3' `-gstabs'
2116
when using GCC).
2117
 
2118
   A `#define MACRO-NAME MACRO-BODY' is represented with an
2119
`N_MAC_DEFINE' stab with a string field of `MACRO-NAME MACRO-BODY'.
2120
 
2121
   An `#undef MACRO-NAME' is represented with an `N_MAC_UNDEF' stabs
2122
with a string field of simply `MACRO-NAME'.
2123
 
2124
   For both `N_MAC_DEFINE' and `N_MAC_UNDEF', the desc field is the
2125
line number within the file where the corresponding `#define' or
2126
`#undef' occurred.
2127
 
2128
   For example, the following C code:
2129
 
2130
         #define NONE   42
2131
         #define TWO(a, b)      (a + (a) + 2 * b)
2132
         #define ONE(c) (c + 19)
2133
 
2134
         main(int argc, char *argv[])
2135
         {
2136
           func(NONE, TWO(10, 11));
2137
           func(NONE, ONE(23));
2138
 
2139
         #undef ONE
2140
         #define ONE(c) (c + 23)
2141
 
2142
           func(NONE, ONE(-23));
2143
 
2144
           return (0);
2145
         }
2146
 
2147
         int global;
2148
 
2149
         func(int arg1, int arg2)
2150
         {
2151
           global = arg1 + arg2;
2152
         }
2153
 
2154
produces the following stabs (as well as many others):
2155
 
2156
         .stabs "NONE 42",54,0,1,0
2157
         .stabs "TWO(a,b) (a + (a) + 2 * b)",54,0,2,0
2158
         .stabs "ONE(c) (c + 19)",54,0,3,0
2159
         .stabs "ONE",58,0,10,0
2160
         .stabs "ONE(c) (c + 23)",54,0,11,0
2161
 
2162
NOTE: In the above example, `54' is `N_MAC_DEFINE' and `58' is
2163
`N_MAC_UNDEF'.
2164
 
2165

2166
File: stabs.info,  Node: Symbol Tables,  Next: Cplusplus,  Prev: Macro define and undefine,  Up: Top
2167
 
2168
7 Symbol Information in Symbol Tables
2169
*************************************
2170
 
2171
This chapter describes the format of symbol table entries and how stab
2172
assembler directives map to them.  It also describes the
2173
transformations that the assembler and linker make on data from stabs.
2174
 
2175
* Menu:
2176
 
2177
* Symbol Table Format::
2178
* Transformations On Symbol Tables::
2179
 
2180

2181
File: stabs.info,  Node: Symbol Table Format,  Next: Transformations On Symbol Tables,  Up: Symbol Tables
2182
 
2183
7.1 Symbol Table Format
2184
=======================
2185
 
2186
Each time the assembler encounters a stab directive, it puts each field
2187
of the stab into a corresponding field in a symbol table entry of its
2188
output file.  If the stab contains a string field, the symbol table
2189
entry for that stab points to a string table entry containing the
2190
string data from the stab.  Assembler labels become relocatable
2191
addresses.  Symbol table entries in a.out have the format:
2192
 
2193
     struct internal_nlist {
2194
       unsigned long n_strx;         /* index into string table of name */
2195
       unsigned char n_type;         /* type of symbol */
2196
       unsigned char n_other;        /* misc info (usually empty) */
2197
       unsigned short n_desc;        /* description field */
2198
       bfd_vma n_value;              /* value of symbol */
2199
     };
2200
 
2201
   If the stab has a string, the `n_strx' field holds the offset in
2202
bytes of the string within the string table.  The string is terminated
2203
by a NUL character.  If the stab lacks a string (for example, it was
2204
produced by a `.stabn' or `.stabd' directive), the `n_strx' field is
2205
zero.
2206
 
2207
   Symbol table entries with `n_type' field values greater than 0x1f
2208
originated as stabs generated by the compiler (with one random
2209
exception).  The other entries were placed in the symbol table of the
2210
executable by the assembler or the linker.
2211
 
2212

2213
File: stabs.info,  Node: Transformations On Symbol Tables,  Prev: Symbol Table Format,  Up: Symbol Tables
2214
 
2215
7.2 Transformations on Symbol Tables
2216
====================================
2217
 
2218
The linker concatenates object files and does fixups of externally
2219
defined symbols.
2220
 
2221
   You can see the transformations made on stab data by the assembler
2222
and linker by examining the symbol table after each pass of the build.
2223
To do this, use `nm -ap', which dumps the symbol table, including
2224
debugging information, unsorted.  For stab entries the columns are:
2225
VALUE, OTHER, DESC, TYPE, STRING.  For assembler and linker symbols,
2226
the columns are: VALUE, TYPE, STRING.
2227
 
2228
   The low 5 bits of the stab type tell the linker how to relocate the
2229
value of the stab.  Thus for stab types like `N_RSYM' and `N_LSYM',
2230
where the value is an offset or a register number, the low 5 bits are
2231
`N_ABS', which tells the linker not to relocate the value.
2232
 
2233
   Where the value of a stab contains an assembly language label, it is
2234
transformed by each build step.  The assembler turns it into a
2235
relocatable address and the linker turns it into an absolute address.
2236
 
2237
* Menu:
2238
 
2239
* Transformations On Static Variables::
2240
* Transformations On Global Variables::
2241
* Stab Section Transformations::           For some object file formats,
2242
                                           things are a bit different.
2243
 
2244

2245
File: stabs.info,  Node: Transformations On Static Variables,  Next: Transformations On Global Variables,  Up: Transformations On Symbol Tables
2246
 
2247
7.2.1 Transformations on Static Variables
2248
-----------------------------------------
2249
 
2250
This source line defines a static variable at file scope:
2251
 
2252
     static int s_g_repeat
2253
 
2254
The following stab describes the symbol:
2255
 
2256
     .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
2257
 
2258
The assembler transforms the stab into this symbol table entry in the
2259
`.o' file.  The location is expressed as a data segment offset.
2260
 
2261
     00000084 - 00 0000 STSYM s_g_repeat:S1
2262
 
2263
In the symbol table entry from the executable, the linker has made the
2264
relocatable address absolute.
2265
 
2266
     0000e00c - 00 0000 STSYM s_g_repeat:S1
2267
 
2268

2269
File: stabs.info,  Node: Transformations On Global Variables,  Next: Stab Section Transformations,  Prev: Transformations On Static Variables,  Up: Transformations On Symbol Tables
2270
 
2271
7.2.2 Transformations on Global Variables
2272
-----------------------------------------
2273
 
2274
Stabs for global variables do not contain location information. In this
2275
case, the debugger finds location information in the assembler or
2276
linker symbol table entry describing the variable.  The source line:
2277
 
2278
     char g_foo = 'c';
2279
 
2280
generates the stab:
2281
 
2282
     .stabs "g_foo:G2",32,0,0,0
2283
 
2284
   The variable is represented by two symbol table entries in the object
2285
file (see below).  The first one originated as a stab.  The second one
2286
is an external symbol.  The upper case `D' signifies that the `n_type'
2287
field of the symbol table contains 7, `N_DATA' with local linkage.  The
2288
stab's value is zero since the value is not used for `N_GSYM' stabs.
2289
The value of the linker symbol is the relocatable address corresponding
2290
to the variable.
2291
 
2292
     00000000 - 00 0000  GSYM g_foo:G2
2293
     00000080 D _g_foo
2294
 
2295
These entries as transformed by the linker.  The linker symbol table
2296
entry now holds an absolute address:
2297
 
2298
     00000000 - 00 0000  GSYM g_foo:G2
2299
     ...
2300
     0000e008 D _g_foo
2301
 
2302

2303
File: stabs.info,  Node: Stab Section Transformations,  Prev: Transformations On Global Variables,  Up: Transformations On Symbol Tables
2304
 
2305
7.2.3 Transformations of Stabs in separate sections
2306
---------------------------------------------------
2307
 
2308
For object file formats using stabs in separate sections (*note Stab
2309
Sections::), use `objdump --stabs' instead of `nm' to show the stabs in
2310
an object or executable file.  `objdump' is a GNU utility; Sun does not
2311
provide any equivalent.
2312
 
2313
   The following example is for a stab whose value is an address is
2314
relative to the compilation unit (*note ELF Linker Relocation::).  For
2315
example, if the source line
2316
 
2317
     static int ld = 5;
2318
 
2319
   appears within a function, then the assembly language output from the
2320
compiler contains:
2321
 
2322
     .Ddata.data:
2323
     ...
2324
             .stabs "ld:V(0,3)",0x26,0,4,.L18-Ddata.data    # 0x26 is N_STSYM
2325
     ...
2326
     .L18:
2327
             .align 4
2328
             .word 0x5
2329
 
2330
   Because the value is formed by subtracting one symbol from another,
2331
the value is absolute, not relocatable, and so the object file contains
2332
 
2333
     Symnum n_type n_othr n_desc n_value  n_strx String
2334
     31     STSYM  0      4      00000004 680    ld:V(0,3)
2335
 
2336
   without any relocations, and the executable file also contains
2337
 
2338
     Symnum n_type n_othr n_desc n_value  n_strx String
2339
     31     STSYM  0      4      00000004 680    ld:V(0,3)
2340
 
2341

2342
File: stabs.info,  Node: Cplusplus,  Next: Stab Types,  Prev: Symbol Tables,  Up: Top
2343
 
2344
8 GNU C++ Stabs
2345
***************
2346
 
2347
* Menu:
2348
 
2349
* Class Names::                 C++ class names are both tags and typedefs.
2350
* Nested Symbols::              C++ symbol names can be within other types.
2351
* Basic Cplusplus Types::
2352
* Simple Classes::
2353
* Class Instance::
2354
* Methods::                     Method definition
2355
* Method Type Descriptor::      The `#' type descriptor
2356
* Member Type Descriptor::      The `@' type descriptor
2357
* Protections::
2358
* Method Modifiers::
2359
* Virtual Methods::
2360
* Inheritance::
2361
* Virtual Base Classes::
2362
* Static Members::
2363
 
2364

2365
File: stabs.info,  Node: Class Names,  Next: Nested Symbols,  Up: Cplusplus
2366
 
2367
8.1 C++ Class Names
2368
===================
2369
 
2370
In C++, a class name which is declared with `class', `struct', or
2371
`union', is not only a tag, as in C, but also a type name.  Thus there
2372
should be stabs with both `t' and `T' symbol descriptors (*note
2373
Typedefs::).
2374
 
2375
   To save space, there is a special abbreviation for this case.  If the
2376
`T' symbol descriptor is followed by `t', then the stab defines both a
2377
type name and a tag.
2378
 
2379
   For example, the C++ code
2380
 
2381
     struct foo {int x;};
2382
 
2383
   can be represented as either
2384
 
2385
     .stabs "foo:T19=s4x:1,0,32;;",128,0,0,0       # 128 is N_LSYM
2386
     .stabs "foo:t19",128,0,0,0
2387
 
2388
   or
2389
 
2390
     .stabs "foo:Tt19=s4x:1,0,32;;",128,0,0,0
2391
 
2392

2393
File: stabs.info,  Node: Nested Symbols,  Next: Basic Cplusplus Types,  Prev: Class Names,  Up: Cplusplus
2394
 
2395
8.2 Defining a Symbol Within Another Type
2396
=========================================
2397
 
2398
In C++, a symbol (such as a type name) can be defined within another
2399
type.
2400
 
2401
   In stabs, this is sometimes represented by making the name of a
2402
symbol which contains `::'.  Such a pair of colons does not end the name
2403
of the symbol, the way a single colon would (*note String Field::).  I'm
2404
not sure how consistently used or well thought out this mechanism is.
2405
So that a pair of colons in this position always has this meaning, `:'
2406
cannot be used as a symbol descriptor.
2407
 
2408
   For example, if the string for a stab is `foo::bar::baz:t5=*6', then
2409
`foo::bar::baz' is the name of the symbol, `t' is the symbol
2410
descriptor, and `5=*6' is the type information.
2411
 
2412

2413
File: stabs.info,  Node: Basic Cplusplus Types,  Next: Simple Classes,  Prev: Nested Symbols,  Up: Cplusplus
2414
 
2415
8.3 Basic Types For C++
2416
=======================
2417
 
2418
<< the examples that follow are based on a01.C >>
2419
 
2420
   C++ adds two more builtin types to the set defined for C.  These are
2421
the unknown type and the vtable record type.  The unknown type, type
2422
16, is defined in terms of itself like the void type.
2423
 
2424
   The vtable record type, type 17, is defined as a structure type and
2425
then as a structure tag.  The structure has four fields: delta, index,
2426
pfn, and delta2.  pfn is the function pointer.
2427
 
2428
   << In boilerplate $vtbl_ptr_type, what are the fields delta, index,
2429
and delta2 used for? >>
2430
 
2431
   This basic type is present in all C++ programs even if there are no
2432
virtual methods defined.
2433
 
2434
     .stabs "struct_name:sym_desc(type)type_def(17)=type_desc(struct)struct_bytes(8)
2435
             elem_name(delta):type_ref(short int),bit_offset(0),field_bits(16);
2436
             elem_name(index):type_ref(short int),bit_offset(16),field_bits(16);
2437
             elem_name(pfn):type_def(18)=type_desc(ptr to)type_ref(void),
2438
                                         bit_offset(32),field_bits(32);
2439
             elem_name(delta2):type_def(short int);bit_offset(32),field_bits(16);;"
2440
             N_LSYM, NIL, NIL
2441
 
2442
     .stabs "$vtbl_ptr_type:t17=s8
2443
             delta:6,0,16;index:6,16,16;pfn:18=*15,32,32;delta2:6,32,16;;"
2444
             ,128,0,0,0
2445
 
2446
     .stabs "name:sym_dec(struct tag)type_ref($vtbl_ptr_type)",N_LSYM,NIL,NIL,NIL
2447
 
2448
     .stabs "$vtbl_ptr_type:T17",128,0,0,0
2449
 
2450

2451
File: stabs.info,  Node: Simple Classes,  Next: Class Instance,  Prev: Basic Cplusplus Types,  Up: Cplusplus
2452
 
2453
8.4 Simple Class Definition
2454
===========================
2455
 
2456
The stabs describing C++ language features are an extension of the
2457
stabs describing C.  Stabs representing C++ class types elaborate
2458
extensively on the stab format used to describe structure types in C.
2459
Stabs representing class type variables look just like stabs
2460
representing C language variables.
2461
 
2462
   Consider the following very simple class definition.
2463
 
2464
     class baseA {
2465
     public:
2466
             int Adat;
2467
             int Ameth(int in, char other);
2468
     };
2469
 
2470
   The class `baseA' is represented by two stabs.  The first stab
2471
describes the class as a structure type.  The second stab describes a
2472
structure tag of the class type.  Both stabs are of stab type `N_LSYM'.
2473
Since the stab is not located between an `N_FUN' and an `N_LBRAC' stab
2474
this indicates that the class is defined at file scope.  If it were,
2475
then the `N_LSYM' would signify a local variable.
2476
 
2477
   A stab describing a C++ class type is similar in format to a stab
2478
describing a C struct, with each class member shown as a field in the
2479
structure.  The part of the struct format describing fields is expanded
2480
to include extra information relevant to C++ class members.  In
2481
addition, if the class has multiple base classes or virtual functions
2482
the struct format outside of the field parts is also augmented.
2483
 
2484
   In this simple example the field part of the C++ class stab
2485
representing member data looks just like the field part of a C struct
2486
stab.  The section on protections describes how its format is sometimes
2487
extended for member data.
2488
 
2489
   The field part of a C++ class stab representing a member function
2490
differs substantially from the field part of a C struct stab.  It still
2491
begins with `name:' but then goes on to define a new type number for
2492
the member function, describe its return type, its argument types, its
2493
protection level, any qualifiers applied to the method definition, and
2494
whether the method is virtual or not.  If the method is virtual then
2495
the method description goes on to give the vtable index of the method,
2496
and the type number of the first base class defining the method.
2497
 
2498
   When the field name is a method name it is followed by two colons
2499
rather than one.  This is followed by a new type definition for the
2500
method.  This is a number followed by an equal sign and the type of the
2501
method.  Normally this will be a type declared using the `#' type
2502
descriptor; see *note Method Type Descriptor::; static member functions
2503
are declared using the `f' type descriptor instead; see *note Function
2504
Types::.
2505
 
2506
   The format of an overloaded operator method name differs from that of
2507
other methods.  It is `op$::OPERATOR-NAME.' where OPERATOR-NAME is the
2508
operator name such as `+' or `+='.  The name ends with a period, and
2509
any characters except the period can occur in the OPERATOR-NAME string.
2510
 
2511
   The next part of the method description represents the arguments to
2512
the method, preceded by a colon and ending with a semi-colon.  The
2513
types of the arguments are expressed in the same way argument types are
2514
expressed in C++ name mangling.  In this example an `int' and a `char'
2515
map to `ic'.
2516
 
2517
   This is followed by a number, a letter, and an asterisk or period,
2518
followed by another semicolon.  The number indicates the protections
2519
that apply to the member function.  Here the 2 means public.  The
2520
letter encodes any qualifier applied to the method definition.  In this
2521
case, `A' means that it is a normal function definition.  The dot shows
2522
that the method is not virtual.  The sections that follow elaborate
2523
further on these fields and describe the additional information present
2524
for virtual methods.
2525
 
2526
     .stabs "class_name:sym_desc(type)type_def(20)=type_desc(struct)struct_bytes(4)
2527
             field_name(Adat):type(int),bit_offset(0),field_bits(32);
2528
 
2529
             method_name(Ameth)::type_def(21)=type_desc(method)return_type(int);
2530
             :arg_types(int char);
2531
             protection(public)qualifier(normal)virtual(no);;"
2532
             N_LSYM,NIL,NIL,NIL
2533
 
2534
     .stabs "baseA:t20=s4Adat:1,0,32;Ameth::21=##1;:ic;2A.;;",128,0,0,0
2535
 
2536
     .stabs "class_name:sym_desc(struct tag)",N_LSYM,NIL,NIL,NIL
2537
 
2538
     .stabs "baseA:T20",128,0,0,0
2539
 
2540

2541
File: stabs.info,  Node: Class Instance,  Next: Methods,  Prev: Simple Classes,  Up: Cplusplus
2542
 
2543
8.5 Class Instance
2544
==================
2545
 
2546
As shown above, describing even a simple C++ class definition is
2547
accomplished by massively extending the stab format used in C to
2548
describe structure types.  However, once the class is defined, C stabs
2549
with no modifications can be used to describe class instances.  The
2550
following source:
2551
 
2552
     main () {
2553
             baseA AbaseA;
2554
     }
2555
 
2556
yields the following stab describing the class instance.  It looks no
2557
different from a standard C stab describing a local variable.
2558
 
2559
     .stabs "name:type_ref(baseA)", N_LSYM, NIL, NIL, frame_ptr_offset
2560
 
2561
     .stabs "AbaseA:20",128,0,0,-20
2562
 
2563

2564
File: stabs.info,  Node: Methods,  Next: Method Type Descriptor,  Prev: Class Instance,  Up: Cplusplus
2565
 
2566
8.6 Method Definition
2567
=====================
2568
 
2569
The class definition shown above declares Ameth.  The C++ source below
2570
defines Ameth:
2571
 
2572
     int
2573
     baseA::Ameth(int in, char other)
2574
     {
2575
             return in;
2576
     };
2577
 
2578
   This method definition yields three stabs following the code of the
2579
method.  One stab describes the method itself and following two describe
2580
its parameters.  Although there is only one formal argument all methods
2581
have an implicit argument which is the `this' pointer.  The `this'
2582
pointer is a pointer to the object on which the method was called.  Note
2583
that the method name is mangled to encode the class name and argument
2584
types.  Name mangling is described in the ARM (`The Annotated C++
2585
Reference Manual', by Ellis and Stroustrup, ISBN 0-201-51459-1);
2586
`gpcompare.texi' in Cygnus GCC distributions describes the differences
2587
between GNU mangling and ARM mangling.
2588
 
2589
     .stabs "name:symbol_descriptor(global function)return_type(int)",
2590
             N_FUN, NIL, NIL, code_addr_of_method_start
2591
 
2592
     .stabs "Ameth__5baseAic:F1",36,0,0,_Ameth__5baseAic
2593
 
2594
   Here is the stab for the `this' pointer implicit argument.  The name
2595
of the `this' pointer is always `this'.  Type 19, the `this' pointer is
2596
defined as a pointer to type 20, `baseA', but a stab defining `baseA'
2597
has not yet been emitted.  Since the compiler knows it will be emitted
2598
shortly, here it just outputs a cross reference to the undefined
2599
symbol, by prefixing the symbol name with `xs'.
2600
 
2601
     .stabs "name:sym_desc(register param)type_def(19)=
2602
             type_desc(ptr to)type_ref(baseA)=
2603
             type_desc(cross-reference to)baseA:",N_RSYM,NIL,NIL,register_number
2604
 
2605
     .stabs "this:P19=*20=xsbaseA:",64,0,0,8
2606
 
2607
   The stab for the explicit integer argument looks just like a
2608
parameter to a C function.  The last field of the stab is the offset
2609
from the argument pointer, which in most systems is the same as the
2610
frame pointer.
2611
 
2612
     .stabs "name:sym_desc(value parameter)type_ref(int)",
2613
             N_PSYM,NIL,NIL,offset_from_arg_ptr
2614
 
2615
     .stabs "in:p1",160,0,0,72
2616
 
2617
   << The examples that follow are based on A1.C >>
2618
 
2619

2620
File: stabs.info,  Node: Method Type Descriptor,  Next: Member Type Descriptor,  Prev: Methods,  Up: Cplusplus
2621
 
2622
8.7 The `#' Type Descriptor
2623
===========================
2624
 
2625
This is used to describe a class method.  This is a function which takes
2626
an extra argument as its first argument, for the `this' pointer.
2627
 
2628
   If the `#' is immediately followed by another `#', the second one
2629
will be followed by the return type and a semicolon.  The class and
2630
argument types are not specified, and must be determined by demangling
2631
the name of the method if it is available.
2632
 
2633
   Otherwise, the single `#' is followed by the class type, a comma,
2634
the return type, a comma, and zero or more parameter types separated by
2635
commas.  The list of arguments is terminated by a semicolon.  In the
2636
debugging output generated by gcc, a final argument type of `void'
2637
indicates a method which does not take a variable number of arguments.
2638
If the final argument type of `void' does not appear, the method was
2639
declared with an ellipsis.
2640
 
2641
   Note that although such a type will normally be used to describe
2642
fields in structures, unions, or classes, for at least some versions of
2643
the compiler it can also be used in other contexts.
2644
 
2645

2646
File: stabs.info,  Node: Member Type Descriptor,  Next: Protections,  Prev: Method Type Descriptor,  Up: Cplusplus
2647
 
2648
8.8 The `@' Type Descriptor
2649
===========================
2650
 
2651
The `@' type descriptor is used for a pointer-to-non-static-member-data
2652
type.  It is followed by type information for the class (or union), a
2653
comma, and type information for the member data.
2654
 
2655
   The following C++ source:
2656
 
2657
     typedef int A::*int_in_a;
2658
 
2659
   generates the following stab:
2660
 
2661
     .stabs "int_in_a:t20=21=@19,1",128,0,0,0
2662
 
2663
   Note that there is a conflict between this and type attributes
2664
(*note String Field::); both use type descriptor `@'.  Fortunately, the
2665
`@' type descriptor used in this C++ sense always will be followed by a
2666
digit, `(', or `-', and type attributes never start with those things.
2667
 
2668

2669
File: stabs.info,  Node: Protections,  Next: Method Modifiers,  Prev: Member Type Descriptor,  Up: Cplusplus
2670
 
2671
8.9 Protections
2672
===============
2673
 
2674
In the simple class definition shown above all member data and
2675
functions were publicly accessible.  The example that follows contrasts
2676
public, protected and privately accessible fields and shows how these
2677
protections are encoded in C++ stabs.
2678
 
2679
   If the character following the `FIELD-NAME:' part of the string is
2680
`/', then the next character is the visibility.  `0' means private, `1'
2681
means protected, and `2' means public.  Debuggers should ignore
2682
visibility characters they do not recognize, and assume a reasonable
2683
default (such as public) (GDB 4.11 does not, but this should be fixed
2684
in the next GDB release).  If no visibility is specified the field is
2685
public.  The visibility `9' means that the field has been optimized out
2686
and is public (there is no way to specify an optimized out field with a
2687
private or protected visibility).  Visibility `9' is not supported by
2688
GDB 4.11; this should be fixed in the next GDB release.
2689
 
2690
   The following C++ source:
2691
 
2692
     class vis {
2693
     private:
2694
             int   priv;
2695
     protected:
2696
             char  prot;
2697
     public:
2698
             float pub;
2699
     };
2700
 
2701
generates the following stab:
2702
 
2703
     # 128 is N_LSYM
2704
     .stabs "vis:T19=s12priv:/01,0,32;prot:/12,32,8;pub:12,64,32;;",128,0,0,0
2705
 
2706
   `vis:T19=s12' indicates that type number 19 is a 12 byte structure
2707
named `vis' The `priv' field has public visibility (`/0'), type int
2708
(`1'), and offset and size `,0,32;'.  The `prot' field has protected
2709
visibility (`/1'), type char (`2') and offset and size `,32,8;'.  The
2710
`pub' field has type float (`12'), and offset and size `,64,32;'.
2711
 
2712
   Protections for member functions are signified by one digit embedded
2713
in the field part of the stab describing the method.  The digit is 0 if
2714
private, 1 if protected and 2 if public.  Consider the C++ class
2715
definition below:
2716
 
2717
     class all_methods {
2718
     private:
2719
             int   priv_meth(int in){return in;};
2720
     protected:
2721
             char  protMeth(char in){return in;};
2722
     public:
2723
             float pubMeth(float in){return in;};
2724
     };
2725
 
2726
   It generates the following stab.  The digit in question is to the
2727
left of an `A' in each case.  Notice also that in this case two symbol
2728
descriptors apply to the class name struct tag and struct type.
2729
 
2730
     .stabs "class_name:sym_desc(struct tag&type)type_def(21)=
2731
             sym_desc(struct)struct_bytes(1)
2732
             meth_name::type_def(22)=sym_desc(method)returning(int);
2733
             :args(int);protection(private)modifier(normal)virtual(no);
2734
             meth_name::type_def(23)=sym_desc(method)returning(char);
2735
             :args(char);protection(protected)modifier(normal)virtual(no);
2736
             meth_name::type_def(24)=sym_desc(method)returning(float);
2737
             :args(float);protection(public)modifier(normal)virtual(no);;",
2738
             N_LSYM,NIL,NIL,NIL
2739
 
2740
     .stabs "all_methods:Tt21=s1priv_meth::22=##1;:i;0A.;protMeth::23=##2;:c;1A.;
2741
             pubMeth::24=##12;:f;2A.;;",128,0,0,0
2742
 
2743

2744
File: stabs.info,  Node: Method Modifiers,  Next: Virtual Methods,  Prev: Protections,  Up: Cplusplus
2745
 
2746
8.10 Method Modifiers (`const', `volatile', `const volatile')
2747
=============================================================
2748
 
2749
<< based on a6.C >>
2750
 
2751
   In the class example described above all the methods have the normal
2752
modifier.  This method modifier information is located just after the
2753
protection information for the method.  This field has four possible
2754
character values.  Normal methods use `A', const methods use `B',
2755
volatile methods use `C', and const volatile methods use `D'.  Consider
2756
the class definition below:
2757
 
2758
     class A {
2759
     public:
2760
             int ConstMeth (int arg) const { return arg; };
2761
             char VolatileMeth (char arg) volatile { return arg; };
2762
             float ConstVolMeth (float arg) const volatile {return arg; };
2763
     };
2764
 
2765
   This class is described by the following stab:
2766
 
2767
     .stabs "class(A):sym_desc(struct)type_def(20)=type_desc(struct)struct_bytes(1)
2768
             meth_name(ConstMeth)::type_def(21)sym_desc(method)
2769
             returning(int);:arg(int);protection(public)modifier(const)virtual(no);
2770
             meth_name(VolatileMeth)::type_def(22)=sym_desc(method)
2771
             returning(char);:arg(char);protection(public)modifier(volatile)virt(no)
2772
             meth_name(ConstVolMeth)::type_def(23)=sym_desc(method)
2773
             returning(float);:arg(float);protection(public)modifier(const volatile)
2774
             virtual(no);;", ...
2775
 
2776
     .stabs "A:T20=s1ConstMeth::21=##1;:i;2B.;VolatileMeth::22=##2;:c;2C.;
2777
                  ConstVolMeth::23=##12;:f;2D.;;",128,0,0,0
2778
 
2779

2780
File: stabs.info,  Node: Virtual Methods,  Next: Inheritance,  Prev: Method Modifiers,  Up: Cplusplus
2781
 
2782
8.11 Virtual Methods
2783
====================
2784
 
2785
<< The following examples are based on a4.C >>
2786
 
2787
   The presence of virtual methods in a class definition adds additional
2788
data to the class description.  The extra data is appended to the
2789
description of the virtual method and to the end of the class
2790
description.  Consider the class definition below:
2791
 
2792
     class A {
2793
     public:
2794
             int Adat;
2795
             virtual int A_virt (int arg) { return arg; };
2796
     };
2797
 
2798
   This results in the stab below describing class A.  It defines a new
2799
type (20) which is an 8 byte structure.  The first field of the class
2800
struct is `Adat', an integer, starting at structure offset 0 and
2801
occupying 32 bits.
2802
 
2803
   The second field in the class struct is not explicitly defined by the
2804
C++ class definition but is implied by the fact that the class contains
2805
a virtual method.  This field is the vtable pointer.  The name of the
2806
vtable pointer field starts with `$vf' and continues with a type
2807
reference to the class it is part of.  In this example the type
2808
reference for class A is 20 so the name of its vtable pointer field is
2809
`$vf20', followed by the usual colon.
2810
 
2811
   Next there is a type definition for the vtable pointer type (21).
2812
This is in turn defined as a pointer to another new type (22).
2813
 
2814
   Type 22 is the vtable itself, which is defined as an array, indexed
2815
by a range of integers between 0 and 1, and whose elements are of type
2816
17.  Type 17 was the vtable record type defined by the boilerplate C++
2817
type definitions, as shown earlier.
2818
 
2819
   The bit offset of the vtable pointer field is 32.  The number of bits
2820
in the field are not specified when the field is a vtable pointer.
2821
 
2822
   Next is the method definition for the virtual member function
2823
`A_virt'.  Its description starts out using the same format as the
2824
non-virtual member functions described above, except instead of a dot
2825
after the `A' there is an asterisk, indicating that the function is
2826
virtual.  Since is is virtual some addition information is appended to
2827
the end of the method description.
2828
 
2829
   The first number represents the vtable index of the method.  This is
2830
a 32 bit unsigned number with the high bit set, followed by a
2831
semi-colon.
2832
 
2833
   The second number is a type reference to the first base class in the
2834
inheritance hierarchy defining the virtual member function.  In this
2835
case the class stab describes a base class so the virtual function is
2836
not overriding any other definition of the method.  Therefore the
2837
reference is to the type number of the class that the stab is
2838
describing (20).
2839
 
2840
   This is followed by three semi-colons.  One marks the end of the
2841
current sub-section, one marks the end of the method field, and the
2842
third marks the end of the struct definition.
2843
 
2844
   For classes containing virtual functions the very last section of the
2845
string part of the stab holds a type reference to the first base class.
2846
This is preceded by `~%' and followed by a final semi-colon.
2847
 
2848
     .stabs "class_name(A):type_def(20)=sym_desc(struct)struct_bytes(8)
2849
             field_name(Adat):type_ref(int),bit_offset(0),field_bits(32);
2850
             field_name(A virt func ptr):type_def(21)=type_desc(ptr to)type_def(22)=
2851
             sym_desc(array)index_type_ref(range of int from 0 to 1);
2852
             elem_type_ref(vtbl elem type),
2853
             bit_offset(32);
2854
             meth_name(A_virt)::typedef(23)=sym_desc(method)returning(int);
2855
             :arg_type(int),protection(public)normal(yes)virtual(yes)
2856
             vtable_index(1);class_first_defining(A);;;~%first_base(A);",
2857
             N_LSYM,NIL,NIL,NIL
2858
 
2859
     .stabs "A:t20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
2860
             A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
2861
 
2862

2863
File: stabs.info,  Node: Inheritance,  Next: Virtual Base Classes,  Prev: Virtual Methods,  Up: Cplusplus
2864
 
2865
8.12 Inheritance
2866
================
2867
 
2868
Stabs describing C++ derived classes include additional sections that
2869
describe the inheritance hierarchy of the class.  A derived class stab
2870
also encodes the number of base classes.  For each base class it tells
2871
if the base class is virtual or not, and if the inheritance is private
2872
or public.  It also gives the offset into the object of the portion of
2873
the object corresponding to each base class.
2874
 
2875
   This additional information is embedded in the class stab following
2876
the number of bytes in the struct.  First the number of base classes
2877
appears bracketed by an exclamation point and a comma.
2878
 
2879
   Then for each base type there repeats a series: a virtual character,
2880
a visibility character, a number, a comma, another number, and a
2881
semi-colon.
2882
 
2883
   The virtual character is `1' if the base class is virtual and `0' if
2884
not.  The visibility character is `2' if the derivation is public, `1'
2885
if it is protected, and `0' if it is private.  Debuggers should ignore
2886
virtual or visibility characters they do not recognize, and assume a
2887
reasonable default (such as public and non-virtual) (GDB 4.11 does not,
2888
but this should be fixed in the next GDB release).
2889
 
2890
   The number following the virtual and visibility characters is the
2891
offset from the start of the object to the part of the object
2892
pertaining to the base class.
2893
 
2894
   After the comma, the second number is a type_descriptor for the base
2895
type.  Finally a semi-colon ends the series, which repeats for each
2896
base class.
2897
 
2898
   The source below defines three base classes `A', `B', and `C' and
2899
the derived class `D'.
2900
 
2901
     class A {
2902
     public:
2903
             int Adat;
2904
             virtual int A_virt (int arg) { return arg; };
2905
     };
2906
 
2907
     class B {
2908
     public:
2909
             int B_dat;
2910
             virtual int B_virt (int arg) {return arg; };
2911
     };
2912
 
2913
     class C {
2914
     public:
2915
             int Cdat;
2916
             virtual int C_virt (int arg) {return arg; };
2917
     };
2918
 
2919
     class D : A, virtual B, public C {
2920
     public:
2921
             int Ddat;
2922
             virtual int A_virt (int arg ) { return arg+1; };
2923
             virtual int B_virt (int arg)  { return arg+2; };
2924
             virtual int C_virt (int arg)  { return arg+3; };
2925
             virtual int D_virt (int arg)  { return arg; };
2926
     };
2927
 
2928
   Class stabs similar to the ones described earlier are generated for
2929
each base class.
2930
 
2931
     .stabs "A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
2932
             A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
2933
 
2934
     .stabs "B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1;
2935
             :i;2A*-2147483647;25;;;~%25;",128,0,0,0
2936
 
2937
     .stabs "C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1;
2938
             :i;2A*-2147483647;28;;;~%28;",128,0,0,0
2939
 
2940
   In the stab describing derived class `D' below, the information about
2941
the derivation of this class is encoded as follows.
2942
 
2943
     .stabs "derived_class_name:symbol_descriptors(struct tag&type)=
2944
             type_descriptor(struct)struct_bytes(32)!num_bases(3),
2945
             base_virtual(no)inheritance_public(no)base_offset(0),
2946
             base_class_type_ref(A);
2947
             base_virtual(yes)inheritance_public(no)base_offset(NIL),
2948
             base_class_type_ref(B);
2949
             base_virtual(no)inheritance_public(yes)base_offset(64),
2950
             base_class_type_ref(C); ...
2951
 
2952
     .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:
2953
             1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt:
2954
             :32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;
2955
             28;;D_virt::32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
2956
 
2957

2958
File: stabs.info,  Node: Virtual Base Classes,  Next: Static Members,  Prev: Inheritance,  Up: Cplusplus
2959
 
2960
8.13 Virtual Base Classes
2961
=========================
2962
 
2963
A derived class object consists of a concatenation in memory of the data
2964
areas defined by each base class, starting with the leftmost and ending
2965
with the rightmost in the list of base classes.  The exception to this
2966
rule is for virtual inheritance.  In the example above, class `D'
2967
inherits virtually from base class `B'.  This means that an instance of
2968
a `D' object will not contain its own `B' part but merely a pointer to
2969
a `B' part, known as a virtual base pointer.
2970
 
2971
   In a derived class stab, the base offset part of the derivation
2972
information, described above, shows how the base class parts are
2973
ordered.  The base offset for a virtual base class is always given as 0.
2974
Notice that the base offset for `B' is given as 0 even though `B' is
2975
not the first base class.  The first base class `A' starts at offset 0.
2976
 
2977
   The field information part of the stab for class `D' describes the
2978
field which is the pointer to the virtual base class `B'. The vbase
2979
pointer name is `$vb' followed by a type reference to the virtual base
2980
class.  Since the type id for `B' in this example is 25, the vbase
2981
pointer name is `$vb25'.
2982
 
2983
     .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,
2984
            160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;
2985
            2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt:
2986
            :32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
2987
 
2988
   Following the name and a semicolon is a type reference describing the
2989
type of the virtual base class pointer, in this case 24.  Type 24 was
2990
defined earlier as the type of the `B' class `this' pointer.  The
2991
`this' pointer for a class is a pointer to the class type.
2992
 
2993
     .stabs "this:P24=*25=xsB:",64,0,0,8
2994
 
2995
   Finally the field offset part of the vbase pointer field description
2996
shows that the vbase pointer is the first field in the `D' object,
2997
before any data fields defined by the class.  The layout of a `D' class
2998
object is a follows, `Adat' at 0, the vtable pointer for `A' at 32,
2999
`Cdat' at 64, the vtable pointer for C at 96, the virtual base pointer
3000
for `B' at 128, and `Ddat' at 160.
3001
 
3002

3003
File: stabs.info,  Node: Static Members,  Prev: Virtual Base Classes,  Up: Cplusplus
3004
 
3005
8.14 Static Members
3006
===================
3007
 
3008
The data area for a class is a concatenation of the space used by the
3009
data members of the class.  If the class has virtual methods, a vtable
3010
pointer follows the class data.  The field offset part of each field
3011
description in the class stab shows this ordering.
3012
 
3013
   << How is this reflected in stabs?  See Cygnus bug #677 for some
3014
info.  >>
3015
 
3016

3017
File: stabs.info,  Node: Stab Types,  Next: Symbol Descriptors,  Prev: Cplusplus,  Up: Top
3018
 
3019
Appendix A Table of Stab Types
3020
******************************
3021
 
3022
The following are all the possible values for the stab type field, for
3023
a.out files, in numeric order.  This does not apply to XCOFF, but it
3024
does apply to stabs in sections (*note Stab Sections::).  Stabs in
3025
ECOFF use these values but add 0x8f300 to distinguish them from non-stab
3026
symbols.
3027
 
3028
   The symbolic names are defined in the file `include/aout/stabs.def'.
3029
 
3030
* Menu:
3031
 
3032
* Non-Stab Symbol Types::       Types from 0 to 0x1f
3033
* Stab Symbol Types::           Types from 0x20 to 0xff
3034
 
3035

3036
File: stabs.info,  Node: Non-Stab Symbol Types,  Next: Stab Symbol Types,  Up: Stab Types
3037
 
3038
A.1 Non-Stab Symbol Types
3039
=========================
3040
 
3041
The following types are used by the linker and assembler, not by stab
3042
directives.  Since this document does not attempt to describe aspects of
3043
object file format other than the debugging format, no details are
3044
given.
3045
 
3046
`0x0     N_UNDF'
3047
     Undefined symbol
3048
 
3049
`0x2     N_ABS'
3050
     File scope absolute symbol
3051
 
3052
`0x3     N_ABS | N_EXT'
3053
     External absolute symbol
3054
 
3055
`0x4     N_TEXT'
3056
     File scope text symbol
3057
 
3058
`0x5     N_TEXT | N_EXT'
3059
     External text symbol
3060
 
3061
`0x6     N_DATA'
3062
     File scope data symbol
3063
 
3064
`0x7     N_DATA | N_EXT'
3065
     External data symbol
3066
 
3067
`0x8     N_BSS'
3068
     File scope BSS symbol
3069
 
3070
`0x9     N_BSS | N_EXT'
3071
     External BSS symbol
3072
 
3073
`0x0c    N_FN_SEQ'
3074
     Same as `N_FN', for Sequent compilers
3075
 
3076
`0x0a    N_INDR'
3077
     Symbol is indirected to another symbol
3078
 
3079
`0x12    N_COMM'
3080
     Common--visible after shared library dynamic link
3081
 
3082
`0x14 N_SETA'
3083
`0x15 N_SETA | N_EXT'
3084
     Absolute set element
3085
 
3086
`0x16 N_SETT'
3087
`0x17 N_SETT | N_EXT'
3088
     Text segment set element
3089
 
3090
`0x18 N_SETD'
3091
`0x19 N_SETD | N_EXT'
3092
     Data segment set element
3093
 
3094
`0x1a N_SETB'
3095
`0x1b N_SETB | N_EXT'
3096
     BSS segment set element
3097
 
3098
`0x1c N_SETV'
3099
`0x1d N_SETV | N_EXT'
3100
     Pointer to set vector
3101
 
3102
`0x1e N_WARNING'
3103
     Print a warning message during linking
3104
 
3105
`0x1f    N_FN'
3106
     File name of a `.o' file
3107
 
3108

3109
File: stabs.info,  Node: Stab Symbol Types,  Prev: Non-Stab Symbol Types,  Up: Stab Types
3110
 
3111
A.2 Stab Symbol Types
3112
=====================
3113
 
3114
The following symbol types indicate that this is a stab.  This is the
3115
full list of stab numbers, including stab types that are used in
3116
languages other than C.
3117
 
3118
`0x20     N_GSYM'
3119
     Global symbol; see *note Global Variables::.
3120
 
3121
`0x22     N_FNAME'
3122
     Function name (for BSD Fortran); see *note Procedures::.
3123
 
3124
`0x24     N_FUN'
3125
     Function name (*note Procedures::) or text segment variable (*note
3126
     Statics::).
3127
 
3128
`0x26 N_STSYM'
3129
     Data segment file-scope variable; see *note Statics::.
3130
 
3131
`0x28 N_LCSYM'
3132
     BSS segment file-scope variable; see *note Statics::.
3133
 
3134
`0x2a N_MAIN'
3135
     Name of main routine; see *note Main Program::.
3136
 
3137
`0x2c N_ROSYM'
3138
     Variable in `.rodata' section; see *note Statics::.
3139
 
3140
`0x30     N_PC'
3141
     Global symbol (for Pascal); see *note N_PC::.
3142
 
3143
`0x32     N_NSYMS'
3144
     Number of symbols (according to Ultrix V4.0); see *note N_NSYMS::.
3145
 
3146
`0x34     N_NOMAP'
3147
     No DST map; see *note N_NOMAP::.
3148
 
3149
`0x36     N_MAC_DEFINE'
3150
     Name and body of a `#define'd macro; see *note Macro define and
3151
     undefine::.
3152
 
3153
`0x38 N_OBJ'
3154
     Object file (Solaris2).
3155
 
3156
`0x3a     N_MAC_UNDEF'
3157
     Name of an `#undef'ed macro; see *note Macro define and undefine::.
3158
 
3159
`0x3c N_OPT'
3160
     Debugger options (Solaris2).
3161
 
3162
`0x40     N_RSYM'
3163
     Register variable; see *note Register Variables::.
3164
 
3165
`0x42     N_M2C'
3166
     Modula-2 compilation unit; see *note N_M2C::.
3167
 
3168
`0x44     N_SLINE'
3169
     Line number in text segment; see *note Line Numbers::.
3170
 
3171
`0x46     N_DSLINE'
3172
     Line number in data segment; see *note Line Numbers::.
3173
 
3174
`0x48     N_BSLINE'
3175
     Line number in bss segment; see *note Line Numbers::.
3176
 
3177
`0x48     N_BROWS'
3178
     Sun source code browser, path to `.cb' file; see *note N_BROWS::.
3179
 
3180
`0x4a     N_DEFD'
3181
     GNU Modula2 definition module dependency; see *note N_DEFD::.
3182
 
3183
`0x4c N_FLINE'
3184
     Function start/body/end line numbers (Solaris2).
3185
 
3186
`0x50     N_EHDECL'
3187
     GNU C++ exception variable; see *note N_EHDECL::.
3188
 
3189
`0x50     N_MOD2'
3190
     Modula2 info "for imc" (according to Ultrix V4.0); see *note
3191
     N_MOD2::.
3192
 
3193
`0x54     N_CATCH'
3194
     GNU C++ `catch' clause; see *note N_CATCH::.
3195
 
3196
`0x60     N_SSYM'
3197
     Structure of union element; see *note N_SSYM::.
3198
 
3199
`0x62 N_ENDM'
3200
     Last stab for module (Solaris2).
3201
 
3202
`0x64     N_SO'
3203
     Path and name of source file; see *note Source Files::.
3204
 
3205
`0x80 N_LSYM'
3206
     Stack variable (*note Stack Variables::) or type (*note
3207
     Typedefs::).
3208
 
3209
`0x82     N_BINCL'
3210
     Beginning of an include file (Sun only); see *note Include Files::.
3211
 
3212
`0x84     N_SOL'
3213
     Name of include file; see *note Include Files::.
3214
 
3215
`0xa0     N_PSYM'
3216
     Parameter variable; see *note Parameters::.
3217
 
3218
`0xa2     N_EINCL'
3219
     End of an include file; see *note Include Files::.
3220
 
3221
`0xa4     N_ENTRY'
3222
     Alternate entry point; see *note Alternate Entry Points::.
3223
 
3224
`0xc0     N_LBRAC'
3225
     Beginning of a lexical block; see *note Block Structure::.
3226
 
3227
`0xc2     N_EXCL'
3228
     Place holder for a deleted include file; see *note Include Files::.
3229
 
3230
`0xc4     N_SCOPE'
3231
     Modula2 scope information (Sun linker); see *note N_SCOPE::.
3232
 
3233
`0xe0     N_RBRAC'
3234
     End of a lexical block; see *note Block Structure::.
3235
 
3236
`0xe2     N_BCOMM'
3237
     Begin named common block; see *note Common Blocks::.
3238
 
3239
`0xe4     N_ECOMM'
3240
     End named common block; see *note Common Blocks::.
3241
 
3242
`0xe8     N_ECOML'
3243
     Member of a common block; see *note Common Blocks::.
3244
 
3245
`0xea N_WITH'
3246
     Pascal `with' statement: type,,0,0,offset (Solaris2).
3247
 
3248
`0xf0     N_NBTEXT'
3249
     Gould non-base registers; see *note Gould::.
3250
 
3251
`0xf2     N_NBDATA'
3252
     Gould non-base registers; see *note Gould::.
3253
 
3254
`0xf4     N_NBBSS'
3255
     Gould non-base registers; see *note Gould::.
3256
 
3257
`0xf6     N_NBSTS'
3258
     Gould non-base registers; see *note Gould::.
3259
 
3260
`0xf8     N_NBLCS'
3261
     Gould non-base registers; see *note Gould::.
3262
 
3263

3264
File: stabs.info,  Node: Symbol Descriptors,  Next: Type Descriptors,  Prev: Stab Types,  Up: Top
3265
 
3266
Appendix B Table of Symbol Descriptors
3267
**************************************
3268
 
3269
The symbol descriptor is the character which follows the colon in many
3270
stabs, and which tells what kind of stab it is.  *Note String Field::,
3271
for more information about their use.
3272
 
3273
`DIGIT'
3274
`('
3275
`-'
3276
     Variable on the stack; see *note Stack Variables::.
3277
 
3278
`:'
3279
     C++ nested symbol; see *Note Nested Symbols::.
3280
 
3281
`a'
3282
     Parameter passed by reference in register; see *note Reference
3283
     Parameters::.
3284
 
3285
`b'
3286
     Based variable; see *note Based Variables::.
3287
 
3288
`c'
3289
     Constant; see *note Constants::.
3290
 
3291
`C'
3292
     Conformant array bound (Pascal, maybe other languages); *note
3293
     Conformant Arrays::.  Name of a caught exception (GNU C++).  These
3294
     can be distinguished because the latter uses `N_CATCH' and the
3295
     former uses another symbol type.
3296
 
3297
`d'
3298
     Floating point register variable; see *note Register Variables::.
3299
 
3300
`D'
3301
     Parameter in floating point register; see *note Register
3302
     Parameters::.
3303
 
3304
`f'
3305
     File scope function; see *note Procedures::.
3306
 
3307
`F'
3308
     Global function; see *note Procedures::.
3309
 
3310
`G'
3311
     Global variable; see *note Global Variables::.
3312
 
3313
`i'
3314
     *Note Register Parameters::.
3315
 
3316
`I'
3317
     Internal (nested) procedure; see *note Nested Procedures::.
3318
 
3319
`J'
3320
     Internal (nested) function; see *note Nested Procedures::.
3321
 
3322
`L'
3323
     Label name (documented by AIX, no further information known).
3324
 
3325
`m'
3326
     Module; see *note Procedures::.
3327
 
3328
`p'
3329
     Argument list parameter; see *note Parameters::.
3330
 
3331
`pP'
3332
     *Note Parameters::.
3333
 
3334
`pF'
3335
     Fortran Function parameter; see *note Parameters::.
3336
 
3337
`P'
3338
     Unfortunately, three separate meanings have been independently
3339
     invented for this symbol descriptor.  At least the GNU and Sun
3340
     uses can be distinguished by the symbol type.  Global Procedure
3341
     (AIX) (symbol type used unknown); see *note Procedures::.
3342
     Register parameter (GNU) (symbol type `N_PSYM'); see *note
3343
     Parameters::.  Prototype of function referenced by this file (Sun
3344
     `acc') (symbol type `N_FUN').
3345
 
3346
`Q'
3347
     Static Procedure; see *note Procedures::.
3348
 
3349
`R'
3350
     Register parameter; see *note Register Parameters::.
3351
 
3352
`r'
3353
     Register variable; see *note Register Variables::.
3354
 
3355
`S'
3356
     File scope variable; see *note Statics::.
3357
 
3358
`s'
3359
     Local variable (OS9000).
3360
 
3361
`t'
3362
     Type name; see *note Typedefs::.
3363
 
3364
`T'
3365
     Enumeration, structure, or union tag; see *note Typedefs::.
3366
 
3367
`v'
3368
     Parameter passed by reference; see *note Reference Parameters::.
3369
 
3370
`V'
3371
     Procedure scope static variable; see *note Statics::.
3372
 
3373
`x'
3374
     Conformant array; see *note Conformant Arrays::.
3375
 
3376
`X'
3377
     Function return variable; see *note Parameters::.
3378
 
3379

3380
File: stabs.info,  Node: Type Descriptors,  Next: Expanded Reference,  Prev: Symbol Descriptors,  Up: Top
3381
 
3382
Appendix C Table of Type Descriptors
3383
************************************
3384
 
3385
The type descriptor is the character which follows the type number and
3386
an equals sign.  It specifies what kind of type is being defined.
3387
*Note String Field::, for more information about their use.
3388
 
3389
`DIGIT'
3390
`('
3391
     Type reference; see *note String Field::.
3392
 
3393
`-'
3394
     Reference to builtin type; see *note Negative Type Numbers::.
3395
 
3396
`#'
3397
     Method (C++); see *note Method Type Descriptor::.
3398
 
3399
`*'
3400
     Pointer; see *note Miscellaneous Types::.
3401
 
3402
`&'
3403
     Reference (C++).
3404
 
3405
`@'
3406
     Type Attributes (AIX); see *note String Field::.  Member (class
3407
     and variable) type (GNU C++); see *note Member Type Descriptor::.
3408
 
3409
`a'
3410
     Array; see *note Arrays::.
3411
 
3412
`A'
3413
     Open array; see *note Arrays::.
3414
 
3415
`b'
3416
     Pascal space type (AIX); see *note Miscellaneous Types::.  Builtin
3417
     integer type (Sun); see *note Builtin Type Descriptors::.  Const
3418
     and volatile qualified type (OS9000).
3419
 
3420
`B'
3421
     Volatile-qualified type; see *note Miscellaneous Types::.
3422
 
3423
`c'
3424
     Complex builtin type (AIX); see *note Builtin Type Descriptors::.
3425
     Const-qualified type (OS9000).
3426
 
3427
`C'
3428
     COBOL Picture type.  See AIX documentation for details.
3429
 
3430
`d'
3431
     File type; see *note Miscellaneous Types::.
3432
 
3433
`D'
3434
     N-dimensional dynamic array; see *note Arrays::.
3435
 
3436
`e'
3437
     Enumeration type; see *note Enumerations::.
3438
 
3439
`E'
3440
     N-dimensional subarray; see *note Arrays::.
3441
 
3442
`f'
3443
     Function type; see *note Function Types::.
3444
 
3445
`F'
3446
     Pascal function parameter; see *note Function Types::
3447
 
3448
`g'
3449
     Builtin floating point type; see *note Builtin Type Descriptors::.
3450
 
3451
`G'
3452
     COBOL Group.  See AIX documentation for details.
3453
 
3454
`i'
3455
     Imported type (AIX); see *note Cross-References::.
3456
     Volatile-qualified type (OS9000).
3457
 
3458
`k'
3459
     Const-qualified type; see *note Miscellaneous Types::.
3460
 
3461
`K'
3462
     COBOL File Descriptor.  See AIX documentation for details.
3463
 
3464
`M'
3465
     Multiple instance type; see *note Miscellaneous Types::.
3466
 
3467
`n'
3468
     String type; see *note Strings::.
3469
 
3470
`N'
3471
     Stringptr; see *note Strings::.
3472
 
3473
`o'
3474
     Opaque type; see *note Typedefs::.
3475
 
3476
`p'
3477
     Procedure; see *note Function Types::.
3478
 
3479
`P'
3480
     Packed array; see *note Arrays::.
3481
 
3482
`r'
3483
     Range type; see *note Subranges::.
3484
 
3485
`R'
3486
     Builtin floating type; see *note Builtin Type Descriptors:: (Sun).
3487
     Pascal subroutine parameter; see *note Function Types:: (AIX).
3488
     Detecting this conflict is possible with careful parsing (hint: a
3489
     Pascal subroutine parameter type will always contain a comma, and
3490
     a builtin type descriptor never will).
3491
 
3492
`s'
3493
     Structure type; see *note Structures::.
3494
 
3495
`S'
3496
     Set type; see *note Miscellaneous Types::.
3497
 
3498
`u'
3499
     Union; see *note Unions::.
3500
 
3501
`v'
3502
     Variant record.  This is a Pascal and Modula-2 feature which is
3503
     like a union within a struct in C.  See AIX documentation for
3504
     details.
3505
 
3506
`w'
3507
     Wide character; see *note Builtin Type Descriptors::.
3508
 
3509
`x'
3510
     Cross-reference; see *note Cross-References::.
3511
 
3512
`Y'
3513
     Used by IBM's xlC C++ compiler (for structures, I think).
3514
 
3515
`z'
3516
     gstring; see *note Strings::.
3517
 
3518

3519
File: stabs.info,  Node: Expanded Reference,  Next: Questions,  Prev: Type Descriptors,  Up: Top
3520
 
3521
Appendix D Expanded Reference by Stab Type
3522
******************************************
3523
 
3524
For a full list of stab types, and cross-references to where they are
3525
described, see *note Stab Types::.  This appendix just covers certain
3526
stabs which are not yet described in the main body of this document;
3527
eventually the information will all be in one place.
3528
 
3529
   Format of an entry:
3530
 
3531
   The first line is the symbol type (see `include/aout/stab.def').
3532
 
3533
   The second line describes the language constructs the symbol type
3534
represents.
3535
 
3536
   The third line is the stab format with the significant stab fields
3537
named and the rest NIL.
3538
 
3539
   Subsequent lines expand upon the meaning and possible values for each
3540
significant stab field.
3541
 
3542
   Finally, any further information.
3543
 
3544
* Menu:
3545
 
3546
* N_PC::                        Pascal global symbol
3547
* N_NSYMS::                     Number of symbols
3548
* N_NOMAP::                     No DST map
3549
* N_M2C::                       Modula-2 compilation unit
3550
* N_BROWS::                     Path to .cb file for Sun source code browser
3551
* N_DEFD::                      GNU Modula2 definition module dependency
3552
* N_EHDECL::                    GNU C++ exception variable
3553
* N_MOD2::                      Modula2 information "for imc"
3554
* N_CATCH::                     GNU C++ "catch" clause
3555
* N_SSYM::                      Structure or union element
3556
* N_SCOPE::                     Modula2 scope information (Sun only)
3557
* Gould::                       non-base register symbols used on Gould systems
3558
* N_LENG::                      Length of preceding entry
3559
 
3560

3561
File: stabs.info,  Node: N_PC,  Next: N_NSYMS,  Up: Expanded Reference
3562
 
3563
D.1 N_PC
3564
========
3565
 
3566
 -- `.stabs': N_PC
3567
     Global symbol (for Pascal).
3568
 
3569
          "name" -> "symbol_name"  <>
3570
          value  -> supposedly the line number (stab.def is skeptical)
3571
 
3572
          `stabdump.c' says:
3573
 
3574
          global pascal symbol: name,,0,subtype,line
3575
          << subtype? >>
3576
 
3577

3578
File: stabs.info,  Node: N_NSYMS,  Next: N_NOMAP,  Prev: N_PC,  Up: Expanded Reference
3579
 
3580
D.2 N_NSYMS
3581
===========
3582
 
3583
 -- `.stabn': N_NSYMS
3584
     Number of symbols (according to Ultrix V4.0).
3585
 
3586
                  0, files,,funcs,lines (stab.def)
3587
 
3588

3589
File: stabs.info,  Node: N_NOMAP,  Next: N_M2C,  Prev: N_NSYMS,  Up: Expanded Reference
3590
 
3591
D.3 N_NOMAP
3592
===========
3593
 
3594
 -- `.stabs': N_NOMAP
3595
     No DST map for symbol (according to Ultrix V4.0).  I think this
3596
     means a variable has been optimized out.
3597
 
3598
                  name, ,0,type,ignored (stab.def)
3599
 
3600

3601
File: stabs.info,  Node: N_M2C,  Next: N_BROWS,  Prev: N_NOMAP,  Up: Expanded Reference
3602
 
3603
D.4 N_M2C
3604
=========
3605
 
3606
 -- `.stabs': N_M2C
3607
     Modula-2 compilation unit.
3608
 
3609
          "string" -> "unit_name,unit_time_stamp[,code_time_stamp]"
3610
          desc   -> unit_number
3611
          value  -> 0 (main unit)
3612
                    1 (any other unit)
3613
 
3614
     See `Dbx and Dbxtool Interfaces', 2nd edition, by Sun, 1988, for
3615
     more information.
3616
 
3617
 
3618

3619
File: stabs.info,  Node: N_BROWS,  Next: N_DEFD,  Prev: N_M2C,  Up: Expanded Reference
3620
 
3621
D.5 N_BROWS
3622
===========
3623
 
3624
 -- `.stabs': N_BROWS
3625
     Sun source code browser, path to `.cb' file
3626
 
3627
     <> "path to associated `.cb' file"
3628
 
3629
     Note: N_BROWS has the same value as N_BSLINE.
3630
 
3631

3632
File: stabs.info,  Node: N_DEFD,  Next: N_EHDECL,  Prev: N_BROWS,  Up: Expanded Reference
3633
 
3634
D.6 N_DEFD
3635
==========
3636
 
3637
 -- `.stabn': N_DEFD
3638
     GNU Modula2 definition module dependency.
3639
 
3640
     GNU Modula-2 definition module dependency.  The value is the
3641
     modification time of the definition file.  The other field is
3642
     non-zero if it is imported with the GNU M2 keyword `%INITIALIZE'.
3643
     Perhaps `N_M2C' can be used if there are enough empty fields?
3644
 
3645

3646
File: stabs.info,  Node: N_EHDECL,  Next: N_MOD2,  Prev: N_DEFD,  Up: Expanded Reference
3647
 
3648
D.7 N_EHDECL
3649
============
3650
 
3651
 -- `.stabs': N_EHDECL
3652
     GNU C++ exception variable <>.
3653
 
3654
     "STRING is variable name"
3655
 
3656
     Note: conflicts with `N_MOD2'.
3657
 
3658

3659
File: stabs.info,  Node: N_MOD2,  Next: N_CATCH,  Prev: N_EHDECL,  Up: Expanded Reference
3660
 
3661
D.8 N_MOD2
3662
==========
3663
 
3664
 -- `.stab?': N_MOD2
3665
     Modula2 info "for imc" (according to Ultrix V4.0)
3666
 
3667
     Note: conflicts with `N_EHDECL'  <>
3668
 
3669

3670
File: stabs.info,  Node: N_CATCH,  Next: N_SSYM,  Prev: N_MOD2,  Up: Expanded Reference
3671
 
3672
D.9 N_CATCH
3673
===========
3674
 
3675
 -- `.stabn': N_CATCH
3676
     GNU C++ `catch' clause
3677
 
3678
     GNU C++ `catch' clause.  The value is its address.  The desc field
3679
     is nonzero if this entry is immediately followed by a `CAUGHT' stab
3680
     saying what exception was caught.  Multiple `CAUGHT' stabs means
3681
     that multiple exceptions can be caught here.  If desc is 0, it
3682
     means all exceptions are caught here.
3683
 
3684

3685
File: stabs.info,  Node: N_SSYM,  Next: N_SCOPE,  Prev: N_CATCH,  Up: Expanded Reference
3686
 
3687
D.10 N_SSYM
3688
===========
3689
 
3690
 -- `.stabn': N_SSYM
3691
     Structure or union element.
3692
 
3693
     The value is the offset in the structure.
3694
 
3695
     <>
3696
 
3697

3698
File: stabs.info,  Node: N_SCOPE,  Next: Gould,  Prev: N_SSYM,  Up: Expanded Reference
3699
 
3700
D.11 N_SCOPE
3701
============
3702
 
3703
 -- `.stab?': N_SCOPE
3704
     Modula2 scope information (Sun linker) <>
3705
 
3706

3707
File: stabs.info,  Node: Gould,  Next: N_LENG,  Prev: N_SCOPE,  Up: Expanded Reference
3708
 
3709
D.12 Non-base registers on Gould systems
3710
========================================
3711
 
3712
 -- `.stab?': N_NBTEXT
3713
 -- `.stab?': N_NBDATA
3714
 -- `.stab?': N_NBBSS
3715
 -- `.stab?': N_NBSTS
3716
 -- `.stab?': N_NBLCS
3717
     These are used on Gould systems for non-base registers syms.
3718
 
3719
     However, the following values are not the values used by Gould;
3720
     they are the values which GNU has been documenting for these
3721
     values for a long time, without actually checking what Gould uses.
3722
     I include these values only because perhaps some someone actually
3723
     did something with the GNU information (I hope not, why GNU
3724
     knowingly assigned wrong values to these in the header file is a
3725
     complete mystery to me).
3726
 
3727
          240    0xf0     N_NBTEXT  ??
3728
          242    0xf2     N_NBDATA  ??
3729
          244    0xf4     N_NBBSS   ??
3730
          246    0xf6     N_NBSTS   ??
3731
          248    0xf8     N_NBLCS   ??
3732
 
3733

3734
File: stabs.info,  Node: N_LENG,  Prev: Gould,  Up: Expanded Reference
3735
 
3736
D.13 N_LENG
3737
===========
3738
 
3739
 -- `.stabn': N_LENG
3740
     Second symbol entry containing a length-value for the preceding
3741
     entry.  The value is the length.
3742
 
3743

3744
File: stabs.info,  Node: Questions,  Next: Stab Sections,  Prev: Expanded Reference,  Up: Top
3745
 
3746
Appendix E Questions and Anomalies
3747
**********************************
3748
 
3749
   * For GNU C stabs defining local and global variables (`N_LSYM' and
3750
     `N_GSYM'), the desc field is supposed to contain the source line
3751
     number on which the variable is defined.  In reality the desc
3752
     field is always 0.  (This behavior is defined in `dbxout.c' and
3753
     putting a line number in desc is controlled by `#ifdef
3754
     WINNING_GDB', which defaults to false). GDB supposedly uses this
3755
     information if you say `list VAR'.  In reality, VAR can be a
3756
     variable defined in the program and GDB says `function VAR not
3757
     defined'.
3758
 
3759
   * In GNU C stabs, there seems to be no way to differentiate tag
3760
     types: structures, unions, and enums (symbol descriptor `T') and
3761
     typedefs (symbol descriptor `t') defined at file scope from types
3762
     defined locally to a procedure or other more local scope.  They
3763
     all use the `N_LSYM' stab type.  Types defined at procedure scope
3764
     are emitted after the `N_RBRAC' of the preceding function and
3765
     before the code of the procedure in which they are defined.  This
3766
     is exactly the same as types defined in the source file between
3767
     the two procedure bodies.  GDB over-compensates by placing all
3768
     types in block #1, the block for symbols of file scope.  This is
3769
     true for default, `-ansi' and `-traditional' compiler options.
3770
     (Bugs gcc/1063, gdb/1066.)
3771
 
3772
   * What ends the procedure scope?  Is it the proc block's `N_RBRAC'
3773
     or the next `N_FUN'?  (I believe its the first.)
3774
 
3775

3776
File: stabs.info,  Node: Stab Sections,  Next: GNU Free Documentation License,  Prev: Questions,  Up: Top
3777
 
3778
Appendix F Using Stabs in Their Own Sections
3779
********************************************
3780
 
3781
Many object file formats allow tools to create object files with custom
3782
sections containing any arbitrary data.  For any such object file
3783
format, stabs can be embedded in special sections.  This is how stabs
3784
are used with ELF and SOM, and aside from ECOFF and XCOFF, is how stabs
3785
are used with COFF.
3786
 
3787
* Menu:
3788
 
3789
* Stab Section Basics::    How to embed stabs in sections
3790
* ELF Linker Relocation::  Sun ELF hacks
3791
 
3792

3793
File: stabs.info,  Node: Stab Section Basics,  Next: ELF Linker Relocation,  Up: Stab Sections
3794
 
3795
F.1 How to Embed Stabs in Sections
3796
==================================
3797
 
3798
The assembler creates two custom sections, a section named `.stab'
3799
which contains an array of fixed length structures, one struct per stab,
3800
and a section named `.stabstr' containing all the variable length
3801
strings that are referenced by stabs in the `.stab' section.  The byte
3802
order of the stabs binary data depends on the object file format.  For
3803
ELF, it matches the byte order of the ELF file itself, as determined
3804
from the `EI_DATA' field in the `e_ident' member of the ELF header.
3805
For SOM, it is always big-endian (is this true??? FIXME).  For COFF, it
3806
matches the byte order of the COFF headers.  The meaning of the fields
3807
is the same as for a.out (*note Symbol Table Format::), except that the
3808
`n_strx' field is relative to the strings for the current compilation
3809
unit (which can be found using the synthetic N_UNDF stab described
3810
below), rather than the entire string table.
3811
 
3812
   The first stab in the `.stab' section for each compilation unit is
3813
synthetic, generated entirely by the assembler, with no corresponding
3814
`.stab' directive as input to the assembler.  This stab contains the
3815
following fields:
3816
 
3817
`n_strx'
3818
     Offset in the `.stabstr' section to the source filename.
3819
 
3820
`n_type'
3821
     `N_UNDF'.
3822
 
3823
`n_other'
3824
     Unused field, always zero.  This may eventually be used to hold
3825
     overflows from the count in the `n_desc' field.
3826
 
3827
`n_desc'
3828
     Count of upcoming symbols, i.e., the number of remaining stabs for
3829
     this source file.
3830
 
3831
`n_value'
3832
     Size of the string table fragment associated with this source
3833
     file, in bytes.
3834
 
3835
   The `.stabstr' section always starts with a null byte (so that string
3836
offsets of zero reference a null string), followed by random length
3837
strings, each of which is null byte terminated.
3838
 
3839
   The ELF section header for the `.stab' section has its `sh_link'
3840
member set to the section number of the `.stabstr' section, and the
3841
`.stabstr' section has its ELF section header `sh_type' member set to
3842
`SHT_STRTAB' to mark it as a string table.  SOM and COFF have no way of
3843
linking the sections together or marking them as string tables.
3844
 
3845
   For COFF, the `.stab' and `.stabstr' sections may be simply
3846
concatenated by the linker.  GDB then uses the `n_desc' fields to
3847
figure out the extent of the original sections.  Similarly, the
3848
`n_value' fields of the header symbols are added together in order to
3849
get the actual position of the strings in a desired `.stabstr' section.
3850
Although this design obviates any need for the linker to relocate or
3851
otherwise manipulate `.stab' and `.stabstr' sections, it also requires
3852
some care to ensure that the offsets are calculated correctly.  For
3853
instance, if the linker were to pad in between the `.stabstr' sections
3854
before concatenating, then the offsets to strings in the middle of the
3855
executable's `.stabstr' section would be wrong.
3856
 
3857
   The GNU linker is able to optimize stabs information by merging
3858
duplicate strings and removing duplicate header file information (*note
3859
Include Files::).  When some versions of the GNU linker optimize stabs
3860
in sections, they remove the leading `N_UNDF' symbol and arranges for
3861
all the `n_strx' fields to be relative to the start of the `.stabstr'
3862
section.
3863
 
3864

3865
File: stabs.info,  Node: ELF Linker Relocation,  Prev: Stab Section Basics,  Up: Stab Sections
3866
 
3867
F.2 Having the Linker Relocate Stabs in ELF
3868
===========================================
3869
 
3870
This section describes some Sun hacks for Stabs in ELF; it does not
3871
apply to COFF or SOM.
3872
 
3873
   To keep linking fast, you don't want the linker to have to relocate
3874
very many stabs.  Making sure this is done for `N_SLINE', `N_RBRAC',
3875
and `N_LBRAC' stabs is the most important thing (see the descriptions
3876
of those stabs for more information).  But Sun's stabs in ELF has taken
3877
this further, to make all addresses in the `n_value' field (functions
3878
and static variables) relative to the source file.  For the `N_SO'
3879
symbol itself, Sun simply omits the address.  To find the address of
3880
each section corresponding to a given source file, the compiler puts
3881
out symbols giving the address of each section for a given source file.
3882
Since these are ELF (not stab) symbols, the linker relocates them
3883
correctly without having to touch the stabs section.  They are named
3884
`Bbss.bss' for the bss section, `Ddata.data' for the data section, and
3885
`Drodata.rodata' for the rodata section.  For the text section, there
3886
is no such symbol (but there should be, see below).  For an example of
3887
how these symbols work, *Note Stab Section Transformations::.  GCC does
3888
not provide these symbols; it instead relies on the stabs getting
3889
relocated.  Thus addresses which would normally be relative to
3890
`Bbss.bss', etc., are already relocated.  The Sun linker provided with
3891
Solaris 2.2 and earlier relocates stabs using normal ELF relocation
3892
information, as it would do for any section.  Sun has been threatening
3893
to kludge their linker to not do this (to speed up linking), even
3894
though the correct way to avoid having the linker do these relocations
3895
is to have the compiler no longer output relocatable values.  Last I
3896
heard they had been talked out of the linker kludge.  See Sun point
3897
patch 101052-01 and Sun bug 1142109.  With the Sun compiler this
3898
affects `S' symbol descriptor stabs (*note Statics::) and functions
3899
(*note Procedures::).  In the latter case, to adopt the clean solution
3900
(making the value of the stab relative to the start of the compilation
3901
unit), it would be necessary to invent a `Ttext.text' symbol, analogous
3902
to the `Bbss.bss', etc., symbols.  I recommend this rather than using a
3903
zero value and getting the address from the ELF symbols.
3904
 
3905
   Finding the correct `Bbss.bss', etc., symbol is difficult, because
3906
the linker simply concatenates the `.stab' sections from each `.o' file
3907
without including any information about which part of a `.stab' section
3908
comes from which `.o' file.  The way GDB does this is to look for an
3909
ELF `STT_FILE' symbol which has the same name as the last component of
3910
the file name from the `N_SO' symbol in the stabs (for example, if the
3911
file name is `../../gdb/main.c', it looks for an ELF `STT_FILE' symbol
3912
named `main.c').  This loses if different files have the same name
3913
(they could be in different directories, a library could have been
3914
copied from one system to another, etc.).  It would be much cleaner to
3915
have the `Bbss.bss' symbols in the stabs themselves.  Having the linker
3916
relocate them there is no more work than having the linker relocate ELF
3917
symbols, and it solves the problem of having to associate the ELF and
3918
stab symbols.  However, no one has yet designed or implemented such a
3919
scheme.
3920
 
3921

3922
File: stabs.info,  Node: GNU Free Documentation License,  Next: Symbol Types Index,  Prev: Stab Sections,  Up: Top
3923
 
3924
Appendix G GNU Free Documentation License
3925
*****************************************
3926
 
3927
                     Version 1.3, 3 November 2008
3928
 
3929
     Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
3930
     `http://fsf.org/'
3931
 
3932
     Everyone is permitted to copy and distribute verbatim copies
3933
     of this license document, but changing it is not allowed.
3934
 
3935
  0. PREAMBLE
3936
 
3937
     The purpose of this License is to make a manual, textbook, or other
3938
     functional and useful document "free" in the sense of freedom: to
3939
     assure everyone the effective freedom to copy and redistribute it,
3940
     with or without modifying it, either commercially or
3941
     noncommercially.  Secondarily, this License preserves for the
3942
     author and publisher a way to get credit for their work, while not
3943
     being considered responsible for modifications made by others.
3944
 
3945
     This License is a kind of "copyleft", which means that derivative
3946
     works of the document must themselves be free in the same sense.
3947
     It complements the GNU General Public License, which is a copyleft
3948
     license designed for free software.
3949
 
3950
     We have designed this License in order to use it for manuals for
3951
     free software, because free software needs free documentation: a
3952
     free program should come with manuals providing the same freedoms
3953
     that the software does.  But this License is not limited to
3954
     software manuals; it can be used for any textual work, regardless
3955
     of subject matter or whether it is published as a printed book.
3956
     We recommend this License principally for works whose purpose is
3957
     instruction or reference.
3958
 
3959
  1. APPLICABILITY AND DEFINITIONS
3960
 
3961
     This License applies to any manual or other work, in any medium,
3962
     that contains a notice placed by the copyright holder saying it
3963
     can be distributed under the terms of this License.  Such a notice
3964
     grants a world-wide, royalty-free license, unlimited in duration,
3965
     to use that work under the conditions stated herein.  The
3966
     "Document", below, refers to any such manual or work.  Any member
3967
     of the public is a licensee, and is addressed as "you".  You
3968
     accept the license if you copy, modify or distribute the work in a
3969
     way requiring permission under copyright law.
3970
 
3971
     A "Modified Version" of the Document means any work containing the
3972
     Document or a portion of it, either copied verbatim, or with
3973
     modifications and/or translated into another language.
3974
 
3975
     A "Secondary Section" is a named appendix or a front-matter section
3976
     of the Document that deals exclusively with the relationship of the
3977
     publishers or authors of the Document to the Document's overall
3978
     subject (or to related matters) and contains nothing that could
3979
     fall directly within that overall subject.  (Thus, if the Document
3980
     is in part a textbook of mathematics, a Secondary Section may not
3981
     explain any mathematics.)  The relationship could be a matter of
3982
     historical connection with the subject or with related matters, or
3983
     of legal, commercial, philosophical, ethical or political position
3984
     regarding them.
3985
 
3986
     The "Invariant Sections" are certain Secondary Sections whose
3987
     titles are designated, as being those of Invariant Sections, in
3988
     the notice that says that the Document is released under this
3989
     License.  If a section does not fit the above definition of
3990
     Secondary then it is not allowed to be designated as Invariant.
3991
     The Document may contain zero Invariant Sections.  If the Document
3992
     does not identify any Invariant Sections then there are none.
3993
 
3994
     The "Cover Texts" are certain short passages of text that are
3995
     listed, as Front-Cover Texts or Back-Cover Texts, in the notice
3996
     that says that the Document is released under this License.  A
3997
     Front-Cover Text may be at most 5 words, and a Back-Cover Text may
3998
     be at most 25 words.
3999
 
4000
     A "Transparent" copy of the Document means a machine-readable copy,
4001
     represented in a format whose specification is available to the
4002
     general public, that is suitable for revising the document
4003
     straightforwardly with generic text editors or (for images
4004
     composed of pixels) generic paint programs or (for drawings) some
4005
     widely available drawing editor, and that is suitable for input to
4006
     text formatters or for automatic translation to a variety of
4007
     formats suitable for input to text formatters.  A copy made in an
4008
     otherwise Transparent file format whose markup, or absence of
4009
     markup, has been arranged to thwart or discourage subsequent
4010
     modification by readers is not Transparent.  An image format is
4011
     not Transparent if used for any substantial amount of text.  A
4012
     copy that is not "Transparent" is called "Opaque".
4013
 
4014
     Examples of suitable formats for Transparent copies include plain
4015
     ASCII without markup, Texinfo input format, LaTeX input format,
4016
     SGML or XML using a publicly available DTD, and
4017
     standard-conforming simple HTML, PostScript or PDF designed for
4018
     human modification.  Examples of transparent image formats include
4019
     PNG, XCF and JPG.  Opaque formats include proprietary formats that
4020
     can be read and edited only by proprietary word processors, SGML or
4021
     XML for which the DTD and/or processing tools are not generally
4022
     available, and the machine-generated HTML, PostScript or PDF
4023
     produced by some word processors for output purposes only.
4024
 
4025
     The "Title Page" means, for a printed book, the title page itself,
4026
     plus such following pages as are needed to hold, legibly, the
4027
     material this License requires to appear in the title page.  For
4028
     works in formats which do not have any title page as such, "Title
4029
     Page" means the text near the most prominent appearance of the
4030
     work's title, preceding the beginning of the body of the text.
4031
 
4032
     The "publisher" means any person or entity that distributes copies
4033
     of the Document to the public.
4034
 
4035
     A section "Entitled XYZ" means a named subunit of the Document
4036
     whose title either is precisely XYZ or contains XYZ in parentheses
4037
     following text that translates XYZ in another language.  (Here XYZ
4038
     stands for a specific section name mentioned below, such as
4039
     "Acknowledgements", "Dedications", "Endorsements", or "History".)
4040
     To "Preserve the Title" of such a section when you modify the
4041
     Document means that it remains a section "Entitled XYZ" according
4042
     to this definition.
4043
 
4044
     The Document may include Warranty Disclaimers next to the notice
4045
     which states that this License applies to the Document.  These
4046
     Warranty Disclaimers are considered to be included by reference in
4047
     this License, but only as regards disclaiming warranties: any other
4048
     implication that these Warranty Disclaimers may have is void and
4049
     has no effect on the meaning of this License.
4050
 
4051
  2. VERBATIM COPYING
4052
 
4053
     You may copy and distribute the Document in any medium, either
4054
     commercially or noncommercially, provided that this License, the
4055
     copyright notices, and the license notice saying this License
4056
     applies to the Document are reproduced in all copies, and that you
4057
     add no other conditions whatsoever to those of this License.  You
4058
     may not use technical measures to obstruct or control the reading
4059
     or further copying of the copies you make or distribute.  However,
4060
     you may accept compensation in exchange for copies.  If you
4061
     distribute a large enough number of copies you must also follow
4062
     the conditions in section 3.
4063
 
4064
     You may also lend copies, under the same conditions stated above,
4065
     and you may publicly display copies.
4066
 
4067
  3. COPYING IN QUANTITY
4068
 
4069
     If you publish printed copies (or copies in media that commonly
4070
     have printed covers) of the Document, numbering more than 100, and
4071
     the Document's license notice requires Cover Texts, you must
4072
     enclose the copies in covers that carry, clearly and legibly, all
4073
     these Cover Texts: Front-Cover Texts on the front cover, and
4074
     Back-Cover Texts on the back cover.  Both covers must also clearly
4075
     and legibly identify you as the publisher of these copies.  The
4076
     front cover must present the full title with all words of the
4077
     title equally prominent and visible.  You may add other material
4078
     on the covers in addition.  Copying with changes limited to the
4079
     covers, as long as they preserve the title of the Document and
4080
     satisfy these conditions, can be treated as verbatim copying in
4081
     other respects.
4082
 
4083
     If the required texts for either cover are too voluminous to fit
4084
     legibly, you should put the first ones listed (as many as fit
4085
     reasonably) on the actual cover, and continue the rest onto
4086
     adjacent pages.
4087
 
4088
     If you publish or distribute Opaque copies of the Document
4089
     numbering more than 100, you must either include a
4090
     machine-readable Transparent copy along with each Opaque copy, or
4091
     state in or with each Opaque copy a computer-network location from
4092
     which the general network-using public has access to download
4093
     using public-standard network protocols a complete Transparent
4094
     copy of the Document, free of added material.  If you use the
4095
     latter option, you must take reasonably prudent steps, when you
4096
     begin distribution of Opaque copies in quantity, to ensure that
4097
     this Transparent copy will remain thus accessible at the stated
4098
     location until at least one year after the last time you
4099
     distribute an Opaque copy (directly or through your agents or
4100
     retailers) of that edition to the public.
4101
 
4102
     It is requested, but not required, that you contact the authors of
4103
     the Document well before redistributing any large number of
4104
     copies, to give them a chance to provide you with an updated
4105
     version of the Document.
4106
 
4107
  4. MODIFICATIONS
4108
 
4109
     You may copy and distribute a Modified Version of the Document
4110
     under the conditions of sections 2 and 3 above, provided that you
4111
     release the Modified Version under precisely this License, with
4112
     the Modified Version filling the role of the Document, thus
4113
     licensing distribution and modification of the Modified Version to
4114
     whoever possesses a copy of it.  In addition, you must do these
4115
     things in the Modified Version:
4116
 
4117
       A. Use in the Title Page (and on the covers, if any) a title
4118
          distinct from that of the Document, and from those of
4119
          previous versions (which should, if there were any, be listed
4120
          in the History section of the Document).  You may use the
4121
          same title as a previous version if the original publisher of
4122
          that version gives permission.
4123
 
4124
       B. List on the Title Page, as authors, one or more persons or
4125
          entities responsible for authorship of the modifications in
4126
          the Modified Version, together with at least five of the
4127
          principal authors of the Document (all of its principal
4128
          authors, if it has fewer than five), unless they release you
4129
          from this requirement.
4130
 
4131
       C. State on the Title page the name of the publisher of the
4132
          Modified Version, as the publisher.
4133
 
4134
       D. Preserve all the copyright notices of the Document.
4135
 
4136
       E. Add an appropriate copyright notice for your modifications
4137
          adjacent to the other copyright notices.
4138
 
4139
       F. Include, immediately after the copyright notices, a license
4140
          notice giving the public permission to use the Modified
4141
          Version under the terms of this License, in the form shown in
4142
          the Addendum below.
4143
 
4144
       G. Preserve in that license notice the full lists of Invariant
4145
          Sections and required Cover Texts given in the Document's
4146
          license notice.
4147
 
4148
       H. Include an unaltered copy of this License.
4149
 
4150
       I. Preserve the section Entitled "History", Preserve its Title,
4151
          and add to it an item stating at least the title, year, new
4152
          authors, and publisher of the Modified Version as given on
4153
          the Title Page.  If there is no section Entitled "History" in
4154
          the Document, create one stating the title, year, authors,
4155
          and publisher of the Document as given on its Title Page,
4156
          then add an item describing the Modified Version as stated in
4157
          the previous sentence.
4158
 
4159
       J. Preserve the network location, if any, given in the Document
4160
          for public access to a Transparent copy of the Document, and
4161
          likewise the network locations given in the Document for
4162
          previous versions it was based on.  These may be placed in
4163
          the "History" section.  You may omit a network location for a
4164
          work that was published at least four years before the
4165
          Document itself, or if the original publisher of the version
4166
          it refers to gives permission.
4167
 
4168
       K. For any section Entitled "Acknowledgements" or "Dedications",
4169
          Preserve the Title of the section, and preserve in the
4170
          section all the substance and tone of each of the contributor
4171
          acknowledgements and/or dedications given therein.
4172
 
4173
       L. Preserve all the Invariant Sections of the Document,
4174
          unaltered in their text and in their titles.  Section numbers
4175
          or the equivalent are not considered part of the section
4176
          titles.
4177
 
4178
       M. Delete any section Entitled "Endorsements".  Such a section
4179
          may not be included in the Modified Version.
4180
 
4181
       N. Do not retitle any existing section to be Entitled
4182
          "Endorsements" or to conflict in title with any Invariant
4183
          Section.
4184
 
4185
       O. Preserve any Warranty Disclaimers.
4186
 
4187
     If the Modified Version includes new front-matter sections or
4188
     appendices that qualify as Secondary Sections and contain no
4189
     material copied from the Document, you may at your option
4190
     designate some or all of these sections as invariant.  To do this,
4191
     add their titles to the list of Invariant Sections in the Modified
4192
     Version's license notice.  These titles must be distinct from any
4193
     other section titles.
4194
 
4195
     You may add a section Entitled "Endorsements", provided it contains
4196
     nothing but endorsements of your Modified Version by various
4197
     parties--for example, statements of peer review or that the text
4198
     has been approved by an organization as the authoritative
4199
     definition of a standard.
4200
 
4201
     You may add a passage of up to five words as a Front-Cover Text,
4202
     and a passage of up to 25 words as a Back-Cover Text, to the end
4203
     of the list of Cover Texts in the Modified Version.  Only one
4204
     passage of Front-Cover Text and one of Back-Cover Text may be
4205
     added by (or through arrangements made by) any one entity.  If the
4206
     Document already includes a cover text for the same cover,
4207
     previously added by you or by arrangement made by the same entity
4208
     you are acting on behalf of, you may not add another; but you may
4209
     replace the old one, on explicit permission from the previous
4210
     publisher that added the old one.
4211
 
4212
     The author(s) and publisher(s) of the Document do not by this
4213
     License give permission to use their names for publicity for or to
4214
     assert or imply endorsement of any Modified Version.
4215
 
4216
  5. COMBINING DOCUMENTS
4217
 
4218
     You may combine the Document with other documents released under
4219
     this License, under the terms defined in section 4 above for
4220
     modified versions, provided that you include in the combination
4221
     all of the Invariant Sections of all of the original documents,
4222
     unmodified, and list them all as Invariant Sections of your
4223
     combined work in its license notice, and that you preserve all
4224
     their Warranty Disclaimers.
4225
 
4226
     The combined work need only contain one copy of this License, and
4227
     multiple identical Invariant Sections may be replaced with a single
4228
     copy.  If there are multiple Invariant Sections with the same name
4229
     but different contents, make the title of each such section unique
4230
     by adding at the end of it, in parentheses, the name of the
4231
     original author or publisher of that section if known, or else a
4232
     unique number.  Make the same adjustment to the section titles in
4233
     the list of Invariant Sections in the license notice of the
4234
     combined work.
4235
 
4236
     In the combination, you must combine any sections Entitled
4237
     "History" in the various original documents, forming one section
4238
     Entitled "History"; likewise combine any sections Entitled
4239
     "Acknowledgements", and any sections Entitled "Dedications".  You
4240
     must delete all sections Entitled "Endorsements."
4241
 
4242
  6. COLLECTIONS OF DOCUMENTS
4243
 
4244
     You may make a collection consisting of the Document and other
4245
     documents released under this License, and replace the individual
4246
     copies of this License in the various documents with a single copy
4247
     that is included in the collection, provided that you follow the
4248
     rules of this License for verbatim copying of each of the
4249
     documents in all other respects.
4250
 
4251
     You may extract a single document from such a collection, and
4252
     distribute it individually under this License, provided you insert
4253
     a copy of this License into the extracted document, and follow
4254
     this License in all other respects regarding verbatim copying of
4255
     that document.
4256
 
4257
  7. AGGREGATION WITH INDEPENDENT WORKS
4258
 
4259
     A compilation of the Document or its derivatives with other
4260
     separate and independent documents or works, in or on a volume of
4261
     a storage or distribution medium, is called an "aggregate" if the
4262
     copyright resulting from the compilation is not used to limit the
4263
     legal rights of the compilation's users beyond what the individual
4264
     works permit.  When the Document is included in an aggregate, this
4265
     License does not apply to the other works in the aggregate which
4266
     are not themselves derivative works of the Document.
4267
 
4268
     If the Cover Text requirement of section 3 is applicable to these
4269
     copies of the Document, then if the Document is less than one half
4270
     of the entire aggregate, the Document's Cover Texts may be placed
4271
     on covers that bracket the Document within the aggregate, or the
4272
     electronic equivalent of covers if the Document is in electronic
4273
     form.  Otherwise they must appear on printed covers that bracket
4274
     the whole aggregate.
4275
 
4276
  8. TRANSLATION
4277
 
4278
     Translation is considered a kind of modification, so you may
4279
     distribute translations of the Document under the terms of section
4280
     4.  Replacing Invariant Sections with translations requires special
4281
     permission from their copyright holders, but you may include
4282
     translations of some or all Invariant Sections in addition to the
4283
     original versions of these Invariant Sections.  You may include a
4284
     translation of this License, and all the license notices in the
4285
     Document, and any Warranty Disclaimers, provided that you also
4286
     include the original English version of this License and the
4287
     original versions of those notices and disclaimers.  In case of a
4288
     disagreement between the translation and the original version of
4289
     this License or a notice or disclaimer, the original version will
4290
     prevail.
4291
 
4292
     If a section in the Document is Entitled "Acknowledgements",
4293
     "Dedications", or "History", the requirement (section 4) to
4294
     Preserve its Title (section 1) will typically require changing the
4295
     actual title.
4296
 
4297
  9. TERMINATION
4298
 
4299
     You may not copy, modify, sublicense, or distribute the Document
4300
     except as expressly provided under this License.  Any attempt
4301
     otherwise to copy, modify, sublicense, or distribute it is void,
4302
     and will automatically terminate your rights under this License.
4303
 
4304
     However, if you cease all violation of this License, then your
4305
     license from a particular copyright holder is reinstated (a)
4306
     provisionally, unless and until the copyright holder explicitly
4307
     and finally terminates your license, and (b) permanently, if the
4308
     copyright holder fails to notify you of the violation by some
4309
     reasonable means prior to 60 days after the cessation.
4310
 
4311
     Moreover, your license from a particular copyright holder is
4312
     reinstated permanently if the copyright holder notifies you of the
4313
     violation by some reasonable means, this is the first time you have
4314
     received notice of violation of this License (for any work) from
4315
     that copyright holder, and you cure the violation prior to 30 days
4316
     after your receipt of the notice.
4317
 
4318
     Termination of your rights under this section does not terminate
4319
     the licenses of parties who have received copies or rights from
4320
     you under this License.  If your rights have been terminated and
4321
     not permanently reinstated, receipt of a copy of some or all of
4322
     the same material does not give you any rights to use it.
4323
 
4324
 10. FUTURE REVISIONS OF THIS LICENSE
4325
 
4326
     The Free Software Foundation may publish new, revised versions of
4327
     the GNU Free Documentation License from time to time.  Such new
4328
     versions will be similar in spirit to the present version, but may
4329
     differ in detail to address new problems or concerns.  See
4330
     `http://www.gnu.org/copyleft/'.
4331
 
4332
     Each version of the License is given a distinguishing version
4333
     number.  If the Document specifies that a particular numbered
4334
     version of this License "or any later version" applies to it, you
4335
     have the option of following the terms and conditions either of
4336
     that specified version or of any later version that has been
4337
     published (not as a draft) by the Free Software Foundation.  If
4338
     the Document does not specify a version number of this License,
4339
     you may choose any version ever published (not as a draft) by the
4340
     Free Software Foundation.  If the Document specifies that a proxy
4341
     can decide which future versions of this License can be used, that
4342
     proxy's public statement of acceptance of a version permanently
4343
     authorizes you to choose that version for the Document.
4344
 
4345
 11. RELICENSING
4346
 
4347
     "Massive Multiauthor Collaboration Site" (or "MMC Site") means any
4348
     World Wide Web server that publishes copyrightable works and also
4349
     provides prominent facilities for anybody to edit those works.  A
4350
     public wiki that anybody can edit is an example of such a server.
4351
     A "Massive Multiauthor Collaboration" (or "MMC") contained in the
4352
     site means any set of copyrightable works thus published on the MMC
4353
     site.
4354
 
4355
     "CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
4356
     license published by Creative Commons Corporation, a not-for-profit
4357
     corporation with a principal place of business in San Francisco,
4358
     California, as well as future copyleft versions of that license
4359
     published by that same organization.
4360
 
4361
     "Incorporate" means to publish or republish a Document, in whole or
4362
     in part, as part of another Document.
4363
 
4364
     An MMC is "eligible for relicensing" if it is licensed under this
4365
     License, and if all works that were first published under this
4366
     License somewhere other than this MMC, and subsequently
4367
     incorporated in whole or in part into the MMC, (1) had no cover
4368
     texts or invariant sections, and (2) were thus incorporated prior
4369
     to November 1, 2008.
4370
 
4371
     The operator of an MMC Site may republish an MMC contained in the
4372
     site under CC-BY-SA on the same site at any time before August 1,
4373
     2009, provided the MMC is eligible for relicensing.
4374
 
4375
 
4376
ADDENDUM: How to use this License for your documents
4377
====================================================
4378
 
4379
To use this License in a document you have written, include a copy of
4380
the License in the document and put the following copyright and license
4381
notices just after the title page:
4382
 
4383
       Copyright (C)  YEAR  YOUR NAME.
4384
       Permission is granted to copy, distribute and/or modify this document
4385
       under the terms of the GNU Free Documentation License, Version 1.3
4386
       or any later version published by the Free Software Foundation;
4387
       with no Invariant Sections, no Front-Cover Texts, and no Back-Cover
4388
       Texts.  A copy of the license is included in the section entitled ``GNU
4389
       Free Documentation License''.
4390
 
4391
   If you have Invariant Sections, Front-Cover Texts and Back-Cover
4392
Texts, replace the "with...Texts." line with this:
4393
 
4394
         with the Invariant Sections being LIST THEIR TITLES, with
4395
         the Front-Cover Texts being LIST, and with the Back-Cover Texts
4396
         being LIST.
4397
 
4398
   If you have Invariant Sections without Cover Texts, or some other
4399
combination of the three, merge those two alternatives to suit the
4400
situation.
4401
 
4402
   If your document contains nontrivial examples of program code, we
4403
recommend releasing these examples in parallel under your choice of
4404
free software license, such as the GNU General Public License, to
4405
permit their use in free software.
4406
 
4407

4408
File: stabs.info,  Node: Symbol Types Index,  Prev: GNU Free Documentation License,  Up: Top
4409
 
4410
Symbol Types Index
4411
******************
4412
 
4413
 
4414
* Menu:
4415
4416
* .bb:                                   Block Structure.      (line 26)
4417
* .be:                                   Block Structure.      (line 26)
4418
* C_BCOMM:                               Common Blocks.        (line 10)
4419
* C_BINCL:                               Include Files.        (line 41)
4420
* C_BLOCK:                               Block Structure.      (line 26)
4421
* C_BSTAT:                               Statics.              (line 31)
4422
* C_DECL, for types:                     Typedefs.             (line  6)
4423
* C_ECOML:                               Common Blocks.        (line 17)
4424
* C_ECOMM:                               Common Blocks.        (line 10)
4425
* C_EINCL:                               Include Files.        (line 41)
4426
* C_ENTRY:                               Alternate Entry Points.
4427
                                                               (line  6)
4428
* C_ESTAT:                               Statics.              (line 31)
4429
* C_FILE:                                Source Files.         (line 61)
4430
* C_FUN:                                 Procedures.           (line 18)
4431
* C_GSYM:                                Global Variables.     (line  6)
4432
* C_LSYM:                                Stack Variables.      (line 11)
4433
* C_PSYM:                                Parameters.           (line 12)
4434
* C_RPSYM:                               Register Parameters.  (line 15)
4435
* C_RSYM:                                Register Variables.   (line  6)
4436
* C_STSYM:                               Statics.              (line 31)
4437
* N_BCOMM:                               Common Blocks.        (line 10)
4438
* N_BINCL:                               Include Files.        (line 17)
4439
* N_BROWS:                               N_BROWS.              (line  7)
4440
* N_BSLINE:                              Line Numbers.         (line 12)
4441
* N_CATCH:                               N_CATCH.              (line  7)
4442
* N_DEFD:                                N_DEFD.               (line  7)
4443
* N_DSLINE:                              Line Numbers.         (line 12)
4444
* N_ECOML:                               Common Blocks.        (line 17)
4445
* N_ECOMM:                               Common Blocks.        (line 10)
4446
* N_EHDECL:                              N_EHDECL.             (line  7)
4447
* N_EINCL:                               Include Files.        (line 17)
4448
* N_ENTRY:                               Alternate Entry Points.
4449
                                                               (line  6)
4450
* N_EXCL:                                Include Files.        (line 17)
4451
* N_FNAME:                               Procedures.           (line  6)
4452
* N_FUN, for functions:                  Procedures.           (line  6)
4453
* N_FUN, for variables:                  Statics.              (line 12)
4454
* N_GSYM:                                Global Variables.     (line  6)
4455
* N_GSYM, for functions (Sun acc):       Procedures.           (line  6)
4456
* N_LBRAC:                               Block Structure.      (line  6)
4457
* N_LCSYM:                               Statics.              (line 12)
4458
* N_LENG:                                N_LENG.               (line  7)
4459
* N_LSYM, for parameter:                 Local Variable Parameters.
4460
                                                               (line 35)
4461
* N_LSYM, for stack variables:           Stack Variables.      (line 11)
4462
* N_LSYM, for types:                     Typedefs.             (line  6)
4463
* N_M2C:                                 N_M2C.                (line  7)
4464
* N_MAC_DEFINE:                          Macro define and undefine.
4465
                                                               (line 11)
4466
* N_MAC_UNDEF:                           Macro define and undefine.
4467
                                                               (line 14)
4468
* N_MAIN:                                Main Program.         (line  6)
4469
* N_MOD2:                                N_MOD2.               (line  7)
4470
* N_NBBSS:                               Gould.                (line  9)
4471
* N_NBDATA:                              Gould.                (line  8)
4472
* N_NBLCS:                               Gould.                (line 11)
4473
* N_NBSTS:                               Gould.                (line 10)
4474
* N_NBTEXT:                              Gould.                (line  7)
4475
* N_NOMAP:                               N_NOMAP.              (line  7)
4476
* N_NSYMS:                               N_NSYMS.              (line  7)
4477
* N_PC:                                  N_PC.                 (line  7)
4478
* N_PSYM:                                Parameters.           (line 12)
4479
* N_RBRAC:                               Block Structure.      (line  6)
4480
* N_ROSYM:                               Statics.              (line 12)
4481
* N_RSYM:                                Register Variables.   (line  6)
4482
* N_RSYM, for parameters:                Register Parameters.  (line 15)
4483
* N_SCOPE:                               N_SCOPE.              (line  7)
4484
* N_SLINE:                               Line Numbers.         (line  6)
4485
* N_SO:                                  Source Files.         (line  6)
4486
* N_SOL:                                 Include Files.        (line 11)
4487
 
4488
 
4489
* N_STSYM, for functions (Sun acc):      Procedures.           (line  6)
4490
4491
4492

4493
Tag Table:
4494
Node: Top1433
4495
Node: Overview2480
4496
Node: Flow3895
4497
Node: Stabs Format5421
4498
Node: String Field6983
4499
Node: C Example12414
4500
Node: Assembly Code12959
4501
Node: Program Structure14930
4502
Node: Main Program15656
4503
Node: Source Files16217
4504
Node: Include Files18669
4505
Node: Line Numbers21334
4506
Node: Procedures22868
4507
Node: Nested Procedures28758
4508
Node: Block Structure29934
4509
Node: Alternate Entry Points31340
4510
Node: Constants32073
4511
Node: Variables35185
4512
Node: Stack Variables35873
4513
Node: Global Variables37574
4514
Node: Register Variables38730
4515
Node: Common Blocks39552
4516
Node: Statics40806
4517
Node: Based Variables43385
4518
Node: Parameters44770
4519
Node: Register Parameters46382
4520
Node: Local Variable Parameters48643
4521
Node: Reference Parameters51558
4522
Node: Conformant Arrays52178
4523
Node: Types52895
4524
Node: Builtin Types53842
4525
Node: Traditional Builtin Types54988
4526
Node: Traditional Integer Types55389
4527
Node: Traditional Other Types57697
4528
Node: Builtin Type Descriptors58611
4529
Node: Negative Type Numbers62111
4530
Node: Miscellaneous Types68466
4531
Node: Cross-References70352
4532
Node: Subranges72027
4533
Node: Arrays73266
4534
Node: Strings76491
4535
Node: Enumerations77553
4536
Node: Structures79938
4537
Node: Typedefs82645
4538
Node: Unions83969
4539
Node: Function Types85550
4540
Node: Macro define and undefine87132
4541
Node: Symbol Tables88709
4542
Node: Symbol Table Format89161
4543
Node: Transformations On Symbol Tables90609
4544
Node: Transformations On Static Variables91963
4545
Node: Transformations On Global Variables92699
4546
Node: Stab Section Transformations93942
4547
Node: Cplusplus95325
4548
Node: Class Names95908
4549
Node: Nested Symbols96653
4550
Node: Basic Cplusplus Types97499
4551
Node: Simple Classes99059
4552
Node: Class Instance103353
4553
Node: Methods104070
4554
Node: Method Type Descriptor106289
4555
Node: Member Type Descriptor107489
4556
Node: Protections108281
4557
Node: Method Modifiers111371
4558
Node: Virtual Methods112999
4559
Node: Inheritance116800
4560
Node: Virtual Base Classes120496
4561
Node: Static Members122740
4562
Node: Stab Types123210
4563
Node: Non-Stab Symbol Types123834
4564
Node: Stab Symbol Types125265
4565
Node: Symbol Descriptors129196
4566
Node: Type Descriptors131975
4567
Node: Expanded Reference135187
4568
Node: N_PC136605
4569
Node: N_NSYMS136973
4570
Node: N_NOMAP137214
4571
Node: N_M2C137520
4572
Node: N_BROWS137954
4573
Node: N_DEFD138237
4574
Node: N_EHDECL138694
4575
Node: N_MOD2138945
4576
Node: N_CATCH139183
4577
Node: N_SSYM139677
4578
Node: N_SCOPE139962
4579
Node: Gould140152
4580
Node: N_LENG141144
4581
Node: Questions141372
4582
Node: Stab Sections143016
4583
Node: Stab Section Basics143626
4584
Node: ELF Linker Relocation146967
4585
Node: GNU Free Documentation License150377

powered by: WebSVN 2.1.0

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