* config/mips/tm-irix3.h: Add sigcontext offsets for Irix.
[deliverable/binutils-gdb.git] / gdb / doc / stabs.texinfo
CommitLineData
e505224d
PB
1\input texinfo
2@setfilename stabs.info
3
4@ifinfo
5@format
6START-INFO-DIR-ENTRY
139741da 7* Stabs: (stabs). The "stabs" debugging information format.
e505224d
PB
8END-INFO-DIR-ENTRY
9@end format
10@end ifinfo
11
12@ifinfo
8c59ee11 13This document describes the stabs debugging symbol tables.
e505224d 14
612dbd4c 15Copyright 1992 Free Software Foundation, Inc.
e505224d
PB
16Contributed by Cygnus Support. Written by Julia Menapace.
17
18Permission is granted to make and distribute verbatim copies of
19this manual provided the copyright notice and this permission notice
20are preserved on all copies.
21
22@ignore
23Permission is granted to process this file through Tex and print the
24results, provided the printed document carries copying permission
25notice identical to this one except for the removal of this paragraph
26(this paragraph not being relevant to the printed manual).
27
28@end ignore
29Permission is granted to copy or distribute modified versions of this
30manual under the terms of the GPL (for which purpose this text may be
31regarded as a program in the language TeX).
32@end ifinfo
33
139741da 34@setchapternewpage odd
e505224d
PB
35@settitle STABS
36@titlepage
139741da 37@title The ``stabs'' debug format
e505224d
PB
38@author Julia Menapace
39@author Cygnus Support
40@page
41@tex
42\def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
43\xdef\manvers{\$Revision$} % For use in headers, footers too
44{\parskip=0pt
45\hfill Cygnus Support\par
46\hfill \manvers\par
47\hfill \TeX{}info \texinfoversion\par
48}
49@end tex
50
51@vskip 0pt plus 1filll
899bafeb
RP
52Copyright @copyright{} 1992 Free Software Foundation, Inc.
53Contributed by Cygnus Support.
e505224d
PB
54
55Permission is granted to make and distribute verbatim copies of
56this manual provided the copyright notice and this permission notice
57are preserved on all copies.
58
59@end titlepage
60
899bafeb
RP
61@ifinfo
62@node Top
63@top The "stabs" representation of debugging information
e505224d 64
612dbd4c 65This document describes the GNU stabs debugging format in a.out files.
e505224d
PB
66
67@menu
139741da
RP
68* Overview:: Overview of stabs
69* Program structure:: Encoding of the structure of the program
6897f9ec 70* Constants:: Constants
139741da 71* Example:: A comprehensive example in C
e505224d 72* Variables::
8c59ee11 73* Types:: Type definitions
139741da 74* Symbol tables:: Symbol information in symbol tables
8c59ee11 75* Cplusplus::
e505224d
PB
76
77Appendixes:
139741da
RP
78* Example2.c:: Source code for extended example
79* Example2.s:: Assembly code for extended example
8c59ee11
JK
80* Stab types:: Table A: Symbol types from stabs
81* Assembler types:: Table B: Symbol types from assembler and linker
82* Symbol Descriptors:: Table C
83* Type Descriptors:: Table D
139741da
RP
84* Expanded reference:: Reference information by stab type
85* Questions:: Questions and anomolies
86* xcoff-differences:: Differences between GNU stabs in a.out
87 and GNU stabs in xcoff
88* Sun-differences:: Differences between GNU stabs and Sun
89 native stabs
e505224d 90@end menu
899bafeb 91@end ifinfo
e505224d
PB
92
93
899bafeb 94@node Overview
e505224d
PB
95@chapter Overview of stabs
96
139741da
RP
97@dfn{Stabs} refers to a format for information that describes a program
98to a debugger. This format was apparently invented by
99@c FIXME! <<name of inventor>> at
100the University of California at Berkeley, for the @code{pdx} Pascal
101debugger; the format has spread widely since then.
102
8c59ee11
JK
103This document is one of the few published sources of documentation on
104stabs. It is believed to be completely comprehensive for stabs used by
105C. The lists of symbol descriptors (@pxref{Symbol Descriptors}) and
106type descriptors (@pxref{Type Descriptors}) are believed to be completely
107comprehensive. There are known to be stabs for C++ and COBOL which are
108poorly documented here. Stabs specific to other languages (e.g. Pascal,
109Modula-2) are probably not as well documented as they should be.
110
111Other sources of information on stabs are @cite{dbx and dbxtool
112interfaces}, 2nd edition, by Sun, circa 1988, and @cite{AIX Version 3.2
113Files Reference}, Fourth Edition, September 1992, "dbx Stabstring
114Grammar" in the a.out section, page 2-31. This document is believed to
115incorporate the information from those two sources except where it
116explictly directs you to them for more information.
117
e505224d
PB
118@menu
119* Flow:: Overview of debugging information flow
8c59ee11 120* Stabs Format:: Overview of stab format
e505224d
PB
121* C example:: A simple example in C source
122* Assembly code:: The simple example at the assembly level
123@end menu
124
899bafeb 125@node Flow
e505224d
PB
126@section Overview of debugging information flow
127
139741da
RP
128The GNU C compiler compiles C source in a @file{.c} file into assembly
129language in a @file{.s} file, which is translated by the assembler into
130a @file{.o} file, and then linked with other @file{.o} files and
131libraries to produce an executable file.
e505224d 132
139741da
RP
133With the @samp{-g} option, GCC puts additional debugging information in
134the @file{.s} file, which is slightly transformed by the assembler and
e505224d
PB
135linker, and carried through into the final executable. This debugging
136information describes features of the source file like line numbers,
137the types and scopes of variables, and functions, their parameters and
138their scopes.
139
140For some object file formats, the debugging information is
139741da 141encapsulated in assembler directives known collectively as `stab' (symbol
e505224d
PB
142table) directives, interspersed with the generated code. Stabs are
143the native format for debugging information in the a.out and xcoff
144object file formats. The GNU tools can also emit stabs in the coff
145and ecoff object file formats.
146
139741da
RP
147The assembler adds the information from stabs to the symbol information
148it places by default in the symbol table and the string table of the
149@file{.o} file it is building. The linker consolidates the @file{.o}
150files into one executable file, with one symbol table and one string
151table. Debuggers use the symbol and string tables in the executable as
152a source of debugging information about the program.
e505224d 153
8c59ee11 154@node Stabs Format
e505224d
PB
155@section Overview of stab format
156
157There are three overall formats for stab assembler directives
139741da
RP
158differentiated by the first word of the stab. The name of the directive
159describes what combination of four possible data fields will follow. It
160is either @code{.stabs} (string), @code{.stabn} (number), or
161@code{.stabd} (dot).
e505224d
PB
162
163The overall format of each class of stab is:
164
165@example
139741da
RP
166.stabs "@var{string}",@var{type},0,@var{desc},@var{value}
167.stabn @var{type},0,@var{desc},@var{value}
168.stabd @var{type},0,@var{desc}
e505224d
PB
169@end example
170
139741da
RP
171In general, in @code{.stabs} the @var{string} field contains name and type
172information. For @code{.stabd} the value field is implicit and has the value
e505224d
PB
173of the current file location. Otherwise the value field often
174contains a relocatable address, frame pointer offset, or register
175number, that maps to the source code element described by the stab.
176
6897f9ec
JK
177The number in the type field gives some basic information about what
178type of stab this is (or whether it @emph{is} a stab, as opposed to an
179ordinary symbol). Each possible type number defines a different stab
180type. The stab type further defines the exact interpretation of, and
181possible values for, any remaining @code{"@var{string}"}, @var{desc}, or
139741da 182@var{value} fields present in the stab. Table A (@pxref{Stab
6897f9ec
JK
183types,,Table A: Symbol types from stabs}) lists in numeric order the
184possible type field values for stab directives. The reference section
185that follows Table A describes the meaning of the fields for each stab
186type in detail. The examples that follow this overview introduce the
187stab types in terms of the source code elements they describe.
e505224d 188
139741da
RP
189For @code{.stabs} the @code{"@var{string}"} field holds the meat of the
190debugging information. The generally unstructured nature of this field
191is what makes stabs extensible. For some stab types the string field
192contains only a name. For other stab types the contents can be a great
193deal more complex.
e505224d 194
139741da 195The overall format is of the @code{"@var{string}"} field is:
e505224d
PB
196
197@example
139741da
RP
198"@var{name}@r{[}:@var{symbol_descriptor}@r{]}
199 @r{[}@var{type_number}@r{[}=@var{type_descriptor} @r{@dots{}]]}"
e505224d
PB
200@end example
201
139741da 202@var{name} is the name of the symbol represented by the stab.
6897f9ec 203@var{name} can be omitted, which means the stab represents an unnamed
8c59ee11 204object. For example, @samp{:t10=*2} defines type 10 as a pointer to
6897f9ec
JK
205type 2, but does not give the type a name. Omitting the @var{name}
206field is supported by AIX dbx and GDB after about version 4.8, but not
207other debuggers.
e505224d 208
139741da
RP
209The @var{symbol_descriptor} following the @samp{:} is an alphabetic
210character that tells more specifically what kind of symbol the stab
211represents. If the @var{symbol_descriptor} is omitted, but type
212information follows, then the stab represents a local variable. For a
8c59ee11 213list of symbol descriptors, see @ref{Symbol Descriptors,,Table C: Symbol
139741da 214descriptors}.
e505224d 215
6897f9ec
JK
216The @samp{c} symbol descriptor is an exception in that it is not
217followed by type information. @xref{Constants}.
218
139741da
RP
219Type information is either a @var{type_number}, or a
220@samp{@var{type_number}=}. The @var{type_number} alone is a type
221reference, referring directly to a type that has already been defined.
e505224d 222
139741da
RP
223The @samp{@var{type_number}=} is a type definition, where the number
224represents a new type which is about to be defined. The type definition
225may refer to other types by number, and those type numbers may be
226followed by @samp{=} and nested definitions.
e505224d
PB
227
228In a type definition, if the character that follows the equals sign is
139741da
RP
229non-numeric then it is a @var{type_descriptor}, and tells what kind of
230type is about to be defined. Any other values following the
231@var{type_descriptor} vary, depending on the @var{type_descriptor}. If
232a number follows the @samp{=} then the number is a @var{type_reference}.
233This is described more thoroughly in the section on types. @xref{Type
234Descriptors,,Table D: Type Descriptors}, for a list of
235@var{type_descriptor} values.
236
6897f9ec
JK
237There is an AIX extension for type attributes. Following the @samp{=}
238is any number of type attributes. Each one starts with @samp{@@} and
239ends with @samp{;}. Debuggers, including AIX's dbx, skip any type
8c59ee11
JK
240attributes they do not recognize. GDB 4.9 does not do this--it will
241ignore the entire symbol containing a type attribute. Hopefully this
242will be fixed in the next GDB release. Because of a conflict with C++
243(@pxref{Cplusplus}), new attributes should not be defined which begin
244with a digit, @samp{(}, or @samp{-}; GDB may be unable to distinguish
245those from the C++ type descriptor @samp{@@}. The attributes are:
6897f9ec
JK
246
247@table @code
248@item a@var{boundary}
8c59ee11 249@var{boundary} is an integer specifying the alignment. I assume it
6897f9ec
JK
250applies to all variables of this type.
251
252@item s@var{size}
8c59ee11 253Size in bits of a variable of this type.
6897f9ec
JK
254
255@item p@var{integer}
256Pointer class (for checking). Not sure what this means, or how
257@var{integer} is interpreted.
258
259@item P
260Indicate this is a packed type, meaning that structure fields or array
261elements are placed more closely in memory, to save memory at the
262expense of speed.
263@end table
264
b6963343
JK
265All this can make the @code{"@var{string}"} field quite long. All
266versions of GDB, and some versions of DBX, can handle arbitrarily long
267strings. But many versions of DBX cretinously limit the strings to
268about 80 characters, so compilers which must work with such DBX's need
269to split the @code{.stabs} directive into several @code{.stabs}
270directives. Each stab duplicates exactly all but the
6897f9ec 271@code{"@var{string}"} field. The @code{"@var{string}"} field of
b6963343
JK
272every stab except the last is marked as continued with a
273double-backslash at the end. Removing the backslashes and concatenating
274the @code{"@var{string}"} fields of each stab produces the original,
275long string.
e505224d 276
899bafeb 277@node C example
e505224d
PB
278@section A simple example in C source
279
280To get the flavor of how stabs describe source information for a C
281program, let's look at the simple program:
282
283@example
284main()
285@{
139741da 286 printf("Hello world");
e505224d
PB
287@}
288@end example
289
139741da
RP
290When compiled with @samp{-g}, the program above yields the following
291@file{.s} file. Line numbers have been added to make it easier to refer
292to parts of the @file{.s} file in the description of the stabs that
293follows.
e505224d 294
899bafeb 295@node Assembly code
e505224d
PB
296@section The simple example at the assembly level
297
298@example
2991 gcc2_compiled.:
3002 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
3013 .stabs "hello.c",100,0,0,Ltext0
3024 .text
3035 Ltext0:
3046 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
3057 .stabs "char:t2=r2;0;127;",128,0,0,0
3068 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
3079 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
30810 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
30911 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0
31012 .stabs "long long int:t7=r1;0;-1;",128,0,0,0
31113 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
31214 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
31315 .stabs "signed char:t10=r1;-128;127;",128,0,0,0
31416 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0
31517 .stabs "float:t12=r1;4;0;",128,0,0,0
31618 .stabs "double:t13=r1;8;0;",128,0,0,0
31719 .stabs "long double:t14=r1;8;0;",128,0,0,0
31820 .stabs "void:t15=15",128,0,0,0
139741da 31921 .align 4
e505224d 32022 LC0:
139741da
RP
32123 .ascii "Hello, world!\12\0"
32224 .align 4
32325 .global _main
32426 .proc 1
e505224d
PB
32527 _main:
32628 .stabn 68,0,4,LM1
32729 LM1:
139741da
RP
32830 !#PROLOGUE# 0
32931 save %sp,-136,%sp
33032 !#PROLOGUE# 1
33133 call ___main,0
33234 nop
e505224d
PB
33335 .stabn 68,0,5,LM2
33436 LM2:
33537 LBB2:
139741da
RP
33638 sethi %hi(LC0),%o1
33739 or %o1,%lo(LC0),%o0
33840 call _printf,0
33941 nop
e505224d
PB
34042 .stabn 68,0,6,LM3
34143 LM3:
34244 LBE2:
34345 .stabn 68,0,6,LM4
34446 LM4:
34547 L1:
139741da
RP
34648 ret
34749 restore
e505224d
PB
34850 .stabs "main:F1",36,0,0,_main
34951 .stabn 192,0,0,LBB2
35052 .stabn 224,0,0,LBE2
351@end example
352
139741da 353This simple ``hello world'' example demonstrates several of the stab
e505224d
PB
354types used to describe C language source files.
355
899bafeb 356@node Program structure
139741da 357@chapter Encoding for the structure of the program
e505224d
PB
358
359@menu
360* Source file:: The path and name of the source file
361* Line numbers::
362* Procedures::
8d0dca57 363* Block Structure::
e505224d
PB
364@end menu
365
899bafeb 366@node Source file
e505224d
PB
367@section The path and name of the source file
368
139741da
RP
369@table @strong
370@item Directive:
371@code{.stabs}
372@item Type:
373@code{N_SO}
374@end table
e505224d
PB
375
376The first stabs in the .s file contain the name and path of the source
377file that was compiled to produce the .s file. This information is
378contained in two records of stab type N_SO (100).
379
380@example
381 .stabs "path_name", N_SO, NIL, NIL, Code_address_of_program_start
382 .stabs "file_name:", N_SO, NIL, NIL, Code_address_of_program_start
383@end example
384
385@example
3862 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
3873 .stabs "hello.c",100,0,0,Ltext0
139741da 3884 .text
e505224d
PB
3895 Ltext0:
390@end example
391
899bafeb 392@node Line numbers
e505224d
PB
393@section Line Numbers
394
139741da
RP
395@table @strong
396@item Directive:
397@code{.stabn}
398@item Type:
399@code{N_SLINE}
400@end table
e505224d 401
139741da 402The start of source lines is represented by the @code{N_SLINE} (68) stab
e505224d
PB
403type.
404
405@example
139741da 406.stabn N_SLINE, NIL, @var{line}, @var{address}
e505224d
PB
407@end example
408
139741da
RP
409@var{line} is a source line number; @var{address} represents the code
410address for the start of that source line.
411
e505224d
PB
412@example
41327 _main:
41428 .stabn 68,0,4,LM1
41529 LM1:
139741da 41630 !#PROLOGUE# 0
e505224d
PB
417@end example
418
899bafeb 419@node Procedures
6897f9ec
JK
420@section Procedures
421
422All of the following stabs use the @samp{N_FUN} symbol type.
423
424A function is represented by a @samp{F} symbol descriptor for a global
425(extern) function, and @samp{f} for a static (local) function. The next
426@samp{N_SLINE} symbol can be used to find the line number of the start
427of the function. The value field is the address of the start of the
428function. The type information of the stab represents the return type
429of the function; thus @samp{foo:f5} means that foo is a function
430returning type 5.
431
432The AIX documentation also defines symbol descriptor @samp{J} as an
433internal function. I assume this means a function nested within another
434function. It also says Symbol descriptor @samp{m} is a module in
435Modula-2 or extended Pascal.
436
437Procedures (functions which do not return values) are represented as
438functions returning the void type in C. I don't see why this couldn't
439be used for all languages (inventing a void type for this purpose if
440necessary), but the AIX documentation defines @samp{I}, @samp{P}, and
441@samp{Q} for internal, global, and static procedures, respectively.
442These symbol descriptors are unusual in that they are not followed by
443type information.
444
8c59ee11
JK
445For any of the above symbol descriptors, after the symbol descriptor and
446the type information, there is optionally a comma, followed by the name
447of the procedure, followed by a comma, followed by a name specifying the
448scope. The first name is local to the scope specified. I assume then
449that the name of the symbol (before the @samp{:}), if specified, is some
450sort of global name. I assume the name specifying the scope is the name
451of a function specifying that scope. This feature is an AIX extension,
452and this information is based on the manual; I haven't actually tried
453it.
6897f9ec
JK
454
455The stab representing a procedure is located immediately following the
456code of the procedure. This stab is in turn directly followed by a
457group of other stabs describing elements of the procedure. These other
458stabs describe the procedure's parameters, its block local variables and
459its block structure.
e505224d
PB
460
461@example
139741da
RP
46248 ret
46349 restore
e505224d
PB
464@end example
465
139741da
RP
466The @code{.stabs} entry after this code fragment shows the @var{name} of
467the procedure (@code{main}); the type descriptor @var{desc} (@code{F},
468for a global procedure); a reference to the predefined type @code{int}
469for the return type; and the starting @var{address} of the procedure.
470
471Here is an exploded summary (with whitespace introduced for clarity),
472followed by line 50 of our sample assembly output, which has this form:
473
e505224d 474@example
139741da
RP
475.stabs "@var{name}:
476 @var{desc} @r{(global proc @samp{F})}
477 @var{return_type_ref} @r{(int)}
478 ",N_FUN, NIL, NIL,
479 @var{address}
e505224d
PB
480@end example
481
482@example
48350 .stabs "main:F1",36,0,0,_main
484@end example
485
899bafeb 486@node Block Structure
e505224d
PB
487@section Block Structure
488
139741da
RP
489@table @strong
490@item Directive:
491@code{.stabn}
492@item Types:
493@code{N_LBRAC}, @code{N_RBRAC}
494@end table
e505224d 495
139741da
RP
496The program's block structure is represented by the @code{N_LBRAC} (left
497brace) and the @code{N_RBRAC} (right brace) stab types. The following code
498range, which is the body of @code{main}, is labeled with @samp{LBB2:} at the
499beginning and @samp{LBE2:} at the end.
e505224d
PB
500
501@example
50237 LBB2:
139741da
RP
50338 sethi %hi(LC0),%o1
50439 or %o1,%lo(LC0),%o0
50540 call _printf,0
50641 nop
e505224d
PB
50742 .stabn 68,0,6,LM3
50843 LM3:
50944 LBE2:
510@end example
511
139741da
RP
512The @code{N_LBRAC} and @code{N_RBRAC} stabs that describe the block
513scope of the procedure are located after the @code{N_FUNC} stab that
514represents the procedure itself. The @code{N_LBRAC} uses the
515@code{LBB2} label as the code address in its value field, and the
516@code{N_RBRAC} uses @code{LBE2}.
e505224d
PB
517
518@example
51950 .stabs "main:F1",36,0,0,_main
520@end example
521
522@example
139741da
RP
523 .stabn N_LBRAC, NIL, NIL, @var{left-brace-address}
524 .stabn N_RBRAC, NIL, NIL, @var{right-brace-address}
e505224d
PB
525@end example
526
527@example
52851 .stabn 192,0,0,LBB2
52952 .stabn 224,0,0,LBE2
530@end example
531
6897f9ec
JK
532@node Constants
533@chapter Constants
534
535The @samp{c} symbol descriptor indicates that this stab represents a
536constant. This symbol descriptor is an exception to the general rule
537that symbol descriptors are followed by type information. Instead, it
538is followed by @samp{=} and one of the following:
539
540@table @code
541@item b@var{value}
542Boolean constant. @var{value} is a numeric value; I assume it is 0 for
543false or 1 for true.
544
545@item c@var{value}
546Character constant. @var{value} is the numeric value of the constant.
547
548@item e@var{type-information},@var{value}
549Enumeration constant. @var{type-information} is the type of the
550constant, as it would appear after a symbol descriptor
8c59ee11 551(@pxref{Stabs Format}). @var{value} is the numeric value of the constant.
6897f9ec
JK
552
553@item i@var{value}
554Integer constant. @var{value} is the numeric value.
555
556@item r@var{value}
557Real constant. @var{value} is the real value, which can be @samp{INF}
558(optionally preceded by a sign) for infinity, @samp{QNAN} for a quiet
559NaN (not-a-number), or @samp{SNAN} for a signalling NaN. If it is a
560normal number the format is that accepted by the C library function
561@code{atof}.
562
563@item s@var{string}
564String constant. @var{string} is a string enclosed in either @samp{'}
565(in which case @samp{'} characters within the string are represented as
566@samp{\'} or @samp{"} (in which case @samp{"} characters within the
567string are represented as @samp{\"}).
568
569@item S@var{type-information},@var{elements},@var{bits},@var{pattern}
570Set constant. @var{type-information} is the type of the constant, as it
8c59ee11 571would appear after a symbol descriptor (@pxref{Stabs Format}).
6897f9ec
JK
572@var{elements} is the number of elements in the set (is this just the
573number of bits set in @var{pattern}? Or redundant with the type? I
574don't get it), @var{bits} is the number of bits in the constant (meaning
575it specifies the length of @var{pattern}, I think), and @var{pattern} is
576a hexadecimal representation of the set. AIX documentation refers to a
577limit of 32 bytes, but I see no reason why this limit should exist.
578@end table
579
580The boolean, character, string, and set constants are not supported by
581GDB 4.9, but it will ignore them. GDB 4.8 and earlier gave an error
582message and refused to read symbols from the file containing the
583constants.
584
585This information is followed by @samp{;}.
586
899bafeb 587@node Example
e505224d
PB
588@chapter A Comprehensive Example in C
589
139741da 590Now we'll examine a second program, @code{example2}, which builds on the
e505224d
PB
591first example to introduce the rest of the stab types, symbol
592descriptors, and type descriptors used in C.
139741da
RP
593@xref{Example2.c} for the complete @file{.c} source,
594and @pxref{Example2.s} for the @file{.s} assembly code.
e505224d
PB
595This description includes parts of those files.
596
597@section Flow of control and nested scopes
598
9cd64d11 599@table @strong
139741da
RP
600@item Directive:
601@code{.stabn}
602@item Types:
603@code{N_SLINE}, @code{N_LBRAC}, @code{N_RBRAC} (cont.)
604@end table
e505224d 605
899bafeb
RP
606Consider the body of @code{main}, from @file{example2.c}. It shows more
607about how @code{N_SLINE}, @code{N_RBRAC}, and @code{N_LBRAC} stabs are used.
e505224d
PB
608
609@example
61020 @{
61121 static float s_flap;
139741da
RP
61222 int times;
61323 for (times=0; times < s_g_repeat; times++)@{
61424 int inner;
61525 printf ("Hello world\n");
61626 @}
e505224d
PB
61727 @};
618@end example
619
899bafeb 620Here we have a single source line, the @samp{for} line, that generates
e505224d 621non-linear flow of control, and non-contiguous code. In this case, an
899bafeb 622@code{N_SLINE} stab with the same line number proceeds each block of
e505224d
PB
623non-contiguous code generated from the same source line.
624
139741da
RP
625The example also shows nested scopes. The @code{N_LBRAC} and
626@code{N_LBRAC} stabs that describe block structure are nested in the
627same order as the corresponding code blocks, those of the for loop
628inside those for the body of main.
e505224d 629
139741da
RP
630@noindent
631This is the label for the @code{N_LBRAC} (left brace) stab marking the
632start of @code{main}.
e505224d 633
139741da 634@example
e505224d 63557 LBB2:
139741da
RP
636@end example
637
638@noindent
639In the first code range for C source line 23, the @code{for} loop
640initialize and test, @code{N_SLINE} (68) records the line number:
e505224d 641
139741da
RP
642@example
643.stabn N_SLINE, NIL,
644 @var{line},
645 @var{address}
e505224d 646
e505224d
PB
64758 .stabn 68,0,23,LM2
64859 LM2:
139741da 64960 st %g0,[%fp-20]
e505224d 65061 L2:
139741da
RP
65162 sethi %hi(_s_g_repeat),%o0
65263 ld [%fp-20],%o1
65364 ld [%o0+%lo(_s_g_repeat)],%o0
65465 cmp %o1,%o0
65566 bge L3
65667 nop
e505224d 657
139741da 658@exdent label for the @code{N_LBRAC} (start block) marking the start of @code{for} loop
e505224d 659
e505224d
PB
66068 LBB3:
66169 .stabn 68,0,25,LM3
66270 LM3:
139741da
RP
66371 sethi %hi(LC0),%o1
66472 or %o1,%lo(LC0),%o0
66573 call _printf,0
66674 nop
e505224d
PB
66775 .stabn 68,0,26,LM4
66876 LM4:
e505224d 669
139741da 670@exdent label for the @code{N_RBRAC} (end block) stab marking the end of the @code{for} loop
e505224d 671
e505224d 67277 LBE3:
139741da 673@end example
e505224d 674
139741da
RP
675@noindent
676Now we come to the second code range for source line 23, the @code{for}
677loop increment and return. Once again, @code{N_SLINE} (68) records the
678source line number:
612dbd4c 679
139741da
RP
680@example
681.stabn, N_SLINE, NIL,
682 @var{line},
683 @var{address}
e505224d 684
e505224d
PB
68578 .stabn 68,0,23,LM5
68679 LM5:
68780 L4:
139741da
RP
68881 ld [%fp-20],%o0
68982 add %o0,1,%o1
69083 st %o1,[%fp-20]
69184 b,a L2
e505224d
PB
69285 L3:
69386 .stabn 68,0,27,LM6
69487 LM6:
e505224d 695
139741da 696@exdent label for the @code{N_RBRAC} (end block) stab marking the end of the @code{for} loop
e505224d 697
e505224d
PB
69888 LBE2:
69989 .stabn 68,0,27,LM7
70090 LM7:
70191 L1:
139741da
RP
70292 ret
70393 restore
e505224d
PB
70494 .stabs "main:F1",36,0,0,_main
70595 .stabs "argc:p1",160,0,0,68
70696 .stabs "argv:p20=*21=*2",160,0,0,72
70797 .stabs "s_flap:V12",40,0,0,_s_flap.0
70898 .stabs "times:1",128,0,0,-20
139741da
RP
709@end example
710
711@noindent
712Here is an illustration of stabs describing nested scopes. The scope
713nesting is reflected in the nested bracketing stabs (@code{N_LBRAC},
714192, appears here).
e505224d 715
139741da
RP
716@example
717.stabn N_LBRAC,NIL,NIL,
718 @var{block-start-address}
e505224d
PB
719
72099 .stabn 192,0,0,LBB2 ## begin proc label
721100 .stabs "inner:1",128,0,0,-24
722101 .stabn 192,0,0,LBB3 ## begin for label
139741da 723@end example
e505224d 724
139741da
RP
725@noindent
726@code{N_RBRAC} (224), ``right brace'' ends a lexical block (scope).
727
728@example
729.stabn N_RBRAC,NIL,NIL,
730 @var{block-end-address}
e505224d
PB
731
732102 .stabn 224,0,0,LBE3 ## end for label
733103 .stabn 224,0,0,LBE2 ## end proc label
734@end example
735
899bafeb 736@node Variables
e505224d
PB
737@chapter Variables
738
739@menu
740* Automatic variables:: locally scoped
8d0dca57 741* Global Variables::
e505224d
PB
742* Register variables::
743* Initialized statics::
744* Un-initialized statics::
745* Parameters::
746@end menu
747
899bafeb 748@node Automatic variables
e505224d
PB
749@section Locally scoped automatic variables
750
139741da
RP
751@table @strong
752@item Directive:
753@code{.stabs}
754@item Type:
755@code{N_LSYM}
756@item Symbol Descriptor:
757none
758@end table
e505224d 759
139741da
RP
760In addition to describing types, the @code{N_LSYM} stab type also
761describes locally scoped automatic variables. Refer again to the body
762of @code{main} in @file{example2.c}. It allocates two automatic
763variables: @samp{times} is scoped to the body of @code{main}, and
764@samp{inner} is scoped to the body of the @code{for} loop.
765@samp{s_flap} is locally scoped but not automatic, and will be discussed
766later.
e505224d
PB
767
768@example
76920 @{
77021 static float s_flap;
139741da
RP
77122 int times;
77223 for (times=0; times < s_g_repeat; times++)@{
77324 int inner;
77425 printf ("Hello world\n");
77526 @}
e505224d
PB
77627 @};
777@end example
778
139741da
RP
779The @code{N_LSYM} stab for an automatic variable is located just before the
780@code{N_LBRAC} stab describing the open brace of the block to which it is
e505224d
PB
781scoped.
782
783@example
139741da
RP
784@exdent @code{N_LSYM} (128): automatic variable, scoped locally to @code{main}
785
786.stabs "@var{name}:
8c59ee11 787 @var{type information}",
139741da
RP
788 N_LSYM, NIL, NIL,
789 @var{frame-pointer-offset}
e505224d
PB
790
79198 .stabs "times:1",128,0,0,-20
79299 .stabn 192,0,0,LBB2 ## begin `main' N_LBRAC
793
139741da
RP
794@exdent @code{N_LSYM} (128): automatic variable, scoped locally to the @code{for} loop
795
796.stabs "@var{name}:
8c59ee11 797 @var{type information}",
139741da
RP
798 N_LSYM, NIL, NIL,
799 @var{frame-pointer-offset}
e505224d
PB
800
801100 .stabs "inner:1",128,0,0,-24
802101 .stabn 192,0,0,LBB3 ## begin `for' loop N_LBRAC
803@end example
804
8c59ee11
JK
805The symbol descriptor is omitted for automatic variables. Since type
806information should being with a digit, @samp{-}, or @samp{(}, only
807digits, @samp{-}, and @samp{(} are precluded from being used for symbol
808descriptors by this fact. However, the Acorn RISC machine (ARM) is said
809to get this wrong: it puts out a mere type definition here, without the
810preceding @code{@var{typenumber}=}. This is a bad idea; there is no
811guarantee that type descriptors are distinct from symbol descriptors.
e505224d 812
899bafeb 813@node Global Variables
e505224d
PB
814@section Global Variables
815
139741da
RP
816@table @strong
817@item Directive:
818@code{.stabs}
819@item Type:
820@code{N_GSYM}
821@item Symbol Descriptor:
822@code{G}
823@end table
e505224d 824
139741da
RP
825Global variables are represented by the @code{N_GSYM} stab type. The symbol
826descriptor, following the colon in the string field, is @samp{G}. Following
827the @samp{G} is a type reference or type definition. In this example it is a
828type reference to the basic C type, @code{char}. The first source line in
829@file{example2.c},
e505224d
PB
830
831@example
8321 char g_foo = 'c';
833@end example
834
139741da
RP
835@noindent
836yields the following stab. The stab immediately precedes the code that
e505224d
PB
837allocates storage for the variable it describes.
838
839@example
139741da
RP
840@exdent @code{N_GSYM} (32): global symbol
841
842.stabs "@var{name}:
843 @var{descriptor}
844 @var{type-ref}",
845 N_GSYM, NIL, NIL, NIL
e505224d 846
e505224d 84721 .stabs "g_foo:G2",32,0,0,0
139741da
RP
84822 .global _g_foo
84923 .data
e505224d 85024 _g_foo:
139741da 85125 .byte 99
e505224d
PB
852@end example
853
139741da
RP
854The address of the variable represented by the @code{N_GSYM} is not contained
855in the @code{N_GSYM} stab. The debugger gets this information from the
e505224d
PB
856external symbol for the global variable.
857
899bafeb 858@node Register variables
6897f9ec 859@section Register variables
139741da 860
8c59ee11
JK
861@c According to an old version of this manual, AIX uses C_RPSYM instead
862@c of C_RSYM. I am skeptical; this should be verified.
6897f9ec
JK
863Register variables have their own stab type, @code{N_RSYM}, and their
864own symbol descriptor, @code{r}. The stab's value field contains the
865number of the register where the variable data will be stored.
e505224d 866
6897f9ec 867The value is the register number.
e505224d 868
6897f9ec
JK
869AIX defines a separate symbol descriptor @samp{d} for floating point
870registers. This seems incredibly stupid--why not just just give
8c59ee11
JK
871floating point registers different register numbers? I have not
872verified whether the compiler actually uses @samp{d}.
e505224d 873
6897f9ec
JK
874If the register is explicitly allocated to a global variable, but not
875initialized, as in
e505224d
PB
876
877@example
6897f9ec 878register int g_bar asm ("%g5");
e505224d
PB
879@end example
880
6897f9ec
JK
881the stab may be emitted at the end of the object file, with
882the other bss symbols.
e505224d 883
899bafeb 884@node Initialized statics
e505224d
PB
885@section Initialized static variables
886
139741da
RP
887@table @strong
888@item Directive:
889@code{.stabs}
890@item Type:
891@code{N_STSYM}
892@item Symbol Descriptors:
893@code{S} (file scope), @code{V} (procedure scope)
894@end table
e505224d 895
139741da
RP
896Initialized static variables are represented by the @code{N_STSYM} stab
897type. The symbol descriptor part of the string field shows if the
898variable is file scope static (@samp{S}) or procedure scope static
899(@samp{V}). The source line
e505224d
PB
900
901@example
9023 static int s_g_repeat = 2;
903@end example
904
139741da
RP
905@noindent
906yields the following code. The stab is located immediately preceding
e505224d 907the storage for the variable it represents. Since the variable in
139741da 908this example is file scope static the symbol descriptor is @samp{S}.
e505224d
PB
909
910@example
139741da
RP
911@exdent @code{N_STSYM} (38): initialized static variable (data seg w/internal linkage)
912
913.stabs "@var{name}:
914 @var{descriptor}
915 @var{type-ref}",
916 N_STSYM,NIL,NIL,
917 @var{address}
918
e505224d 91926 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
139741da 92027 .align 4
e505224d 92128 _s_g_repeat:
139741da 92229 .word 2
e505224d
PB
923@end example
924
925
899bafeb 926@node Un-initialized statics
e505224d
PB
927@section Un-initialized static variables
928
139741da
RP
929@table @strong
930@item Directive:
931@code{.stabs}
932@item Type:
933@code{N_LCSYM}
934@item Symbol Descriptors:
935@code{S} (file scope), @code{V} (procedure scope)
936@end table
e505224d 937
139741da
RP
938Un-initialized static variables are represented by the @code{N_LCSYM}
939stab type. The symbol descriptor part of the string shows if the
940variable is file scope static (@samp{S}) or procedure scope static
941(@samp{V}). In this example it is procedure scope static. The source
942line allocating @code{s_flap} immediately follows the open brace for the
943procedure @code{main}.
e505224d
PB
944
945@example
94620 @{
94721 static float s_flap;
948@end example
949
139741da
RP
950The code that reserves storage for the variable @code{s_flap} precedes the
951body of body of @code{main}.
e505224d
PB
952
953@example
139741da 95439 .reserve _s_flap.0,4,"bss",4
e505224d
PB
955@end example
956
139741da
RP
957But since @code{s_flap} is scoped locally to @code{main}, its stab is
958located with the other stabs representing symbols local to @code{main}.
959The stab for @code{s_flap} is located just before the @code{N_LBRAC} for
960@code{main}.
e505224d
PB
961
962@example
139741da
RP
963@exdent @code{N_LCSYM} (40): uninitialized static var (BSS seg w/internal linkage)
964
965.stabs "@var{name}:
966 @var{descriptor}
967 @var{type-ref}",
968 N_LCSYM, NIL, NIL,
969 @var{address}
e505224d 970
e505224d
PB
97197 .stabs "s_flap:V12",40,0,0,_s_flap.0
97298 .stabs "times:1",128,0,0,-20
139741da 97399 .stabn 192,0,0,LBB2 # N_LBRAC for main.
e505224d
PB
974@end example
975
139741da
RP
976@c ............................................................
977
899bafeb 978@node Parameters
e505224d
PB
979@section Parameters
980
497e44a5 981The symbol descriptor @samp{p} is used to refer to parameters which are
b82ea042
JK
982in the arglist. Symbols have symbol type @samp{N_PSYM}. The value of
983the symbol is the offset relative to the argument list.
984
985If the parameter is passed in a register, then the traditional way to do
497e44a5 986this is to provide two symbols for each argument:
e505224d
PB
987
988@example
b82ea042
JK
989.stabs "arg:p1" . . . ; N_PSYM
990.stabs "arg:r1" . . . ; N_RSYM
e505224d
PB
991@end example
992
497e44a5
JK
993Debuggers are expected to use the second one to find the value, and the
994first one to know that it is an argument.
e505224d 995
b82ea042
JK
996Because this is kind of ugly, some compilers use symbol descriptor
997@samp{P} or @samp{R} to indicate an argument which is in a register.
998The symbol value is the register number. @samp{P} and @samp{R} mean the
999same thing, the difference is that @samp{P} is a GNU invention and
1000@samp{R} is an IBM (xcoff) invention. As of version 4.9, GDB should
1001handle either one. Symbol type @samp{C_RPSYM} is used with @samp{R} and
1002@samp{N_RSYM} is used with @samp{P}.
1003
6897f9ec
JK
1004AIX, according to the documentation, uses @samp{D} for a parameter
1005passed in a floating point register. This strikes me as incredibly
1006bogus---why doesn't it just use @samp{R} with a register number which
23aed449 1007indicates that it's a floating point register? I haven't verified
6897f9ec
JK
1008whether the system actually does what the documentation indicates.
1009
a2a2eac8
JK
1010There is at least one case where GCC uses a @samp{p}/@samp{r} pair
1011rather than @samp{P}; this is where the argument is passed in the
1012argument list and then loaded into a register.
1013
c156f3c1
JK
1014On the sparc and hppa, for a @samp{P} symbol whose type is a structure
1015or union, the register contains the address of the structure. On the
1016sparc, this is also true of a @samp{p}/@samp{r} pair (using Sun cc) or a
1017@samp{p} symbol. However, if a (small) structure is really in a
1018register, @samp{r} is used. And, to top it all off, on the hppa it
1019might be a structure which was passed on the stack and loaded into a
1020register and for which there is a @samp{p}/@samp{r} pair! I believe
6897f9ec
JK
1021that symbol descriptor @samp{i} is supposed to deal with this case, (it
1022is said to mean "value parameter by reference, indirect access", I don't
1023know the source for this information) but I don't know details or what
1024compilers or debuggers use it, if any (not GDB or GCC). It is not clear
1025to me whether this case needs to be dealt with differently than
1026parameters passed by reference (see below).
c156f3c1 1027
b82ea042 1028There is another case similar to an argument in a register, which is an
98ef6f31
JK
1029argument which is actually stored as a local variable. Sometimes this
1030happens when the argument was passed in a register and then the compiler
1031stores it as a local variable. If possible, the compiler should claim
1032that it's in a register, but this isn't always done. Some compilers use
1033the pair of symbols approach described above ("arg:p" followed by
1034"arg:"); this includes gcc1 (not gcc2) on the sparc when passing a small
23aed449
JK
1035structure and gcc2 (sometimes) when the argument type is float and it is
1036passed as a double and converted to float by the prologue (in the latter
1037case the type of the "arg:p" symbol is double and the type of the "arg:"
1038symbol is float). GCC, at least on the 960, uses a single @samp{p}
1039symbol descriptor for an argument which is stored as a local variable
1040but uses @samp{N_LSYM} instead of @samp{N_PSYM}. In this case the value
1041of the symbol is an offset relative to the local variables for that
1042function, not relative to the arguments (on some machines those are the
1043same thing, but not on all).
e505224d 1044
6897f9ec
JK
1045If the parameter is passed by reference (e.g. Pascal VAR parameters),
1046then type symbol descriptor is @samp{v} if it is in the argument list,
1047or @samp{a} if it in a register. Other than the fact that these contain
1048the address of the parameter other than the parameter itself, they are
1049identical to @samp{p} and @samp{R}, respectively. I believe @samp{a} is
1050an AIX invention; @samp{v} is supported by all stabs-using systems as
1051far as I know.
1052
1053@c Is this paragraph correct? It is based on piecing together patchy
1054@c information and some guesswork
1055Conformant arrays refer to a feature of Modula-2, and perhaps other
1056languages, in which the size of an array parameter is not known to the
1057called function until run-time. Such parameters have two stabs, a
1058@samp{x} for the array itself, and a @samp{C}, which represents the size
1059of the array. The value of the @samp{x} stab is the offset in the
1060argument list where the address of the array is stored (it this right?
1061it is a guess); the value of the @samp{C} stab is the offset in the
1062argument list where the size of the array (in elements? in bytes?) is
1063stored.
1064
1065The following are also said to go with @samp{N_PSYM}:
a2a2eac8
JK
1066
1067@example
1068"name" -> "param_name:#type"
a2a2eac8 1069 -> pP (<<??>>)
8c59ee11 1070 -> pF FORTRAN function parameter
a2a2eac8
JK
1071 -> X (function result variable)
1072 -> b (based variable)
1073
1074value -> offset from the argument pointer (positive).
1075@end example
1076
497e44a5 1077As a simple example, the code
899bafeb 1078
497e44a5 1079@example
b82ea042
JK
1080main (argc, argv)
1081 int argc;
1082 char **argv;
1083@{
497e44a5
JK
1084@end example
1085
1086produces the stabs
899bafeb 1087
497e44a5 1088@example
b82ea042
JK
1089.stabs "main:F1",36,0,0,_main ; 36 is N_FUN
1090.stabs "argc:p1",160,0,0,68 ; 160 is N_PSYM
1091.stabs "argv:p20=*21=*2",160,0,0,72
e505224d
PB
1092@end example
1093
497e44a5 1094The type definition of argv is interesting because it contains several
a2a2eac8
JK
1095type definitions. Type 21 is pointer to type 2 (char) and argv (type 20) is
1096pointer to type 21.
e505224d 1097
8c59ee11
JK
1098@node Types
1099@chapter Type definitions
e505224d 1100
612dbd4c 1101Now let's look at some variable definitions involving complex types.
e505224d
PB
1102This involves understanding better how types are described. In the
1103examples so far types have been described as references to previously
1104defined types or defined in terms of subranges of or pointers to
1105previously defined types. The section that follows will talk about
1106the various other type descriptors that may follow the = sign in a
1107type definition.
1108
1109@menu
8c59ee11
JK
1110* Builtin types:: Integers, floating point, void, etc.
1111* Miscellaneous Types:: Pointers, sets, files, etc.
1112* Cross-references:: Referring to a type not yet defined.
1113* Subranges:: A type with a specific range.
1114* Arrays:: An aggregate type of same-typed elements.
1115* Strings:: Like an array but also has a length.
1116* Enumerations:: Like an integer but the values have names.
1117* Structures:: An aggregate type of different-typed elements.
1118* Typedefs:: Giving a type a name
e505224d
PB
1119* Unions::
1120* Function types::
1121@end menu
1122
8c59ee11
JK
1123@node Builtin types
1124@section Builtin types
e505224d 1125
8c59ee11
JK
1126Certain types are built in (@code{int}, @code{short}, @code{void},
1127@code{float}, etc.); the debugger recognizes these types and knows how
1128to handle them. Thus don't be surprised if some of the following ways
1129of specifying builtin types do not specify everything that a debugger
1130would need to know about the type---in some cases they merely specify
1131enough information to distinguish the type from other types.
1132
1133The traditional way to define builtin types is convolunted, so new ways
1134have been invented to describe them. Sun's ACC uses the @samp{b} and
1135@samp{R} type descriptors, and IBM uses negative type numbers. GDB can
1136accept all three, as of version 4.8; dbx just accepts the traditional
1137builtin types and perhaps one of the other two formats.
1138
1139@menu
1140* Traditional Builtin Types:: Put on your seatbelts and prepare for kludgery
1141* Builtin Type Descriptors:: Builtin types with special type descriptors
1142* Negative Type Numbers:: Builtin types using negative type numbers
1143@end menu
1144
1145@node Traditional Builtin Types
1146@subsection Traditional Builtin types
1147
1148Often types are defined as subranges of themselves. If the array bounds
1149can fit within an @code{int}, then they are given normally. For example:
1150
1151@example
1152.stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0 ; 128 is N_LSYM
1153.stabs "char:t2=r2;0;127;",128,0,0,0
1154@end example
1155
1156Builtin types can also be described as subranges of @code{int}:
1157
1158@example
1159.stabs "unsigned short:t6=r1;0;65535;",128,0,0,0
1160@end example
1161
1162If the upper bound of a subrange is -1, it means that the type is an
1163integral type whose bounds are too big to describe in an int.
1164Traditionally this is only used for @code{unsigned int} and
1165@code{unsigned long}; GCC also uses it for @code{long long} and
1166@code{unsigned long long}, and the only way to tell those types apart is
1167to look at their names. On other machines GCC puts out bounds in octal,
1168with a leading 0. In this case a negative bound consists of a number
1169which is a 1 bit followed by a bunch of 0 bits, and a positive bound is
1170one in which a bunch of bits are 1.
1171
1172@example
1173.stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
1174.stabs "long long int:t7=r1;0;-1;",128,0,0,0
1175@end example
1176
1177If the upper bound of a subrange is 0, it means that this is a floating
1178point type, and the lower bound of the subrange indicates the number of
1179bytes in the type:
1180
1181@example
1182.stabs "float:t12=r1;4;0;",128,0,0,0
1183.stabs "double:t13=r1;8;0;",128,0,0,0
1184@end example
1185
1186However, GCC writes @code{long double} the same way it writes
1187@code{double}; the only way to distinguish them is by the name:
1188
1189@example
1190.stabs "long double:t14=r1;8;0;",128,0,0,0
1191@end example
1192
1193Complex types are defined the same way as floating-point types; the only
1194way to distinguish a single-precision complex from a double-precision
1195floating-point type is by the name.
1196
1197The C @code{void} type is defined as itself:
1198
1199@example
1200.stabs "void:t15=15",128,0,0,0
1201@end example
1202
1203I'm not sure how a boolean type is represented.
1204
1205@node Builtin Type Descriptors
1206@subsection Defining Builtin Types using Builtin Type Descriptors
1207
1208There are various type descriptors to define builtin types:
1209
1210@table @code
1a8b5668
JK
1211@c FIXME: clean up description of width and offset, once we figure out
1212@c what they mean
8c59ee11
JK
1213@item b @var{signed} @var{char-flag} @var{width} ; @var{offset} ; @var{nbits} ;
1214Define an integral type. @var{signed} is @samp{u} for unsigned or
1215@samp{s} for signed. @var{char-flag} is @samp{c} which indicates this
1216is a character type, or is omitted. I assume this is to distinguish an
1217integral type from a character type of the same size, for example it
1218might make sense to set it for the C type @code{wchar_t} so the debugger
1219can print such variables differently (Solaris does not do this). Sun
1220sets it on the C types @code{signed char} and @code{unsigned char} which
1221arguably is wrong. @var{width} and @var{offset} appear to be for small
1222objects stored in larger ones, for example a @code{short} in an
1223@code{int} register. @var{width} is normally the number of bytes in the
1224type. @var{offset} seems to always be zero. @var{nbits} is the number
1225of bits in the type.
1226
1227Note that type descriptor @samp{b} used for builtin types conflicts with
1228its use for Pascal space types (@pxref{Miscellaneous Types}); they can
1229be distinguished because the character following the type descriptor
1230will be a digit, @samp{(}, or @samp{-} for a Pascal space type, or
1231@samp{u} or @samp{s} for a builtin type.
1232
1233@item w
1234Documented by AIX to define a wide character type, but their compiler
1235actually uses negative type numbers (@pxref{Negative Type Numbers}).
1236
1a8b5668
JK
1237@item R @var{fp_type} ; @var{bytes} ;
1238Define a floating point type. @var{fp_type} has one of the following values:
1239
1240@table @code
1241@item 1 (NF_SINGLE)
1242IEEE 32-bit (single precision) floating point format.
1243
1244@item 2 (NF_DOUBLE)
1245IEEE 64-bit (double precision) floating point format.
1246
1247@item 3 (NF_COMPLEX)
1248@item 4 (NF_COMPLEX16)
1249@item 5 (NF_COMPLEX32)
1250These are for complex numbers. A comment in
1251@file{include/aout/stab_gnu.h} describes them as Fortran complex, double
1252complex, and complex*16, respectively, but what does that mean? (i.e.
1253Single precision? Double precison?).
1254
1255@item 6 (NF_LDOUBLE)
1256Long double. It would be cleaner to define a different code for every
1257possible format of long double.
1258@end table
1259
1260@var{bytes} is the number of bytes occupied by the type. This allows a
1261debugger to perform some operations with the type even if it doesn't
1262understand @var{fp_code}.
8c59ee11
JK
1263
1264@item g @var{type-information} ; @var{nbits}
1265Documented by AIX to define a floating type, but their compiler actually
1266uses negative type numbers (@pxref{Negative Type Numbers}).
1267
1268@item c @var{type-information} ; @var{nbits}
1269Documented by AIX to define a complex type, but their compiler actually
1270uses negative type numbers (@pxref{Negative Type Numbers}).
1271@end table
1272
1273The C @code{void} type is defined as a signed integral type 0 bits long:
1274@example
1275.stabs "void:t19=bs0;0;0",128,0,0,0
1276@end example
1277
1278I'm not sure how a boolean type is represented.
1279
1280@node Negative Type Numbers
1281@subsection Negative Type numbers
1282
1283Since the debugger knows about the builtin types anyway, the idea of
1284negative type numbers is simply to give a special type number which
1285indicates the built in type. There is no stab defining these types.
1286
1287I'm not sure whether anyone has tried to define what this means if
1288@code{int} can be other than 32 bits (or other types can be other than
1289their customary size). If @code{int} has exactly one size for each
1290architecture, then it can be handled easily enough, but if the size of
1291@code{int} can vary according the compiler options, then it gets hairy.
1292I guess the consistent way to do this would be to define separate
1293negative type numbers for 16-bit @code{int} and 32-bit @code{int};
1294therefore I have indicated below the customary size (and other format
1295information) for each type. The information below is currently correct
1296because AIX on the RS6000 is the only system which uses these type
1297numbers. If these type numbers start to get used on other systems, I
1298suspect the correct thing to do is to define a new number in cases where
1299a type does not have the size and format indicated below.
1300
1301@table @code
1302@item -1
1303@code{int}, 32 bit signed integral type.
1304
1305@item -2
1306@code{char}, 8 bit type holding a character. Both GDB and dbx on AIX
1307treat this as signed. GCC uses this type whether @code{char} is signed
1308or not, which seems like a bad idea. The AIX compiler (xlc) seems to
1309avoid this type; it uses -5 instead for @code{char}.
1310
1311@item -3
1312@code{short}, 16 bit signed integral type.
1313
1314@item -4
1315@code{long}, 32 bit signed integral type.
1316
1317@item -5
1318@code{unsigned char}, 8 bit unsigned integral type.
1319
1320@item -6
1321@code{signed char}, 8 bit signed integral type.
1322
1323@item -7
1324@code{unsigned short}, 16 bit unsigned integral type.
1325
1326@item -8
1327@code{unsigned int}, 32 bit unsigned integral type.
1328
1329@item -9
1330@code{unsigned}, 32 bit unsigned integral type.
1331
1332@item -10
1333@code{unsigned long}, 32 bit unsigned integral type.
1334
1335@item -11
1336@code{void}, type indicating the lack of a value.
1337
1338@item -12
1339@code{float}, IEEE single precision.
1340
1341@item -13
1342@code{double}, IEEE double precision.
1343
1344@item -14
1345@code{long double}, IEEE extended, RS6000 format.
1346
1347@item -15
1348@code{integer}. Pascal, I assume. 32 bit signed integral type.
1349
1350@item -16
1351Boolean. Only one bit is used, not sure about the actual size of the
1352type.
1353
1354@item -17
1355@code{short real}. Pascal, I assume. IEEE single precision.
1356
1357@item -18
1358@code{real}. Pascal, I assume. IEEE double precision.
1359
1360@item -19
1361A Pascal Stringptr. @xref{Strings}.
1362
1363@item -20
1364@code{character}, 8 bit unsigned type.
1365
1366@item -21
1367@code{logical*1}, 8 bit unsigned integral type.
1368
1369@item -22
1370@code{logical*2}, 16 bit unsigned integral type.
1371
1372@item -23
1373@code{logical*4}, 32 bit unsigned integral type.
1374
1375@item -24
1376@code{logical}, 32 bit unsigned integral type.
1377
1378@item -25
1379A complex type consisting of two IEEE single-precision floating point values.
1380
1381@item -26
1382A complex type consisting of two IEEE double-precision floating point values.
1383
1384@item -27
1385@code{integer*1}, 8 bit signed integral type.
1386
1387@item -28
1388@code{integer*2}, 16 bit signed integral type.
1389
1390@item -29
1391@code{integer*4}, 32 bit signed integral type.
1392
1393@item -30
1394Wide character. AIX appears not to use this for the C type
1395@code{wchar_t}; instead it uses an integral type of the appropriate
1396size.
1397@end table
1398
1399@node Miscellaneous Types
1400@section Miscellaneous Types
1401
1402@table @code
1403@item b @var{type-information} ; @var{bytes}
1404Pascal space type. This is documented by IBM; what does it mean?
1405
1406Note that this use of the @samp{b} type descriptor can be distinguished
1407from its use for builtin integral types (@pxref{Builtin Type
1408Descriptors}) because the character following the type descriptor is
1409always a digit, @samp{(}, or @samp{-}.
1410
1411@item B @var{type-information}
1412A volatile-qualified version of @var{type-information}. This is a Sun
1413extension. A volatile-qualified type means that references and stores
1414to a variable of that type must not be optimized or cached; they must
1415occur as the user specifies them.
1416
1417@item d @var{type-information}
1418File of type @var{type-information}. As far as I know this is only used
1419by Pascal.
1420
1421@item k @var{type-information}
1422A const-qualified version of @var{type-information}. This is a Sun
1423extension. A const-qualified type means that a variable of this type
1424cannot be modified.
1425
1426@item M @var{type-information} ; @var{length}
1427Multiple instance type. The type seems to composed of @var{length}
1428repetitions of @var{type-information}, for example @code{character*3} is
1429represented by @samp{M-2;3}, where @samp{-2} is a reference to a
1430character type (@pxref{Negative Type Numbers}). I'm not sure how this
1431differs from an array. This appears to be a FORTRAN feature.
1432@var{length} is a bound, like those in range types, @xref{Subranges}.
1433
1434@item S @var{type-information}
1435Pascal set type. @var{type-information} must be a small type such as an
1436enumeration or a subrange, and the type is a bitmask whose length is
1437specified by the number of elements in @var{type-information}.
1438
1439@item * @var{type-information}
1440Pointer to @var{type-information}.
139741da 1441@end table
e505224d 1442
8c59ee11
JK
1443@node Cross-references
1444@section Cross-references to other types
1445
1446If a type is used before it is defined, one common way to deal with this
1447is just to use a type reference to a type which has not yet been
1448defined. The debugger is expected to be able to deal with this.
1449
1450Another way is with the @samp{x} type descriptor, which is followed by
1451@samp{s} for a structure tag, @samp{u} for a union tag, or @samp{e} for
1452a enumerator tag, followed by the name of the tag, followed by @samp{:}.
1453for example the following C declarations:
e505224d
PB
1454
1455@example
8c59ee11
JK
1456struct foo;
1457struct foo *bar;
e505224d
PB
1458@end example
1459
8c59ee11
JK
1460produce
1461
1462@example
1463.stabs "bar:G16=*17=xsfoo:",32,0,0,0
1464@end example
1465
1466Not all debuggers support the @samp{x} type descriptor, so on some
1467machines GCC does not use it. I believe that for the above example it
1468would just emit a reference to type 17 and never define it, but I
1469haven't verified that.
1470
1471Modula-2 imported types, at least on AIX, use the @samp{i} type
1472descriptor, which is followed by the name of the module from which the
1473type is imported, followed by @samp{:}, followed by the name of the
1474type. There is then optionally a comma followed by type information for
1475the type (This differs from merely naming the type (@pxref{Typedefs}) in
1476that it identifies the module; I don't understand whether the name of
1477the type given here is always just the same as the name we are giving
1478it, or whether this type descriptor is used with a nameless stab
1479(@pxref{Stabs Format}), or what). The symbol ends with @samp{;}.
e505224d 1480
8c59ee11
JK
1481@node Subranges
1482@section Subrange types
1483
1484The @samp{r} type descriptor defines a type as a subrange of another
1485type. It is followed by type information for the type which it is a
1486subrange of, a semicolon, an integral lower bound, a semicolon, an
1487integral upper bound, and a semicolon. The AIX documentation does not
1488specify the trailing semicolon; I believe it is confused.
1489
1490AIX allows the bounds to be one of the following instead of an integer:
1491
1492@table @code
1493@item A @var{offset}
1494The bound is passed by reference on the stack at offset @var{offset}
1495from the argument list. @xref{Parameters}, for more information on such
1496offsets.
1497
1498@item T @var{offset}
1499The bound is passed by value on the stack at offset @var{offset} from
1500the argument list.
1501
1502@item a @var{register-number}
1503The bound is pased by reference in register number
1504@var{register-number}.
1505
1506@item t @var{register-number}
1507The bound is passed by value in register number @var{register-number}.
1508
1509@item J
1510There is no bound.
1511@end table
1512
1513Subranges are also used for builtin types, @xref{Traditional Builtin Types}.
1514
1515@node Arrays
1516@section Array types
1517
1518Arrays use the @samp{a} type descriptor. Following the type descriptor
1519is the type of the index and the type of the array elements. The two
1520types types are not separated by any sort of delimiter; if the type of
1521the index does not end in a semicolon I don't know what is supposed to
1522happen. IBM documents a semicolon between the two types. For the
1523common case (a range type), this ends up as being the same since IBM
1524documents a range type as not ending in a semicolon, but the latter does
1525not accord with common practice, in which range types do end with
1526semicolons.
6aa83a79
JG
1527
1528The type of the index is often a range type, expressed as the letter r
8c59ee11
JK
1529and some parameters. It defines the size of the array. In the example
1530below, the range @code{r1;0;2;} defines an index type which is a
1531subrange of type 1 (integer), with a lower bound of 0 and an upper bound
1532of 2. This defines the valid range of subscripts of a three-element C
1533array.
e505224d 1534
8c59ee11 1535For example, the definition
e505224d
PB
1536
1537@example
8c59ee11
JK
1538char char_vec[3] = @{'a','b','c'@};
1539@end example
e505224d 1540
8c59ee11
JK
1541@noindent
1542produces the output
1543
1544@example
1545.stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
1546 .global _char_vec
1547 .align 4
1548_char_vec:
1549 .byte 97
1550 .byte 98
1551 .byte 99
1552@end example
1553
1554If an array is @dfn{packed}, it means that the elements are spaced more
1555closely than normal, saving memory at the expense of speed. For
1556example, an array of 3-byte objects might, if unpacked, have each
1557element aligned on a 4-byte boundary, but if packed, have no padding.
1558One way to specify that something is packed is with type attributes
1559(@pxref{Stabs Format}), in the case of arrays another is to use the
1560@samp{P} type descriptor instead of @samp{a}. Other than specifying a
1561packed array, @samp{P} is identical to @samp{a}.
1562
1563@c FIXME-what is it? A pointer?
1564An open array is represented by the @samp{A} type descriptor followed by
1565type information specifying the type of the array elements.
1566
1567@c FIXME: what is the format of this type? A pointer to a vector of pointers?
1568An N-dimensional dynamic array is represented by
1569
1570@example
1571D @var{dimensions} ; @var{type-information}
1572@end example
1573
1574@c Does dimensions really have this meaning? The AIX documentation
1575@c doesn't say.
1576@var{dimensions} is the number of dimensions; @var{type-information}
1577specifies the type of the array elements.
1578
1579@c FIXME: what is the format of this type? A pointer to some offsets in
1580@c another array?
1581A subarray of an N-dimensional array is represented by
1582
1583@example
1584E @var{dimensions} ; @var{type-information}
e505224d
PB
1585@end example
1586
8c59ee11
JK
1587@c Does dimensions really have this meaning? The AIX documentation
1588@c doesn't say.
1589@var{dimensions} is the number of dimensions; @var{type-information}
1590specifies the type of the array elements.
1591
1592@node Strings
1593@section Strings
1594
1595Some languages, like C or the original Pascal, do not have string types,
1596they just have related things like arrays of characters. But most
1597Pascals and various other languages have string types, which are
1598indicated as follows:
1599
1600@table @code
1601@item n @var{type-information} ; @var{bytes}
1602@var{bytes} is the maximum length. I'm not sure what
1603@var{type-information} is; I suspect that it means that this is a string
1604of @var{type-information} (thus allowing a string of integers, a string
1605of wide characters, etc., as well as a string of characters). Not sure
1606what the format of this type is. This is an AIX feature.
1607
1608@item z @var{type-information} ; @var{bytes}
1609Just like @samp{n} except that this is a gstring, not an ordinary
1610string. I don't know the difference.
1611
1612@item N
1613Pascal Stringptr. What is this? This is an AIX feature.
1614@end table
1615
899bafeb 1616@node Enumerations
e505224d
PB
1617@section Enumerations
1618
8c59ee11 1619Enumerations are defined with the @samp{e} type descriptor.
e505224d 1620
8c59ee11
JK
1621@c FIXME: Where does this information properly go? Perhaps it is
1622@c redundant with something we already explain.
e505224d
PB
1623The source line below declares an enumeration type. It is defined at
1624file scope between the bodies of main and s_proc in example2.c.
8c59ee11 1625The type definition is located after the N_RBRAC that marks the end of
e505224d 1626the previous procedure's block scope, and before the N_FUN that marks
8c59ee11
JK
1627the beginning of the next procedure's block scope. Therefore it does not
1628describe a block local symbol, but a file local one.
1629
1630The source line:
e505224d
PB
1631
1632@example
8c59ee11 1633enum e_places @{first,second=3,last@};
e505224d
PB
1634@end example
1635
899bafeb 1636@noindent
8c59ee11 1637generates the following stab
e505224d 1638
899bafeb 1639@example
8c59ee11 1640.stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0
899bafeb 1641@end example
e505224d
PB
1642
1643The symbol descriptor (T) says that the stab describes a structure,
1644enumeration, or type tag. The type descriptor e, following the 22= of
1645the type definition narrows it down to an enumeration type. Following
1646the e is a list of the elements of the enumeration. The format is
1647name:value,. The list of elements ends with a ;.
1648
8c59ee11
JK
1649There is no standard way to specify the size of an enumeration type; it
1650is determined by the architecture (normally all enumerations types are
165132 bits). There should be a way to specify an enumeration type of
1652another size; type attributes would be one way to do this @xref{Stabs
1653Format}.
1654
1655@node Structures
1656@section Structures
e505224d 1657
139741da
RP
1658@table @strong
1659@item Directive:
1660@code{.stabs}
1661@item Type:
8c59ee11 1662@code{N_LSYM} or @code{C_DECL}
139741da
RP
1663@item Symbol Descriptor:
1664@code{T}
1665@item Type Descriptor:
1666@code{s}
1667@end table
e505224d
PB
1668
1669The following source code declares a structure tag and defines an
4d7f562d 1670instance of the structure in global scope. Then a typedef equates the
e505224d
PB
1671structure tag with a new type. A seperate stab is generated for the
1672structure tag, the structure typedef, and the structure instance. The
1673stabs for the tag and the typedef are emited when the definitions are
1674encountered. Since the structure elements are not initialized, the
1675stab and code for the structure variable itself is located at the end
1676of the program in .common.
1677
1678@example
16796 struct s_tag @{
16807 int s_int;
16818 float s_float;
16829 char s_char_vec[8];
168310 struct s_tag* s_next;
168411 @} g_an_s;
168512
168613 typedef struct s_tag s_typedef;
1687@end example
1688
1689The structure tag is an N_LSYM stab type because, like the enum, the
1690symbol is file scope. Like the enum, the symbol descriptor is T, for
1691enumeration, struct or tag type. The symbol descriptor s following
1692the 16= of the type definition narrows the symbol type to struct.
1693
1694Following the struct symbol descriptor is the number of bytes the
1695struct occupies, followed by a description of each structure element.
1696The structure element descriptions are of the form name:type, bit
1697offset from the start of the struct, and number of bits in the
1698element.
1699
1700
612dbd4c 1701@example
e505224d
PB
1702 <128> N_LSYM - type definition
1703 .stabs "name:sym_desc(struct tag) Type_def(16)=type_desc(struct type)
139741da 1704 struct_bytes
e505224d 1705 elem_name:type_ref(int),bit_offset,field_bits;
139741da 1706 elem_name:type_ref(float),bit_offset,field_bits;
6aa83a79
JG
1707 elem_name:type_def(17)=type_desc(array)
1708 index_type(range of int from 0 to 7);
1709 element_type(char),bit_offset,field_bits;;",
139741da 1710 N_LSYM,NIL,NIL,NIL
e505224d
PB
1711
171230 .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;
139741da 1713 s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
612dbd4c 1714@end example
e505224d
PB
1715
1716In this example, two of the structure elements are previously defined
1717types. For these, the type following the name: part of the element
1718description is a simple type reference. The other two structure
1719elements are new types. In this case there is a type definition
1720embedded after the name:. The type definition for the array element
1721looks just like a type definition for a standalone array. The s_next
1722field is a pointer to the same kind of structure that the field is an
1723element of. So the definition of structure type 16 contains an type
1724definition for an element which is a pointer to type 16.
1725
899bafeb 1726@node Typedefs
8c59ee11 1727@section Giving a type a name
e505224d 1728
8c59ee11 1729To give a type a name, use the @samp{t} symbol descriptor. For example,
e505224d 1730
899bafeb 1731@example
8c59ee11 1732.stabs "s_typedef:t16",128,0,0,0
899bafeb 1733@end example
e505224d 1734
8c59ee11
JK
1735specifies that @code{s_typedef} refers to type number 16. Such stabs
1736have symbol type @code{N_LSYM} or @code{C_DECL}.
e505224d 1737
8c59ee11
JK
1738If instead, you are giving a name to a tag for a structure, union, or
1739enumeration, use the @samp{T} symbol descriptor instead. I believe C is
1740the only language with this feature.
e505224d 1741
8c59ee11
JK
1742If the type is an opaque type (I believe this is a Modula-2 feature),
1743AIX provides a type descriptor to specify it. The type descriptor is
1744@samp{o} and is followed by a name. I don't know what the name
1745means---is it always the same as the name of the type, or is this type
1746descriptor used with a nameless stab (@pxref{Stabs Format})? There
1747optionally follows a comma followed by type information which defines
1748the type of this type. If omitted, a semicolon is used in place of the
1749comma and the type information, and, the type is much like a generic
1750pointer type---it has a known size but little else about it is
1751specified.
e505224d 1752
899bafeb 1753@node Unions
e505224d
PB
1754@section Unions
1755
612dbd4c 1756Next let's look at unions. In example2 this union type is declared
e505224d
PB
1757locally to a procedure and an instance of the union is defined.
1758
1759@example
176036 union u_tag @{
176137 int u_int;
176238 float u_float;
176339 char* u_char;
176440 @} an_u;
1765@end example
1766
1767This code generates a stab for the union tag and a stab for the union
1768variable. Both use the N_LSYM stab type. Since the union variable is
1769scoped locally to the procedure in which it is defined, its stab is
139741da 1770located immediately preceding the N_LBRAC for the procedure's block
e505224d
PB
1771start.
1772
139741da 1773The stab for the union tag, however is located preceding the code for
e505224d
PB
1774the procedure in which it is defined. The stab type is N_LSYM. This
1775would seem to imply that the union type is file scope, like the struct
1776type s_tag. This is not true. The contents and position of the stab
1777for u_type do not convey any infomation about its procedure local
1778scope.
1779
899bafeb 1780@display
e505224d
PB
1781 <128> N_LSYM - type
1782 .stabs "name:sym_desc(union tag)type_def(22)=type_desc(union)
1783 byte_size(4)
1784 elem_name:type_ref(int),bit_offset(0),bit_size(32);
1785 elem_name:type_ref(float),bit_offset(0),bit_size(32);
1786 elem_name:type_ref(ptr to char),bit_offset(0),bit_size(32);;"
1787 N_LSYM, NIL, NIL, NIL
899bafeb 1788@end display
e505224d 1789
5bc927fb
RP
1790@smallexample
1791105 .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;",
1792 128,0,0,0
1793@end smallexample
e505224d
PB
1794
1795The symbol descriptor, T, following the name: means that the stab
4d7f562d 1796describes an enumeration, struct or type tag. The type descriptor u,
e505224d
PB
1797following the 23= of the type definition, narrows it down to a union
1798type definition. Following the u is the number of bytes in the union.
1799After that is a list of union element descriptions. Their format is
1800name:type, bit offset into the union, and number of bytes for the
1801element;.
1802
1803The stab for the union variable follows. Notice that the frame
1804pointer offset for local variables is negative.
1805
899bafeb 1806@display
e505224d
PB
1807 <128> N_LSYM - local variable (with no symbol descriptor)
1808 .stabs "name:type_ref(u_tag)", N_LSYM, NIL, NIL, frame_ptr_offset
899bafeb 1809@end display
e505224d 1810
899bafeb 1811@example
e505224d 1812130 .stabs "an_u:23",128,0,0,-20
899bafeb 1813@end example
e505224d 1814
899bafeb 1815@node Function types
e505224d
PB
1816@section Function types
1817
8c59ee11
JK
1818There are various types for function variables. These types are not
1819used in defining functions; see symbol descriptor @samp{f}; they are
1820used for things like pointers to functions.
e505224d 1821
8c59ee11
JK
1822The simple, traditional, type is type descriptor @samp{f} is followed by
1823type information for the return type of the function, followed by a
1824semicolon.
1825
1826This does not deal with functions the number and type of whose
1827parameters are part of their type, as found in Modula-2 or ANSI C. AIX
1828provides extensions to specify these, using the @samp{f}, @samp{F},
1829@samp{p}, and @samp{R} type descriptors.
1830
1831First comes the type descriptor. Then, if it is @samp{f} or @samp{F},
1832this is a function, and the type information for the return type of the
1833function follows, followed by a comma. Then comes the number of
1834parameters to the function and a semicolon. Then, for each parameter,
1835there is the name of the parameter followed by a colon (this is only
1836present for type descriptors @samp{R} and @samp{F} which represent
1837Pascal function or procedure parameters), type information for the
1838parameter, a comma, @samp{0} if passed by reference or @samp{1} if
1839passed by value, and a semicolon. The type definition ends with a
1840semicolon.
1841
1842For example,
e505224d
PB
1843
1844@example
8c59ee11 1845int (*g_pf)();
e505224d
PB
1846@end example
1847
8c59ee11
JK
1848@noindent
1849generates the following code:
e505224d 1850
899bafeb 1851@example
8c59ee11
JK
1852.stabs "g_pf:G24=*25=f1",32,0,0,0
1853 .common _g_pf,4,"bss"
899bafeb 1854@end example
e505224d 1855
8c59ee11
JK
1856The variable defines a new type, 24, which is a pointer to another new
1857type, 25, which is defined as a function returning int.
e505224d 1858
899bafeb 1859@node Symbol tables
e505224d
PB
1860@chapter Symbol information in symbol tables
1861
1862This section examines more closely the format of symbol table entries
1863and how stab assembler directives map to them. It also describes what
1864transformations the assembler and linker make on data from stabs.
1865
1866Each time the assembler encounters a stab in its input file it puts
1867each field of the stab into corresponding fields in a symbol table
1868entry of its output file. If the stab contains a string field, the
1869symbol table entry for that stab points to a string table entry
1870containing the string data from the stab. Assembler labels become
1871relocatable addresses. Symbol table entries in a.out have the format:
1872
1873@example
1874struct internal_nlist @{
139741da
RP
1875 unsigned long n_strx; /* index into string table of name */
1876 unsigned char n_type; /* type of symbol */
1877 unsigned char n_other; /* misc info (usually empty) */
1878 unsigned short n_desc; /* description field */
1879 bfd_vma n_value; /* value of symbol */
e505224d
PB
1880@};
1881@end example
1882
1883For .stabs directives, the n_strx field holds the character offset
1884from the start of the string table to the string table entry
1885containing the "string" field. For other classes of stabs (.stabn and
1886.stabd) this field is null.
1887
1888Symbol table entries with n_type fields containing a value greater or
1889equal to 0x20 originated as stabs generated by the compiler (with one
1890random exception). Those with n_type values less than 0x20 were
1891placed in the symbol table of the executable by the assembler or the
1892linker.
1893
1894The linker concatenates object files and does fixups of externally
1895defined symbols. You can see the transformations made on stab data by
1896the assembler and linker by examining the symbol table after each pass
1897of the build, first the assemble and then the link.
1898
1899To do this use nm with the -ap options. This dumps the symbol table,
1900including debugging information, unsorted. For stab entries the
1901columns are: value, other, desc, type, string. For assembler and
1902linker symbols, the columns are: value, type, string.
1903
1904There are a few important things to notice about symbol tables. Where
1905the value field of a stab contains a frame pointer offset, or a
1906register number, that value is unchanged by the rest of the build.
1907
1908Where the value field of a stab contains an assembly language label,
1909it is transformed by each build step. The assembler turns it into a
1910relocatable address and the linker turns it into an absolute address.
1911This source line defines a static variable at file scope:
1912
899bafeb 1913@example
e505224d 19143 static int s_g_repeat
899bafeb 1915@end example
e505224d 1916
899bafeb 1917@noindent
e505224d
PB
1918The following stab describes the symbol.
1919
899bafeb 1920@example
e505224d 192126 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
899bafeb 1922@end example
e505224d 1923
899bafeb 1924@noindent
e505224d 1925The assembler transforms the stab into this symbol table entry in the
899bafeb 1926@file{.o} file. The location is expressed as a data segment offset.
e505224d 1927
899bafeb 1928@example
e505224d 192921 00000084 - 00 0000 STSYM s_g_repeat:S1
899bafeb 1930@end example
e505224d 1931
899bafeb 1932@noindent
e505224d
PB
1933in the symbol table entry from the executable, the linker has made the
1934relocatable address absolute.
1935
899bafeb 1936@example
e505224d 193722 0000e00c - 00 0000 STSYM s_g_repeat:S1
899bafeb 1938@end example
e505224d
PB
1939
1940Stabs for global variables do not contain location information. In
1941this case the debugger finds location information in the assembler or
1942linker symbol table entry describing the variable. The source line:
1943
899bafeb 1944@example
e505224d 19451 char g_foo = 'c';
899bafeb 1946@end example
e505224d 1947
899bafeb 1948@noindent
e505224d
PB
1949generates the stab:
1950
899bafeb 1951@example
e505224d 195221 .stabs "g_foo:G2",32,0,0,0
899bafeb 1953@end example
e505224d
PB
1954
1955The variable is represented by the following two symbol table entries
1956in the object file. The first one originated as a stab. The second
1957one is an external symbol. The upper case D signifies that the n_type
1958field of the symbol table contains 7, N_DATA with local linkage (see
1959Table B). The value field following the file's line number is empty
1960for the stab entry. For the linker symbol it contains the
1961rellocatable address corresponding to the variable.
1962
899bafeb 1963@example
e505224d
PB
196419 00000000 - 00 0000 GSYM g_foo:G2
196520 00000080 D _g_foo
899bafeb 1966@end example
e505224d 1967
899bafeb 1968@noindent
e505224d
PB
1969These entries as transformed by the linker. The linker symbol table
1970entry now holds an absolute address.
1971
899bafeb 1972@example
e505224d 197321 00000000 - 00 0000 GSYM g_foo:G2
899bafeb 1974@dots{}
e505224d 1975215 0000e008 D _g_foo
899bafeb 1976@end example
e505224d 1977
8c59ee11 1978@node Cplusplus
612dbd4c 1979@chapter GNU C++ stabs
e505224d
PB
1980
1981@menu
b32ae57b 1982* Basic Cplusplus types::
e505224d
PB
1983* Simple classes::
1984* Class instance::
1985* Methods:: Method definition
1986* Protections::
2dd00294
JG
1987* Method Modifiers:: (const, volatile, const volatile)
1988* Virtual Methods::
1989* Inheritence::
1990* Virtual Base Classes::
1991* Static Members::
e505224d
PB
1992@end menu
1993
e505224d
PB
1994@subsection type descriptors added for C++ descriptions
1995
1996@table @code
1997@item #
1998method type (two ## if minimal debug)
1999
8c59ee11
JK
2000@item @@
2001Member (class and variable) type. It is followed by type information
2002for the offset basetype, a comma, and type information for the type of
2003the field being pointed to. (FIXME: this is acknowledged to be
2004gibberish. Can anyone say what really goes here?).
2005
2006Note that there is a conflict between this and type attributes
2007(@pxref{Stabs Format}); both use type descriptor @samp{@@}.
2008Fortunately, the @samp{@@} type descriptor used in this C++ sense always
2009will be followed by a digit, @samp{(}, or @samp{-}, and type attributes
2010never start with those things.
e505224d
PB
2011@end table
2012
b32ae57b 2013@node Basic Cplusplus types
e505224d
PB
2014@section Basic types for C++
2015
2016<< the examples that follow are based on a01.C >>
2017
2018
2019C++ adds two more builtin types to the set defined for C. These are
2020the unknown type and the vtable record type. The unknown type, type
202116, is defined in terms of itself like the void type.
2022
2023The vtable record type, type 17, is defined as a structure type and
2024then as a structure tag. The structure has four fields, delta, index,
2025pfn, and delta2. pfn is the function pointer.
2026
2027<< In boilerplate $vtbl_ptr_type, what are the fields delta,
2028index, and delta2 used for? >>
2029
2030This basic type is present in all C++ programs even if there are no
2031virtual methods defined.
2032
899bafeb 2033@display
e505224d 2034.stabs "struct_name:sym_desc(type)type_def(17)=type_desc(struct)struct_bytes(8)
139741da
RP
2035 elem_name(delta):type_ref(short int),bit_offset(0),field_bits(16);
2036 elem_name(index):type_ref(short int),bit_offset(16),field_bits(16);
2037 elem_name(pfn):type_def(18)=type_desc(ptr to)type_ref(void),
2038 bit_offset(32),field_bits(32);
2039 elem_name(delta2):type_def(short int);bit_offset(32),field_bits(16);;"
2040 N_LSYM, NIL, NIL
899bafeb 2041@end display
139741da 2042
899bafeb 2043@smallexample
e505224d 2044.stabs "$vtbl_ptr_type:t17=s8
139741da
RP
2045 delta:6,0,16;index:6,16,16;pfn:18=*15,32,32;delta2:6,32,16;;"
2046 ,128,0,0,0
899bafeb 2047@end smallexample
e505224d 2048
899bafeb 2049@display
e505224d 2050.stabs "name:sym_dec(struct tag)type_ref($vtbl_ptr_type)",N_LSYM,NIL,NIL,NIL
899bafeb 2051@end display
e505224d 2052
899bafeb 2053@example
e505224d 2054.stabs "$vtbl_ptr_type:T17",128,0,0,0
899bafeb 2055@end example
e505224d 2056
899bafeb 2057@node Simple classes
e505224d
PB
2058@section Simple class definition
2059
2060The stabs describing C++ language features are an extension of the
2061stabs describing C. Stabs representing C++ class types elaborate
2062extensively on the stab format used to describe structure types in C.
2063Stabs representing class type variables look just like stabs
2064representing C language variables.
2065
2066Consider the following very simple class definition.
2067
2068@example
2069class baseA @{
2070public:
139741da
RP
2071 int Adat;
2072 int Ameth(int in, char other);
e505224d
PB
2073@};
2074@end example
2075
2076The class baseA is represented by two stabs. The first stab describes
2077the class as a structure type. The second stab describes a structure
2078tag of the class type. Both stabs are of stab type N_LSYM. Since the
2079stab is not located between an N_FUN and a N_LBRAC stab this indicates
2080that the class is defined at file scope. If it were, then the N_LSYM
2081would signify a local variable.
2082
2083A stab describing a C++ class type is similar in format to a stab
2084describing a C struct, with each class member shown as a field in the
2085structure. The part of the struct format describing fields is
2086expanded to include extra information relevent to C++ class members.
2087In addition, if the class has multiple base classes or virtual
2088functions the struct format outside of the field parts is also
2089augmented.
2090
2091In this simple example the field part of the C++ class stab
2092representing member data looks just like the field part of a C struct
2093stab. The section on protections describes how its format is
2094sometimes extended for member data.
2095
2096The field part of a C++ class stab representing a member function
2097differs substantially from the field part of a C struct stab. It
2098still begins with `name:' but then goes on to define a new type number
2099for the member function, describe its return type, its argument types,
2100its protection level, any qualifiers applied to the method definition,
2101and whether the method is virtual or not. If the method is virtual
2102then the method description goes on to give the vtable index of the
2103method, and the type number of the first base class defining the
2104method.
2105
2106When the field name is a method name it is followed by two colons
2107rather than one. This is followed by a new type definition for the
2108method. This is a number followed by an equal sign and then the
2109symbol descriptor `##', indicating a method type. This is followed by
2110a type reference showing the return type of the method and a
2111semi-colon.
2112
2113The format of an overloaded operator method name differs from that
2114of other methods. It is "op$::XXXX." where XXXX is the operator name
612dbd4c
JG
2115such as + or +=. The name ends with a period, and any characters except
2116the period can occur in the XXXX string.
e505224d
PB
2117
2118The next part of the method description represents the arguments to
2119the method, preceeded by a colon and ending with a semi-colon. The
2120types of the arguments are expressed in the same way argument types
2121are expressed in C++ name mangling. In this example an int and a char
2122map to `ic'.
2123
2124This is followed by a number, a letter, and an asterisk or period,
2125followed by another semicolon. The number indicates the protections
2126that apply to the member function. Here the 2 means public. The
2127letter encodes any qualifier applied to the method definition. In
2128this case A means that it is a normal function definition. The dot
2129shows that the method is not virtual. The sections that follow
2130elaborate further on these fields and describe the additional
2131information present for virtual methods.
2132
2133
899bafeb 2134@display
e505224d 2135.stabs "class_name:sym_desc(type)type_def(20)=type_desc(struct)struct_bytes(4)
139741da 2136 field_name(Adat):type(int),bit_offset(0),field_bits(32);
e505224d 2137
139741da
RP
2138 method_name(Ameth)::type_def(21)=type_desc(method)return_type(int);
2139 :arg_types(int char);
2140 protection(public)qualifier(normal)virtual(no);;"
2141 N_LSYM,NIL,NIL,NIL
899bafeb 2142@end display
e505224d 2143
899bafeb 2144@smallexample
e505224d
PB
2145.stabs "baseA:t20=s4Adat:1,0,32;Ameth::21=##1;:ic;2A.;;",128,0,0,0
2146
2147.stabs "class_name:sym_desc(struct tag)",N_LSYM,NIL,NIL,NIL
2148
2149.stabs "baseA:T20",128,0,0,0
899bafeb 2150@end smallexample
e505224d 2151
899bafeb 2152@node Class instance
e505224d
PB
2153@section Class instance
2154
2155As shown above, describing even a simple C++ class definition is
2156accomplished by massively extending the stab format used in C to
2157describe structure types. However, once the class is defined, C stabs
2158with no modifications can be used to describe class instances. The
2159following source:
2160
2161@example
2162main () @{
139741da 2163 baseA AbaseA;
e505224d
PB
2164@}
2165@end example
2166
899bafeb
RP
2167@noindent
2168yields the following stab describing the class instance. It looks no
e505224d
PB
2169different from a standard C stab describing a local variable.
2170
899bafeb 2171@display
e505224d 2172.stabs "name:type_ref(baseA)", N_LSYM, NIL, NIL, frame_ptr_offset
899bafeb 2173@end display
e505224d 2174
899bafeb 2175@example
e505224d 2176.stabs "AbaseA:20",128,0,0,-20
899bafeb 2177@end example
e505224d 2178
899bafeb 2179@node Methods
e505224d
PB
2180@section Method defintion
2181
2182The class definition shown above declares Ameth. The C++ source below
2183defines Ameth:
2184
2185@example
2186int
2187baseA::Ameth(int in, char other)
2188@{
139741da 2189 return in;
e505224d
PB
2190@};
2191@end example
2192
2193
2194This method definition yields three stabs following the code of the
2195method. One stab describes the method itself and following two
2196describe its parameters. Although there is only one formal argument
2197all methods have an implicit argument which is the `this' pointer.
2198The `this' pointer is a pointer to the object on which the method was
2199called. Note that the method name is mangled to encode the class name
2200and argument types. << Name mangling is not described by this
2201document - Is there already such a doc? >>
2202
612dbd4c 2203@example
e505224d 2204.stabs "name:symbol_desriptor(global function)return_type(int)",
139741da 2205 N_FUN, NIL, NIL, code_addr_of_method_start
e505224d
PB
2206
2207.stabs "Ameth__5baseAic:F1",36,0,0,_Ameth__5baseAic
612dbd4c 2208@end example
e505224d
PB
2209
2210Here is the stab for the `this' pointer implicit argument. The name
c2dc518b 2211of the `this' pointer is always `this.' Type 19, the `this' pointer is
e505224d
PB
2212defined as a pointer to type 20, baseA, but a stab defining baseA has
2213not yet been emited. Since the compiler knows it will be emited
2214shortly, here it just outputs a cross reference to the undefined
2215symbol, by prefixing the symbol name with xs.
2216
612dbd4c 2217@example
e505224d 2218.stabs "name:sym_desc(register param)type_def(19)=
139741da 2219 type_desc(ptr to)type_ref(baseA)=
e505224d
PB
2220 type_desc(cross-reference to)baseA:",N_RSYM,NIL,NIL,register_number
2221
c2dc518b 2222.stabs "this:P19=*20=xsbaseA:",64,0,0,8
612dbd4c 2223@end example
e505224d
PB
2224
2225The stab for the explicit integer argument looks just like a parameter
2226to a C function. The last field of the stab is the offset from the
2227argument pointer, which in most systems is the same as the frame
2228pointer.
2229
612dbd4c 2230@example
e505224d 2231.stabs "name:sym_desc(value parameter)type_ref(int)",
139741da 2232 N_PSYM,NIL,NIL,offset_from_arg_ptr
e505224d
PB
2233
2234.stabs "in:p1",160,0,0,72
612dbd4c 2235@end example
e505224d
PB
2236
2237<< The examples that follow are based on A1.C >>
2238
899bafeb 2239@node Protections
e505224d
PB
2240@section Protections
2241
2242
2243In the simple class definition shown above all member data and
2244functions were publicly accessable. The example that follows
2245contrasts public, protected and privately accessable fields and shows
2246how these protections are encoded in C++ stabs.
2247
2248Protections for class member data are signified by two characters
2249embeded in the stab defining the class type. These characters are
2250located after the name: part of the string. /0 means private, /1
2251means protected, and /2 means public. If these characters are omited
2252this means that the member is public. The following C++ source:
2253
2254@example
2255class all_data @{
139741da
RP
2256private:
2257 int priv_dat;
e505224d 2258protected:
139741da 2259 char prot_dat;
e505224d 2260public:
139741da 2261 float pub_dat;
e505224d
PB
2262@};
2263@end example
2264
899bafeb 2265@noindent
e505224d
PB
2266generates the following stab to describe the class type all_data.
2267
899bafeb 2268@display
e505224d 2269.stabs "class_name:sym_desc(type)type_def(19)=type_desc(struct)struct_bytes
139741da
RP
2270 data_name:/protection(private)type_ref(int),bit_offset,num_bits;
2271 data_name:/protection(protected)type_ref(char),bit_offset,num_bits;
2272 data_name:(/num omited, private)type_ref(float),bit_offset,num_bits;;"
2273 N_LSYM,NIL,NIL,NIL
899bafeb 2274@end display
e505224d 2275
899bafeb 2276@smallexample
e505224d 2277.stabs "all_data:t19=s12
139741da 2278 priv_dat:/01,0,32;prot_dat:/12,32,8;pub_dat:12,64,32;;",128,0,0,0
899bafeb 2279@end smallexample
e505224d
PB
2280
2281Protections for member functions are signified by one digit embeded in
2282the field part of the stab describing the method. The digit is 0 if
2283private, 1 if protected and 2 if public. Consider the C++ class
2284definition below:
2285
2286@example
2287class all_methods @{
2288private:
139741da 2289 int priv_meth(int in)@{return in;@};
e505224d 2290protected:
139741da 2291 char protMeth(char in)@{return in;@};
e505224d 2292public:
139741da 2293 float pubMeth(float in)@{return in;@};
e505224d
PB
2294@};
2295@end example
2296
2297It generates the following stab. The digit in question is to the left
2298of an `A' in each case. Notice also that in this case two symbol
2299descriptors apply to the class name struct tag and struct type.
2300
899bafeb 2301@display
e505224d 2302.stabs "class_name:sym_desc(struct tag&type)type_def(21)=
139741da
RP
2303 sym_desc(struct)struct_bytes(1)
2304 meth_name::type_def(22)=sym_desc(method)returning(int);
2305 :args(int);protection(private)modifier(normal)virtual(no);
2306 meth_name::type_def(23)=sym_desc(method)returning(char);
2307 :args(char);protection(protected)modifier(normal)virual(no);
2308 meth_name::type_def(24)=sym_desc(method)returning(float);
2309 :args(float);protection(public)modifier(normal)virtual(no);;",
2310 N_LSYM,NIL,NIL,NIL
899bafeb 2311@end display
139741da 2312
899bafeb 2313@smallexample
e505224d 2314.stabs "all_methods:Tt21=s1priv_meth::22=##1;:i;0A.;protMeth::23=##2;:c;1A.;
139741da 2315 pubMeth::24=##12;:f;2A.;;",128,0,0,0
899bafeb 2316@end smallexample
e505224d 2317
899bafeb
RP
2318@node Method Modifiers
2319@section Method Modifiers (const, volatile, const volatile)
e505224d
PB
2320
2321<< based on a6.C >>
2322
2323In the class example described above all the methods have the normal
2324modifier. This method modifier information is located just after the
2325protection information for the method. This field has four possible
2326character values. Normal methods use A, const methods use B, volatile
2327methods use C, and const volatile methods use D. Consider the class
2328definition below:
2329
2330@example
2331class A @{
2332public:
139741da
RP
2333 int ConstMeth (int arg) const @{ return arg; @};
2334 char VolatileMeth (char arg) volatile @{ return arg; @};
2335 float ConstVolMeth (float arg) const volatile @{return arg; @};
e505224d
PB
2336@};
2337@end example
2338
2339This class is described by the following stab:
2340
899bafeb 2341@display
e505224d 2342.stabs "class(A):sym_desc(struct)type_def(20)=type_desc(struct)struct_bytes(1)
139741da
RP
2343 meth_name(ConstMeth)::type_def(21)sym_desc(method)
2344 returning(int);:arg(int);protection(public)modifier(const)virtual(no);
2345 meth_name(VolatileMeth)::type_def(22)=sym_desc(method)
2346 returning(char);:arg(char);protection(public)modifier(volatile)virt(no)
2347 meth_name(ConstVolMeth)::type_def(23)=sym_desc(method)
2348 returning(float);:arg(float);protection(public)modifer(const volatile)
2349 virtual(no);;", @dots{}
899bafeb 2350@end display
139741da 2351
899bafeb 2352@example
e505224d 2353.stabs "A:T20=s1ConstMeth::21=##1;:i;2B.;VolatileMeth::22=##2;:c;2C.;
139741da 2354 ConstVolMeth::23=##12;:f;2D.;;",128,0,0,0
612dbd4c 2355@end example
e505224d 2356
899bafeb 2357@node Virtual Methods
e505224d
PB
2358@section Virtual Methods
2359
2360<< The following examples are based on a4.C >>
2361
2362The presence of virtual methods in a class definition adds additional
2363data to the class description. The extra data is appended to the
2364description of the virtual method and to the end of the class
2365description. Consider the class definition below:
2366
2367@example
2368class A @{
2369public:
139741da
RP
2370 int Adat;
2371 virtual int A_virt (int arg) @{ return arg; @};
e505224d
PB
2372@};
2373@end example
2374
2375This results in the stab below describing class A. It defines a new
2376type (20) which is an 8 byte structure. The first field of the class
2377struct is Adat, an integer, starting at structure offset 0 and
2378occupying 32 bits.
2379
2380The second field in the class struct is not explicitly defined by the
2381C++ class definition but is implied by the fact that the class
2382contains a virtual method. This field is the vtable pointer. The
2383name of the vtable pointer field starts with $vf and continues with a
2384type reference to the class it is part of. In this example the type
2385reference for class A is 20 so the name of its vtable pointer field is
2386$vf20, followed by the usual colon.
2387
2388Next there is a type definition for the vtable pointer type (21).
2389This is in turn defined as a pointer to another new type (22).
2390
2391Type 22 is the vtable itself, which is defined as an array, indexed by
6aa83a79
JG
2392a range of integers between 0 and 1, and whose elements are of type
239317. Type 17 was the vtable record type defined by the boilerplate C++
2394type definitions, as shown earlier.
e505224d
PB
2395
2396The bit offset of the vtable pointer field is 32. The number of bits
2397in the field are not specified when the field is a vtable pointer.
2398
2399Next is the method definition for the virtual member function A_virt.
2400Its description starts out using the same format as the non-virtual
2401member functions described above, except instead of a dot after the
2402`A' there is an asterisk, indicating that the function is virtual.
2403Since is is virtual some addition information is appended to the end
2404of the method description.
2405
2406The first number represents the vtable index of the method. This is a
240732 bit unsigned number with the high bit set, followed by a
2408semi-colon.
2409
2410The second number is a type reference to the first base class in the
2411inheritence hierarchy defining the virtual member function. In this
2412case the class stab describes a base class so the virtual function is
2413not overriding any other definition of the method. Therefore the
2414reference is to the type number of the class that the stab is
2415describing (20).
2416
2417This is followed by three semi-colons. One marks the end of the
2418current sub-section, one marks the end of the method field, and the
2419third marks the end of the struct definition.
2420
2421For classes containing virtual functions the very last section of the
2422string part of the stab holds a type reference to the first base
2423class. This is preceeded by `~%' and followed by a final semi-colon.
2424
899bafeb 2425@display
e505224d 2426.stabs "class_name(A):type_def(20)=sym_desc(struct)struct_bytes(8)
139741da
RP
2427 field_name(Adat):type_ref(int),bit_offset(0),field_bits(32);
2428 field_name(A virt func ptr):type_def(21)=type_desc(ptr to)type_def(22)=
6aa83a79
JG
2429 sym_desc(array)index_type_ref(range of int from 0 to 1);
2430 elem_type_ref(vtbl elem type),
139741da
RP
2431 bit_offset(32);
2432 meth_name(A_virt)::typedef(23)=sym_desc(method)returning(int);
2433 :arg_type(int),protection(public)normal(yes)virtual(yes)
2434 vtable_index(1);class_first_defining(A);;;~%first_base(A);",
2435 N_LSYM,NIL,NIL,NIL
899bafeb 2436@end display
e505224d 2437
899bafeb 2438@example
e505224d 2439.stabs "A:t20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
612dbd4c 2440@end example
e505224d 2441
2dd00294
JG
2442@node Inheritence
2443@section Inheritence
e505224d
PB
2444
2445Stabs describing C++ derived classes include additional sections that
2446describe the inheritence hierarchy of the class. A derived class stab
2447also encodes the number of base classes. For each base class it tells
2448if the base class is virtual or not, and if the inheritence is private
2449or public. It also gives the offset into the object of the portion of
2450the object corresponding to each base class.
2451
2452This additional information is embeded in the class stab following the
2453number of bytes in the struct. First the number of base classes
2454appears bracketed by an exclamation point and a comma.
2455
2456Then for each base type there repeats a series: two digits, a number,
2457a comma, another number, and a semi-colon.
2458
2459The first of the two digits is 1 if the base class is virtual and 0 if
2460not. The second digit is 2 if the derivation is public and 0 if not.
2461
2462The number following the first two digits is the offset from the start
2463of the object to the part of the object pertaining to the base class.
2464
2465After the comma, the second number is a type_descriptor for the base
2466type. Finally a semi-colon ends the series, which repeats for each
2467base class.
2468
2469The source below defines three base classes A, B, and C and the
2470derived class D.
2471
2472
2473@example
2474class A @{
2475public:
139741da
RP
2476 int Adat;
2477 virtual int A_virt (int arg) @{ return arg; @};
e505224d
PB
2478@};
2479
2480class B @{
2481public:
139741da
RP
2482 int B_dat;
2483 virtual int B_virt (int arg) @{return arg; @};
e505224d
PB
2484@};
2485
2486class C @{
2487public:
139741da
RP
2488 int Cdat;
2489 virtual int C_virt (int arg) @{return arg; @};
e505224d
PB
2490@};
2491
2492class D : A, virtual B, public C @{
2493public:
139741da
RP
2494 int Ddat;
2495 virtual int A_virt (int arg ) @{ return arg+1; @};
2496 virtual int B_virt (int arg) @{ return arg+2; @};
2497 virtual int C_virt (int arg) @{ return arg+3; @};
2498 virtual int D_virt (int arg) @{ return arg; @};
e505224d
PB
2499@};
2500@end example
2501
2502Class stabs similar to the ones described earlier are generated for
2503each base class.
2504
5bc927fb
RP
2505@c FIXME!!! the linebreaks in the following example probably make the
2506@c examples literally unusable, but I don't know any other way to get
2507@c them on the page.
899bafeb 2508@smallexample
5bc927fb
RP
2509.stabs "A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
2510 A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
e505224d 2511
5bc927fb
RP
2512.stabs "B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1;
2513 :i;2A*-2147483647;25;;;~%25;",128,0,0,0
e505224d 2514
5bc927fb
RP
2515.stabs "C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1;
2516 :i;2A*-2147483647;28;;;~%28;",128,0,0,0
899bafeb 2517@end smallexample
e505224d
PB
2518
2519In the stab describing derived class D below, the information about
2520the derivation of this class is encoded as follows.
2521
899bafeb 2522@display
e505224d 2523.stabs "derived_class_name:symbol_descriptors(struct tag&type)=
139741da
RP
2524 type_descriptor(struct)struct_bytes(32)!num_bases(3),
2525 base_virtual(no)inheritence_public(no)base_offset(0),
2526 base_class_type_ref(A);
2527 base_virtual(yes)inheritence_public(no)base_offset(NIL),
2528 base_class_type_ref(B);
2529 base_virtual(no)inheritence_public(yes)base_offset(64),
2530 base_class_type_ref(C); @dots{}
899bafeb 2531@end display
139741da 2532
5bc927fb 2533@c FIXME! fake linebreaks.
899bafeb 2534@smallexample
5bc927fb
RP
2535.stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:
2536 1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt:
2537 :32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;
2538 28;;D_virt::32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
899bafeb 2539@end smallexample
e505224d 2540
2dd00294 2541@node Virtual Base Classes
e505224d
PB
2542@section Virtual Base Classes
2543
2544A derived class object consists of a concatination in memory of the
2545data areas defined by each base class, starting with the leftmost and
2546ending with the rightmost in the list of base classes. The exception
2547to this rule is for virtual inheritence. In the example above, class
2548D inherits virtually from base class B. This means that an instance
2549of a D object will not contain it's own B part but merely a pointer to
2550a B part, known as a virtual base pointer.
2551
2552In a derived class stab, the base offset part of the derivation
2553information, described above, shows how the base class parts are
2554ordered. The base offset for a virtual base class is always given as
25550. Notice that the base offset for B is given as 0 even though B is
2556not the first base class. The first base class A starts at offset 0.
2557
2558The field information part of the stab for class D describes the field
2559which is the pointer to the virtual base class B. The vbase pointer
2560name is $vb followed by a type reference to the virtual base class.
2561Since the type id for B in this example is 25, the vbase pointer name
2562is $vb25.
2563
5bc927fb 2564@c FIXME!! fake linebreaks below
899bafeb 2565@smallexample
5bc927fb
RP
2566.stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,
2567 160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;
2568 2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt:
2569 :32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
899bafeb 2570@end smallexample
e505224d
PB
2571
2572Following the name and a semicolon is a type reference describing the
2573type of the virtual base class pointer, in this case 24. Type 24 was
c2dc518b 2574defined earlier as the type of the B class `this` pointer. The
e505224d
PB
2575`this' pointer for a class is a pointer to the class type.
2576
899bafeb 2577@example
c2dc518b 2578.stabs "this:P24=*25=xsB:",64,0,0,8
899bafeb 2579@end example
e505224d
PB
2580
2581Finally the field offset part of the vbase pointer field description
2582shows that the vbase pointer is the first field in the D object,
2583before any data fields defined by the class. The layout of a D class
2584object is a follows, Adat at 0, the vtable pointer for A at 32, Cdat
2585at 64, the vtable pointer for C at 96, the virtual ase pointer for B
2586at 128, and Ddat at 160.
2587
2588
899bafeb 2589@node Static Members
e505224d
PB
2590@section Static Members
2591
446e5d80
JG
2592The data area for a class is a concatenation of the space used by the
2593data members of the class. If the class has virtual methods, a vtable
e505224d 2594pointer follows the class data. The field offset part of each field
446e5d80 2595description in the class stab shows this ordering.
e505224d 2596
446e5d80 2597<< How is this reflected in stabs? See Cygnus bug #677 for some info. >>
e505224d 2598
899bafeb 2599@node Example2.c
e505224d
PB
2600@appendix Example2.c - source code for extended example
2601
2602@example
26031 char g_foo = 'c';
26042 register int g_bar asm ("%g5");
26053 static int s_g_repeat = 2;
26064 int (*g_pf)();
26075
26086 struct s_tag @{
26097 int s_int;
26108 float s_float;
26119 char s_char_vec[8];
261210 struct s_tag* s_next;
261311 @} g_an_s;
261412
261513 typedef struct s_tag s_typedef;
261614
261715 char char_vec[3] = @{'a','b','c'@};
261816
261917 main (argc, argv)
262018 int argc;
262119 char* argv[];
262220 @{
262321 static float s_flap;
139741da
RP
262422 int times;
262523 for (times=0; times < s_g_repeat; times++)@{
262624 int inner;
262725 printf ("Hello world\n");
262826 @}
e505224d
PB
262927 @};
263028
263129 enum e_places @{first,second=3,last@};
263230
263331 static s_proc (s_arg, s_ptr_arg, char_vec)
263432 s_typedef s_arg;
263533 s_typedef* s_ptr_arg;
263634 char* char_vec;
263735 @{
263836 union u_tag @{
263937 int u_int;
264038 float u_float;
264139 char* u_char;
264240 @} an_u;
264341 @}
264442
264543
2646@end example
2647
899bafeb 2648@node Example2.s
e505224d
PB
2649@appendix Example2.s - assembly code for extended example
2650
2651@example
26521 gcc2_compiled.:
26532 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
26543 .stabs "example2.c",100,0,0,Ltext0
139741da 26554 .text
e505224d
PB
26565 Ltext0:
26576 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
26587 .stabs "char:t2=r2;0;127;",128,0,0,0
26598 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
26609 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
266110 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
266211 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0
266312 .stabs "long long int:t7=r1;0;-1;",128,0,0,0
266413 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
266514 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
266615 .stabs "signed char:t10=r1;-128;127;",128,0,0,0
266716 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0
266817 .stabs "float:t12=r1;4;0;",128,0,0,0
266918 .stabs "double:t13=r1;8;0;",128,0,0,0
267019 .stabs "long double:t14=r1;8;0;",128,0,0,0
267120 .stabs "void:t15=15",128,0,0,0
267221 .stabs "g_foo:G2",32,0,0,0
139741da
RP
267322 .global _g_foo
267423 .data
e505224d 267524 _g_foo:
139741da 267625 .byte 99
e505224d 267726 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
139741da 267827 .align 4
e505224d 267928 _s_g_repeat:
139741da 268029 .word 2
5bc927fb
RP
2681@c FIXME! fake linebreak in line 30
268230 .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;s_char_vec:
2683 17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
e505224d
PB
268431 .stabs "s_typedef:t16",128,0,0,0
268532 .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
139741da
RP
268633 .global _char_vec
268734 .align 4
e505224d 268835 _char_vec:
139741da
RP
268936 .byte 97
269037 .byte 98
269138 .byte 99
269239 .reserve _s_flap.0,4,"bss",4
269340 .text
269441 .align 4
e505224d 269542 LC0:
139741da
RP
269643 .ascii "Hello world\12\0"
269744 .align 4
269845 .global _main
269946 .proc 1
e505224d
PB
270047 _main:
270148 .stabn 68,0,20,LM1
270249 LM1:
139741da
RP
270350 !#PROLOGUE# 0
270451 save %sp,-144,%sp
270552 !#PROLOGUE# 1
270653 st %i0,[%fp+68]
270754 st %i1,[%fp+72]
270855 call ___main,0
270956 nop
e505224d
PB
271057 LBB2:
271158 .stabn 68,0,23,LM2
271259 LM2:
139741da 271360 st %g0,[%fp-20]
e505224d 271461 L2:
139741da
RP
271562 sethi %hi(_s_g_repeat),%o0
271663 ld [%fp-20],%o1
271764 ld [%o0+%lo(_s_g_repeat)],%o0
271865 cmp %o1,%o0
271966 bge L3
272067 nop
e505224d
PB
272168 LBB3:
272269 .stabn 68,0,25,LM3
272370 LM3:
139741da
RP
272471 sethi %hi(LC0),%o1
272572 or %o1,%lo(LC0),%o0
272673 call _printf,0
272774 nop
e505224d
PB
272875 .stabn 68,0,26,LM4
272976 LM4:
273077 LBE3:
273178 .stabn 68,0,23,LM5
273279 LM5:
273380 L4:
139741da
RP
273481 ld [%fp-20],%o0
273582 add %o0,1,%o1
273683 st %o1,[%fp-20]
273784 b,a L2
e505224d
PB
273885 L3:
273986 .stabn 68,0,27,LM6
274087 LM6:
274188 LBE2:
274289 .stabn 68,0,27,LM7
274390 LM7:
274491 L1:
139741da
RP
274592 ret
274693 restore
e505224d
PB
274794 .stabs "main:F1",36,0,0,_main
274895 .stabs "argc:p1",160,0,0,68
274996 .stabs "argv:p20=*21=*2",160,0,0,72
275097 .stabs "s_flap:V12",40,0,0,_s_flap.0
275198 .stabs "times:1",128,0,0,-20
275299 .stabn 192,0,0,LBB2
2753100 .stabs "inner:1",128,0,0,-24
2754101 .stabn 192,0,0,LBB3
2755102 .stabn 224,0,0,LBE3
2756103 .stabn 224,0,0,LBE2
2757104 .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0
5bc927fb
RP
2758@c FIXME: fake linebreak in line 105
2759105 .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;",
2760128,0,0,0
139741da
RP
2761106 .align 4
2762107 .proc 1
e505224d
PB
2763108 _s_proc:
2764109 .stabn 68,0,35,LM8
2765110 LM8:
139741da
RP
2766111 !#PROLOGUE# 0
2767112 save %sp,-120,%sp
2768113 !#PROLOGUE# 1
2769114 mov %i0,%o0
2770115 st %i1,[%fp+72]
2771116 st %i2,[%fp+76]
e505224d
PB
2772117 LBB4:
2773118 .stabn 68,0,41,LM9
2774119 LM9:
2775120 LBE4:
2776121 .stabn 68,0,41,LM10
2777122 LM10:
2778123 L5:
139741da
RP
2779124 ret
2780125 restore
e505224d
PB
2781126 .stabs "s_proc:f1",36,0,0,_s_proc
2782127 .stabs "s_arg:p16",160,0,0,0
2783128 .stabs "s_ptr_arg:p18",160,0,0,72
2784129 .stabs "char_vec:p21",160,0,0,76
2785130 .stabs "an_u:23",128,0,0,-20
2786131 .stabn 192,0,0,LBB4
2787132 .stabn 224,0,0,LBE4
2788133 .stabs "g_bar:r1",64,0,0,5
2789134 .stabs "g_pf:G24=*25=f1",32,0,0,0
139741da 2790135 .common _g_pf,4,"bss"
e505224d 2791136 .stabs "g_an_s:G16",32,0,0,0
139741da 2792137 .common _g_an_s,20,"bss"
e505224d
PB
2793@end example
2794
899bafeb 2795@node Stab types
8c59ee11 2796@appendix Table A: Symbol types from stabs
e505224d
PB
2797
2798Table A lists stab types sorted by type number. Stab type numbers are
279932 and greater. This is the full list of stab numbers, including stab
2800types that are used in languages other than C.
2801
2802The #define names for these stab types are defined in:
2803devo/include/aout/stab.def
2804
899bafeb 2805@smallexample
e505224d
PB
2806type type #define used to describe
2807dec hex name source program feature
5bc927fb 2808------------------------------------------------
139741da
RP
280932 0x20 N_GYSM global symbol
281034 0X22 N_FNAME function name (for BSD Fortran)
281136 0x24 N_FUN function name or text segment variable for C
281238 0x26 N_STSYM static symbol (data segment w/internal linkage)
281340 0x28 N_LCSYM .lcomm symbol(BSS-seg variable w/internal linkage)
281442 0x2a N_MAIN Name of main routine (not used in C)
281548 0x30 N_PC global symbol (for Pascal)
281650 0x32 N_NSYMS number of symbols (according to Ultrix V4.0)
281752 0x34 N_NOMAP no DST map for sym (according to Ultrix V4.0)
281864 0x40 N_RSYM register variable
281966 0x42 N_M2C Modula-2 compilation unit
282068 0x44 N_SLINE line number in text segment
282170 0x46 N_DSLINE line number in data segment
2822
282372 0x48 N_BSLINE line number in bss segment
282472 0x48 N_BROWS Sun source code browser, path to .cb file
2825
282674 0x4a N_DEFD GNU Modula2 definition module dependency
2827
282880 0x50 N_EHDECL GNU C++ exception variable
282980 0x50 N_MOD2 Modula2 info "for imc" (according to Ultrix V4.0)
2830
283184 0x54 N_CATCH GNU C++ "catch" clause
283296 0x60 N_SSYM structure of union element
2833100 0x64 N_SO path and name of source file
2834128 0x80 N_LSYM automatic var in the stack
2835 (also used for type desc.)
2836130 0x82 N_BINCL beginning of an include file (Sun only)
2837132 0x84 N_SOL Name of sub-source (#include) file.
2838160 0xa0 N_PSYM parameter variable
2839162 0xa2 N_EINCL end of an include file
2840164 0xa4 N_ENTRY alternate entry point
2841192 0xc0 N_LBRAC beginning of a lexical block
2842194 0xc2 N_EXCL place holder for a deleted include file
2843196 0xc4 N_SCOPE modula2 scope information (Sun linker)
2844224 0xe0 N_RBRAC end of a lexical block
2845226 0xe2 N_BCOMM begin named common block
2846228 0xe4 N_ECOMM end named common block
2847232 0xe8 N_ECOML end common (local name)
e505224d
PB
2848
2849 << used on Gould systems for non-base registers syms >>
139741da
RP
2850240 0xf0 N_NBTEXT ??
2851242 0xf2 N_NBDATA ??
2852244 0xf4 N_NBBSS ??
2853246 0xf6 N_NBSTS ??
2854248 0xf8 N_NBLCS ??
899bafeb 2855@end smallexample
e505224d 2856
899bafeb 2857@node Assembler types
8c59ee11 2858@appendix Table B: Symbol types from assembler and linker
e505224d
PB
2859
2860Table B shows the types of symbol table entries that hold assembler
2861and linker symbols.
2862
2863The #define names for these n_types values are defined in
2864/include/aout/aout64.h
2865
899bafeb 2866@smallexample
139741da
RP
2867dec hex #define
2868n_type n_type name used to describe
5bc927fb 2869------------------------------------------
139741da
RP
28701 0x0 N_UNDF undefined symbol
28712 0x2 N_ABS absolute symbol -- defined at a particular address
28723 0x3 extern " (vs. file scope)
28734 0x4 N_TEXT text symbol -- defined at offset in text segment
28745 0x5 extern " (vs. file scope)
28756 0x6 N_DATA data symbol -- defined at offset in data segment
28767 0x7 extern " (vs. file scope)
28778 0x8 N_BSS BSS symbol -- defined at offset in zero'd segment
28789 extern " (vs. file scope)
2879
288012 0x0C N_FN_SEQ func name for Sequent compilers (stab exception)
2881
288249 0x12 N_COMM common sym -- visable after shared lib dynamic link
288331 0x1f N_FN file name of a .o file
899bafeb 2884@end smallexample
e505224d 2885
8c59ee11
JK
2886@node Symbol Descriptors
2887@appendix Table C: Symbol descriptors
e505224d 2888
ed9708e2 2889@c Please keep this alphabetical
497e44a5 2890@table @code
8c59ee11
JK
2891@item @var{(digit)}
2892@itemx (
2893@itemx -
497e44a5
JK
2894Local variable, @xref{Automatic variables}.
2895
6897f9ec
JK
2896@item a
2897Parameter passed by reference in register, @xref{Parameters}.
2898
2899@item c
2900Constant, @xref{Constants}.
2901
ed9708e2 2902@item C
8c59ee11
JK
2903Conformant array bound (Pascal, maybe other languages),
2904@xref{Parameters}. Name of a caught exception (GNU C++). These can be
2905distinguished because the latter uses N_CATCH and the former uses
2906another symbol type.
6897f9ec
JK
2907
2908@item d
2909Floating point register variable, @xref{Register variables}.
2910
2911@item D
2912Parameter in floating point register, @xref{Parameters}.
ed9708e2 2913
497e44a5 2914@item f
6897f9ec 2915Static function, @xref{Procedures}.
497e44a5
JK
2916
2917@item F
2918Global function, @xref{Procedures}.
2919
497e44a5
JK
2920@item G
2921Global variable, @xref{Global Variables}.
2922
ed9708e2
JK
2923@item i
2924@xref{Parameters}.
2925
6897f9ec
JK
2926@item I
2927Internal (nested) procedure, @xref{Procedures}.
2928
2929@item J
2930Internal (nested) function, @xref{Procedures}.
2931
2932@item L
2933Label name (documented by AIX, no further information known).
2934
2935@item m
2936Module, @xref{Procedures}.
2937
ed9708e2 2938@item p
8c59ee11 2939Argument list parameter, @xref{Parameters}.
ed9708e2
JK
2940
2941@item pP
2942@xref{Parameters}.
2943
2944@item pF
8c59ee11 2945FORTRAN Function parameter, @xref{Parameters}.
ed9708e2
JK
2946
2947@item P
1a8b5668
JK
2948Unfortunately, three separate meanings have been independently invented
2949for this symbol descriptor. At least the GNU and Sun uses can be
2950distinguished by the symbol type. Global Procedure (AIX) (symbol type
2951used unknown), @xref{Procedures}. Register parameter (GNU) (symbol type
2952N_PSYM), @xref{Parameters}. Prototype of function referenced by this
2953file (Sun acc) (symbol type N_FUN).
6897f9ec
JK
2954
2955@item Q
2956Static Procedure, @xref{Procedures}.
2957
2958@item R
ed9708e2
JK
2959Register parameter @xref{Parameters}.
2960
497e44a5
JK
2961@item r
2962Register variable, @xref{Register variables}.
2963
2964@item S
2965Static file scope variable @xref{Initialized statics},
1b5c6c05 2966@xref{Un-initialized statics}.
497e44a5 2967
ed9708e2
JK
2968@item t
2969Type name, @xref{Typedefs}.
2970
2971@item T
8c59ee11 2972enumeration, struct or union tag, @xref{Typedefs}.
ed9708e2
JK
2973
2974@item v
8c59ee11 2975Parameter passed by reference, @xref{Parameters}.
ed9708e2 2976
497e44a5
JK
2977@item V
2978Static procedure scope variable @xref{Initialized statics},
1b5c6c05 2979@xref{Un-initialized statics}.
497e44a5 2980
6897f9ec
JK
2981@item x
2982Conformant array, @xref{Parameters}.
2983
ed9708e2
JK
2984@item X
2985Function return variable, @xref{Parameters}.
497e44a5 2986@end table
e505224d 2987
899bafeb 2988@node Type Descriptors
8c59ee11 2989@appendix Table D: Type Descriptors
e505224d 2990
6897f9ec 2991@table @code
8c59ee11
JK
2992@item @var{digit}
2993@itemx (
2994Type reference, @xref{Stabs Format}.
2995
2996@item -
2997Reference to builtin type, @xref{Negative Type Numbers}.
2998
2999@item #
3000Method (C++), @xref{Cplusplus}.
6897f9ec
JK
3001
3002@item *
8c59ee11
JK
3003Pointer, @xref{Miscellaneous Types}.
3004
3005@item &
3006Reference (C++).
6897f9ec
JK
3007
3008@item @@
8c59ee11
JK
3009Type Attributes (AIX), @xref{Stabs Format}. Member (class and variable)
3010type (GNU C++), @xref{Cplusplus}.
e505224d 3011
6897f9ec 3012@item a
8c59ee11
JK
3013Array, @xref{Arrays}.
3014
3015@item A
3016Open array, @xref{Arrays}.
3017
3018@item b
3019Pascal space type (AIX), @xref{Miscellaneous Types}. Builtin integer
3020type (Sun), @xref{Builtin Type Descriptors}.
3021
3022@item B
3023Volatile-qualified type, @xref{Miscellaneous Types}.
3024
3025@item c
3026Complex builtin type, @xref{Builtin Type Descriptors}.
3027
3028@item C
3029COBOL Picture type. See AIX documentation for details.
3030
3031@item d
3032File type, @xref{Miscellaneous Types}.
3033
3034@item D
3035N-dimensional dynamic array, @xref{Arrays}.
6897f9ec
JK
3036
3037@item e
8c59ee11
JK
3038Enumeration type, @xref{Enumerations}.
3039
3040@item E
3041N-dimensional subarray, @xref{Arrays}.
6897f9ec
JK
3042
3043@item f
8c59ee11
JK
3044Function type, @xref{Function types}.
3045
3046@item g
3047Builtin floating point type, @xref{Builtin Type Descriptors}.
3048
3049@item G
3050COBOL Group. See AIX documentation for details.
3051
3052@item i
3053Imported type, @xref{Cross-references}.
3054
3055@item k
3056Const-qualified type, @xref{Miscellaneous Types}.
3057
3058@item K
3059COBOL File Descriptor. See AIX documentation for details.
3060
3061@item n
3062String type, @xref{Strings}.
3063
3064@item N
3065Stringptr, @xref{Strings}.
3066
3067@item M
3068Multiple instance type, @xref{Miscellaneous Types}.
3069
3070@item o
3071Opaque type, @xref{Typedefs}.
3072
3073@item P
3074Packed array, @xref{Arrays}.
6897f9ec
JK
3075
3076@item r
8c59ee11
JK
3077Range type, @xref{Subranges}.
3078
3079@item R
3080Builtin floating type, @xref{Builtin Type Descriptors}.
6897f9ec
JK
3081
3082@item s
8c59ee11
JK
3083Structure type, @xref{Structures}.
3084
3085@item S
3086Set type, @xref{Miscellaneous Types}.
6897f9ec
JK
3087
3088@item u
8c59ee11
JK
3089Union, @xref{Unions}.
3090
3091@item v
3092Variant record. This is a Pascal and Modula-2 feature which is like a
3093union within a struct in C. See AIX documentation for details.
3094
3095@item w
3096Wide character, @xref{Builtin Type Descriptors}.
3097
3098@item x
3099Cross-reference, @xref{Cross-references}.
6897f9ec 3100
8c59ee11
JK
3101@item z
3102gstring, @xref{Strings}.
6897f9ec 3103@end table
e505224d 3104
899bafeb 3105@node Expanded reference
e505224d
PB
3106@appendix Expanded reference by stab type.
3107
8c59ee11
JK
3108@c FIXME: For most types this should be much shorter and much sweeter,
3109@c see N_PSYM for an example. For stuff like N_SO where the stab type
3110@c really is the important thing, the information can stay here.
3111
3112@c FIXME: It probably should be merged with Tables A and B.
3113
e505224d
PB
3114Format of an entry:
3115
3116The first line is the symbol type expressed in decimal, hexadecimal,
3117and as a #define (see devo/include/aout/stab.def).
3118
3119The second line describes the language constructs the symbol type
3120represents.
3121
3122The third line is the stab format with the significant stab fields
3123named and the rest NIL.
3124
3125Subsequent lines expand upon the meaning and possible values for each
3126significant stab field. # stands in for the type descriptor.
3127
3128Finally, any further information.
3129
899bafeb
RP
3130@menu
3131* N_GSYM:: Global variable
3132* N_FNAME:: Function name (BSD Fortran)
3133* N_FUN:: C Function name or text segment variable
3134* N_STSYM:: Initialized static symbol
3135* N_LCSYM:: Uninitialized static symbol
3136* N_MAIN:: Name of main routine (not for C)
3137* N_PC:: Pascal global symbol
3138* N_NSYMS:: Number of symbols
3139* N_NOMAP:: No DST map
3140* N_RSYM:: Register variable
3141* N_M2C:: Modula-2 compilation unit
3142* N_SLINE:: Line number in text segment
3143* N_DSLINE:: Line number in data segment
3144* N_BSLINE:: Line number in bss segment
3145* N_BROWS:: Path to .cb file for Sun source code browser
3146* N_DEFD:: GNU Modula2 definition module dependency
3147* N_EHDECL:: GNU C++ exception variable
3148* N_MOD2:: Modula2 information "for imc"
3149* N_CATCH:: GNU C++ "catch" clause
3150* N_SSYM:: Structure or union element
3151* N_SO:: Source file containing main
3152* N_LSYM:: Automatic variable
3153* N_BINCL:: Beginning of include file (Sun only)
3154* N_SOL:: Name of include file
3155* N_PSYM:: Parameter variable
3156* N_EINCL:: End of include file
3157* N_ENTRY:: Alternate entry point
3158* N_LBRAC:: Beginning of lexical block
3159* N_EXCL:: Deleted include file
3160* N_SCOPE:: Modula2 scope information (Sun only)
3161* N_RBRAC:: End of lexical block
3162* N_BCOMM:: Begin named common block
3163* N_ECOMM:: End named common block
3164* N_ECOML:: End common
3165* Gould:: non-base register symbols used on Gould systems
3166* N_LENG:: Length of preceding entry
3167@end menu
3168
3169@node N_GSYM
139741da 3170@section 32 - 0x20 - N_GYSM
899bafeb
RP
3171
3172@display
e505224d
PB
3173Global variable.
3174
3175.stabs "name", N_GSYM, NIL, NIL, NIL
899bafeb 3176@end display
e505224d 3177
899bafeb 3178@example
e505224d 3179"name" -> "symbol_name:#type"
139741da 3180 # -> G
899bafeb 3181@end example
e505224d 3182
4d7f562d 3183Only the "name" field is significant. The location of the variable is
e505224d
PB
3184obtained from the corresponding external symbol.
3185
899bafeb
RP
3186@node N_FNAME
3187@section 34 - 0x22 - N_FNAME
e505224d
PB
3188Function name (for BSD Fortran)
3189
899bafeb 3190@display
e505224d 3191.stabs "name", N_FNAME, NIL, NIL, NIL
899bafeb 3192@end display
e505224d 3193
899bafeb 3194@example
e505224d 3195"name" -> "function_name"
899bafeb 3196@end example
e505224d
PB
3197
3198Only the "name" field is significant. The location of the symbol is
3199obtained from the corresponding extern symbol.
3200
899bafeb 3201@node N_FUN
6897f9ec 3202@section 36 - 0x24 - N_FUN
e505224d 3203
6897f9ec
JK
3204Function name (@pxref{Procedures}) or text segment variable
3205(@pxref{Variables}).
899bafeb
RP
3206@example
3207@exdent @emph{For functions:}
e505224d 3208"name" -> "proc_name:#return_type"
139741da
RP
3209 # -> F (global function)
3210 f (local function)
e505224d
PB
3211desc -> line num for proc start. (GCC doesn't set and DBX doesn't miss it.)
3212value -> Code address of proc start.
3213
899bafeb 3214@exdent @emph{For text segment variables:}
e505224d 3215<<How to create one?>>
899bafeb 3216@end example
e505224d 3217
899bafeb
RP
3218@node N_STSYM
3219@section 38 - 0x26 - N_STSYM
e505224d
PB
3220Initialized static symbol (data segment w/internal linkage).
3221
899bafeb 3222@display
e505224d 3223.stabs "name", N_STSYM, NIL, NIL, value
899bafeb 3224@end display
e505224d 3225
899bafeb 3226@example
e505224d 3227"name" -> "symbol_name#type"
139741da
RP
3228 # -> S (scope global to compilation unit)
3229 -> V (scope local to a procedure)
e505224d 3230value -> Data Address
899bafeb 3231@end example
e505224d 3232
899bafeb
RP
3233@node N_LCSYM
3234@section 40 - 0x28 - N_LCSYM
e505224d
PB
3235Unitialized static (.lcomm) symbol(BSS segment w/internal linkage).
3236
899bafeb 3237@display
e505224d 3238.stabs "name", N_LCLSYM, NIL, NIL, value
899bafeb 3239@end display
e505224d 3240
899bafeb 3241@example
e505224d 3242"name" -> "symbol_name#type"
139741da
RP
3243 # -> S (scope global to compilation unit)
3244 -> V (scope local to procedure)
e505224d 3245value -> BSS Address
899bafeb 3246@end example
e505224d 3247
899bafeb 3248@node N_MAIN
139741da 3249@section 42 - 0x2a - N_MAIN
e505224d
PB
3250Name of main routine (not used in C)
3251
899bafeb 3252@display
e505224d 3253.stabs "name", N_MAIN, NIL, NIL, NIL
899bafeb 3254@end display
e505224d 3255
899bafeb 3256@example
e505224d 3257"name" -> "name_of_main_routine"
899bafeb 3258@end example
e505224d 3259
899bafeb 3260@node N_PC
139741da 3261@section 48 - 0x30 - N_PC
e505224d
PB
3262Global symbol (for Pascal)
3263
899bafeb 3264@display
e505224d 3265.stabs "name", N_PC, NIL, NIL, value
899bafeb 3266@end display
e505224d 3267
899bafeb 3268@example
e505224d
PB
3269"name" -> "symbol_name" <<?>>
3270value -> supposedly the line number (stab.def is skeptical)
899bafeb 3271@end example
e505224d 3272
899bafeb 3273@display
e505224d
PB
3274stabdump.c says:
3275
3276global pascal symbol: name,,0,subtype,line
3277<< subtype? >>
899bafeb 3278@end display
e505224d 3279
899bafeb 3280@node N_NSYMS
139741da 3281@section 50 - 0x32 - N_NSYMS
e505224d
PB
3282Number of symbols (according to Ultrix V4.0)
3283
899bafeb 3284@display
139741da 3285 0, files,,funcs,lines (stab.def)
899bafeb 3286@end display
e505224d 3287
899bafeb
RP
3288@node N_NOMAP
3289@section 52 - 0x34 - N_NOMAP
e505224d
PB
3290no DST map for sym (according to Ultrix V4.0)
3291
899bafeb 3292@display
139741da 3293 name, ,0,type,ignored (stab.def)
899bafeb
RP
3294@end display
3295
3296@node N_RSYM
139741da 3297@section 64 - 0x40 - N_RSYM
e505224d
PB
3298 register variable
3299
899bafeb 3300@display
e505224d 3301.stabs "name:type",N_RSYM,0,RegSize,RegNumber (Sun doc)
899bafeb 3302@end display
e505224d 3303
899bafeb 3304@node N_M2C
139741da 3305@section 66 - 0x42 - N_M2C
e505224d
PB
3306Modula-2 compilation unit
3307
899bafeb 3308@display
e505224d 3309.stabs "name", N_M2C, 0, desc, value
899bafeb 3310@end display
e505224d 3311
899bafeb 3312@example
e505224d
PB
3313"name" -> "unit_name,unit_time_stamp[,code_time_stamp]
3314desc -> unit_number
3315value -> 0 (main unit)
139741da 3316 1 (any other unit)
899bafeb 3317@end example
e505224d 3318
899bafeb 3319@node N_SLINE
139741da 3320@section 68 - 0x44 - N_SLINE
e505224d
PB
3321Line number in text segment
3322
899bafeb 3323@display
e505224d 3324.stabn N_SLINE, 0, desc, value
899bafeb 3325@end display
e505224d 3326
899bafeb 3327@example
e505224d
PB
3328desc -> line_number
3329value -> code_address (relocatable addr where the corresponding code starts)
899bafeb 3330@end example
e505224d
PB
3331
3332For single source lines that generate discontiguous code, such as flow
3333of control statements, there may be more than one N_SLINE stab for the
3334same source line. In this case there is a stab at the start of each
3335code range, each with the same line number.
3336
899bafeb
RP
3337@node N_DSLINE
3338@section 70 - 0x46 - N_DSLINE
e505224d
PB
3339Line number in data segment
3340
899bafeb 3341@display
e505224d 3342.stabn N_DSLINE, 0, desc, value
899bafeb 3343@end display
e505224d 3344
899bafeb 3345@example
e505224d 3346desc -> line_number
899bafeb
RP
3347value -> data_address (relocatable addr where the corresponding code
3348starts)
3349@end example
e505224d
PB
3350
3351See comment for N_SLINE above.
3352
899bafeb
RP
3353@node N_BSLINE
3354@section 72 - 0x48 - N_BSLINE
e505224d
PB
3355Line number in bss segment
3356
899bafeb 3357@display
e505224d 3358.stabn N_BSLINE, 0, desc, value
899bafeb 3359@end display
e505224d 3360
899bafeb 3361@example
e505224d 3362desc -> line_number
899bafeb
RP
3363value -> bss_address (relocatable addr where the corresponding code
3364starts)
3365@end example
e505224d
PB
3366
3367See comment for N_SLINE above.
3368
899bafeb 3369@node N_BROWS
139741da 3370@section 72 - 0x48 - N_BROWS
e505224d
PB
3371Sun source code browser, path to .cb file
3372
3373<<?>>
3374"path to associated .cb file"
3375
3376Note: type field value overlaps with N_BSLINE
3377
899bafeb 3378@node N_DEFD
139741da 3379@section 74 - 0x4a - N_DEFD
612dbd4c 3380GNU Modula2 definition module dependency
e505224d
PB
3381
3382GNU Modula-2 definition module dependency. Value is the modification
3383time of the definition file. Other is non-zero if it is imported with
3384the GNU M2 keyword %INITIALIZE. Perhaps N_M2C can be used if there
3385are enough empty fields?
3386
899bafeb
RP
3387@node N_EHDECL
3388@section 80 - 0x50 - N_EHDECL
612dbd4c 3389GNU C++ exception variable <<?>>
e505224d
PB
3390
3391"name is variable name"
3392
3393Note: conflicts with N_MOD2.
3394
899bafeb
RP
3395@node N_MOD2
3396@section 80 - 0x50 - N_MOD2
3397Modula2 info "for imc" (according to Ultrix V4.0)
e505224d
PB
3398
3399Note: conflicts with N_EHDECL <<?>>
3400
899bafeb
RP
3401@node N_CATCH
3402@section 84 - 0x54 - N_CATCH
3403GNU C++ "catch" clause
e505224d
PB
3404
3405GNU C++ `catch' clause. Value is its address. Desc is nonzero if
3406this entry is immediately followed by a CAUGHT stab saying what
3407exception was caught. Multiple CAUGHT stabs means that multiple
3408exceptions can be caught here. If Desc is 0, it means all exceptions
3409are caught here.
3410
899bafeb 3411@node N_SSYM
139741da 3412@section 96 - 0x60 - N_SSYM
e505224d
PB
3413Structure or union element
3414
899bafeb
RP
3415Value is offset in the structure.
3416
3417<<?looking at structs and unions in C I didn't see these>>
e505224d 3418
899bafeb 3419@node N_SO
139741da 3420@section 100 - 0x64 - N_SO
e505224d
PB
3421Path and name of source file containing main routine
3422
899bafeb 3423@display
e505224d 3424.stabs "name", N_SO, NIL, NIL, value
899bafeb 3425@end display
e505224d 3426
899bafeb 3427@example
c0264596
JK
3428"name" -> /source/directory/
3429 -> source_file
e505224d
PB
3430
3431value -> the starting text address of the compilation.
899bafeb 3432@end example
e505224d 3433
c0264596
JK
3434These are found two in a row. The name field of the first N_SO contains
3435the directory that the source file is relative to. The name field of
3436the second N_SO contains the name of the source file itself.
3437
3438Only some compilers (e.g. gcc2, Sun cc) include the directory; this
3439symbol can be distinguished by the fact that it ends in a slash.
3440According to a comment in GDB's partial-stab.h, other compilers
3441(especially unnamed C++ compilers) put out useless N_SO's for
3442nonexistent source files (after the N_SO for the real source file).
e505224d 3443
899bafeb 3444@node N_LSYM
139741da 3445@section 128 - 0x80 - N_LSYM
e505224d
PB
3446Automatic var in the stack (also used for type descriptors.)
3447
899bafeb 3448@display
e505224d 3449.stabs "name" N_LSYM, NIL, NIL, value
899bafeb 3450@end display
e505224d 3451
899bafeb
RP
3452@example
3453@exdent @emph{For stack based local variables:}
e505224d
PB
3454
3455"name" -> name of the variable
3456value -> offset from frame pointer (negative)
3457
899bafeb 3458@exdent @emph{For type descriptors:}
e505224d
PB
3459
3460"name" -> "name_of_the_type:#type"
139741da 3461 # -> t
e505224d 3462
139741da 3463type -> type_ref (or) type_def
e505224d
PB
3464
3465type_ref -> type_number
3466type_def -> type_number=type_desc etc.
899bafeb 3467@end example
e505224d
PB
3468
3469Type may be either a type reference or a type definition. A type
3470reference is a number that refers to a previously defined type. A
3471type definition is the number that will refer to this type, followed
3472by an equals sign, a type descriptor and the additional data that
3473defines the type. See the Table D for type descriptors and the
3474section on types for what data follows each type descriptor.
3475
899bafeb 3476@node N_BINCL
139741da 3477@section 130 - 0x82 - N_BINCL
e505224d
PB
3478
3479Beginning of an include file (Sun only)
3480
3481Beginning of an include file. Only Sun uses this. In an object file,
3482only the name is significant. The Sun linker puts data into some of
3483the other fields.
3484
899bafeb
RP
3485@node N_SOL
3486@section 132 - 0x84 - N_SOL
e505224d
PB
3487
3488Name of a sub-source file (#include file). Value is starting address
3489of the compilation.
3490<<?>>
3491
899bafeb 3492@node N_PSYM
139741da 3493@section 160 - 0xa0 - N_PSYM
e505224d 3494
a2a2eac8 3495Parameter variable. @xref{Parameters}.
e505224d 3496
899bafeb
RP
3497@node N_EINCL
3498@section 162 - 0xa2 - N_EINCL
e505224d
PB
3499
3500End of an include file. This and N_BINCL act as brackets around the
3501file's output. In an ojbect file, there is no significant data in
899bafeb 3502this entry. The Sun linker puts data into some of the fields.
e505224d
PB
3503<<?>>
3504
899bafeb
RP
3505@node N_ENTRY
3506@section 164 - 0xa4 - N_ENTRY
e505224d
PB
3507
3508Alternate entry point.
3509Value is its address.
3510<<?>>
3511
899bafeb
RP
3512@node N_LBRAC
3513@section 192 - 0xc0 - N_LBRAC
e505224d
PB
3514
3515Beginning of a lexical block (left brace). The variable defined
3516inside the block precede the N_LBRAC symbol. Or can they follow as
3517well as long as a new N_FUNC was not encountered. <<?>>
3518
899bafeb 3519@display
e505224d 3520.stabn N_LBRAC, NIL, NIL, value
899bafeb 3521@end display
e505224d 3522
899bafeb 3523@example
e505224d 3524value -> code address of block start.
899bafeb 3525@end example
e505224d 3526
899bafeb
RP
3527@node N_EXCL
3528@section 194 - 0xc2 - N_EXCL
e505224d
PB
3529
3530Place holder for a deleted include file. Replaces a N_BINCL and
3531everything up to the corresponding N_EINCL. The Sun linker generates
3532these when it finds multiple indentical copies of the symbols from an
3533included file. This appears only in output from the Sun linker.
3534<<?>>
3535
899bafeb
RP
3536@node N_SCOPE
3537@section 196 - 0xc4 - N_SCOPE
e505224d
PB
3538
3539Modula2 scope information (Sun linker)
3540<<?>>
3541
899bafeb 3542@node N_RBRAC
139741da 3543@section 224 - 0xe0 - N_RBRAC
e505224d
PB
3544
3545End of a lexical block (right brace)
3546
899bafeb 3547@display
e505224d 3548.stabn N_RBRAC, NIL, NIL, value
899bafeb 3549@end display
e505224d 3550
899bafeb 3551@example
e505224d 3552value -> code address of the end of the block.
899bafeb 3553@end example
e505224d 3554
899bafeb 3555@node N_BCOMM
139741da 3556@section 226 - 0xe2 - N_BCOMM
e505224d
PB
3557
3558Begin named common block.
3559
3560Only the name is significant.
3561<<?>>
3562
899bafeb 3563@node N_ECOMM
139741da 3564@section 228 - 0xe4 - N_ECOMM
e505224d
PB
3565
3566End named common block.
3567
3568Only the name is significant and it should match the N_BCOMM
3569<<?>>
3570
899bafeb
RP
3571@node N_ECOML
3572@section 232 - 0xe8 - N_ECOML
e505224d
PB
3573
3574End common (local name)
3575
3576value is address.
3577<<?>>
3578
899bafeb
RP
3579@node Gould
3580@section Non-base registers on Gould systems
e505224d
PB
3581<< used on Gould systems for non-base registers syms, values assigned
3582at random, need real info from Gould. >>
3583<<?>>
3584
899bafeb 3585@example
139741da
RP
3586240 0xf0 N_NBTEXT ??
3587242 0xf2 N_NBDATA ??
3588244 0xf4 N_NBBSS ??
3589246 0xf6 N_NBSTS ??
3590248 0xf8 N_NBLCS ??
899bafeb 3591@end example
e505224d 3592
899bafeb
RP
3593@node N_LENG
3594@section - 0xfe - N_LENG
e505224d
PB
3595
3596Second symbol entry containing a length-value for the preceding entry.
3597The value is the length.
3598
899bafeb
RP
3599@node Questions
3600@appendix Questions and anomalies
e505224d
PB
3601
3602@itemize @bullet
3603@item
3604For GNU C stabs defining local and global variables (N_LSYM and
3605N_GSYM), the desc field is supposed to contain the source line number
3606on which the variable is defined. In reality the desc field is always
36070. (This behavour is defined in dbxout.c and putting a line number in
3608desc is controlled by #ifdef WINNING_GDB which defaults to false). Gdb
3609supposedly uses this information if you say 'list var'. In reality
3610var can be a variable defined in the program and gdb says `function
3611var not defined'
3612
3613@item
612dbd4c 3614In GNU C stabs there seems to be no way to differentiate tag types:
e505224d
PB
3615structures, unions, and enums (symbol descriptor T) and typedefs
3616(symbol descriptor t) defined at file scope from types defined locally
3617to a procedure or other more local scope. They all use the N_LSYM
3618stab type. Types defined at procedure scope are emited after the
139741da 3619N_RBRAC of the preceding function and before the code of the
e505224d
PB
3620procedure in which they are defined. This is exactly the same as
3621types defined in the source file between the two procedure bodies.
4d7f562d 3622GDB overcompensates by placing all types in block #1, the block for
e505224d 3623symbols of file scope. This is true for default, -ansi and
4d7f562d 3624-traditional compiler options. (Bugs gcc/1063, gdb/1066.)
e505224d
PB
3625
3626@item
3627What ends the procedure scope? Is it the proc block's N_RBRAC or the
3628next N_FUN? (I believe its the first.)
3629
3630@item
3631The comment in xcoff.h says DBX_STATIC_CONST_VAR_CODE is used for
3632static const variables. DBX_STATIC_CONST_VAR_CODE is set to N_FUN by
3633default, in dbxout.c. If included, xcoff.h redefines it to N_STSYM.
3634But testing the default behaviour, my Sun4 native example shows
3635N_STSYM not N_FUN is used to describe file static initialized
3636variables. (the code tests for TREE_READONLY(decl) &&
3637!TREE_THIS_VOLATILE(decl) and if true uses DBX_STATIC_CONST_VAR_CODE).
3638
3639@item
3640Global variable stabs don't have location information. This comes
3641from the external symbol for the same variable. The external symbol
3642has a leading underbar on the _name of the variable and the stab does
3643not. How do we know these two symbol table entries are talking about
3644the same symbol when their names are different?
3645
3646@item
3647Can gcc be configured to output stabs the way the Sun compiler
3648does, so that their native debugging tools work? <NO?> It doesn't by
3649default. GDB reads either format of stab. (gcc or SunC). How about
3650dbx?
3651@end itemize
3652
899bafeb 3653@node xcoff-differences
e505224d
PB
3654@appendix Differences between GNU stabs in a.out and GNU stabs in xcoff
3655
497e44a5
JK
3656@c FIXME: Merge *all* these into the main body of the document.
3657(The AIX/RS6000 native object file format is xcoff with stabs). This
3658appendix only covers those differences which are not covered in the main
3659body of this document.
e505224d
PB
3660
3661@itemize @bullet
3662@item
3663Instead of .stabs, xcoff uses .stabx.
3664
3665@item
3666The data fields of an xcoff .stabx are in a different order than an
1a8b5668
JK
3667a.out .stabs. The order is: string, value, type, sdb-type. The desc
3668and null fields present in a.out stabs are missing in xcoff stabs. For
3669N_GSYM the value field is the name of the symbol. sdb-type is unused
3670with stabs; it can always be set to 0.
e505224d
PB
3671
3672@item
5bc927fb 3673BSD a.out stab types correspond to AIX xcoff storage classes. In general the
e505224d
PB
3674mapping is N_STABTYPE becomes C_STABTYPE. Some stab types in a.out
3675are not supported in xcoff. See Table E. for full mappings.
3676
3677exception:
3678initialised static N_STSYM and un-initialized static N_LCSYM both map
3679to the C_STSYM storage class. But the destinction is preserved
3680because in xcoff N_STSYM and N_LCSYM must be emited in a named static
3681block. Begin the block with .bs s[RW] data_section_name for N_STSYM
3682or .bs s bss_section_name for N_LCSYM. End the block with .es
3683
e505224d
PB
3684@item
3685xcoff uses a .file stab type to represent the source file name. There
3686is no stab for the path to the source file.
3687
3688@item
3689xcoff uses a .line stab type to represent source lines. The format
3690is: .line line_number.
3691
3692@item
3693xcoff emits line numbers relative to the start of the current
3694function. The start of a function is marked by .bf. If a function
3695includes lines from a seperate file, then those line numbers are
3696absolute line numbers in the <<sub-?>> file being compiled.
3697
3698@item
3699The start of current include file is marked with: .bi "filename" and
3700the end marked with .ei "filename"
3701
3702@item
3703If the xcoff stab is a N_FUN (C_FUN) then follow the string field with
3704,. instead of just ,
e505224d
PB
3705@end itemize
3706
3707
3708(I think that's it for .s file differences. They could stand to be
3709better presented. This is just a list of what I have noticed so far.
3710There are a *lot* of differences in the information in the symbol
3711tables of the executable and object files.)
3712
3713Table E: mapping a.out stab types to xcoff storage classes
3714
3715@example
139741da 3716stab type storage class
e505224d 3717-------------------------------
139741da
RP
3718N_GSYM C_GSYM
3719N_FNAME unknown
3720N_FUN C_FUN
3721N_STSYM C_STSYM
3722N_LCSYM C_STSYM
3723N_MAIN unkown
3724N_PC unknown
3725N_RSYM C_RSYM
3726N_RPSYM (0x8e) C_RPSYM
3727N_M2C unknown
3728N_SLINE unknown
3729N_DSLINE unknown
3730N_BSLINE unknown
3731N_BROWSE unchanged
3732N_CATCH unknown
3733N_SSYM unknown
3734N_SO unknown
3735N_LSYM C_LSYM
3736N_DECL (0x8c) C_DECL
3737N_BINCL unknown
3738N_SOL unknown
3739N_PSYM C_PSYM
3740N_EINCL unknown
3741N_ENTRY C_ENTRY
3742N_LBRAC unknown
3743N_EXCL unknown
3744N_SCOPE unknown
3745N_RBRAC unknown
3746N_BCOMM C_BCOMM
3747N_ECOMM C_ECOMM
3748N_ECOML C_ECOML
3749
3750N_LENG unknown
e505224d
PB
3751@end example
3752
899bafeb 3753@node Sun-differences
e505224d
PB
3754@appendix Differences between GNU stabs and Sun native stabs.
3755
497e44a5
JK
3756@c FIXME: Merge all this stuff into the main body of the document.
3757
e505224d
PB
3758@itemize @bullet
3759@item
612dbd4c 3760GNU C stabs define *all* types, file or procedure scope, as
e505224d
PB
3761N_LSYM. Sun doc talks about using N_GSYM too.
3762
e505224d
PB
3763@item
3764Stabs describing block scopes, N_LBRAC and N_RBRAC are supposed to
3765contain the nesting level of the block in the desc field, re Sun doc.
497e44a5 3766GNU stabs always have 0 in that field. dbx seems not to care.
e505224d
PB
3767
3768@item
3769Sun C stabs use type number pairs in the format (a,b) where a is a
3770number starting with 1 and incremented for each sub-source file in the
3771compilation. b is a number starting with 1 and incremented for each
612dbd4c 3772new type defined in the compilation. GNU C stabs use the type number
e505224d
PB
3773alone, with no source file number.
3774@end itemize
3775
3776@contents
3777@bye
This page took 0.318483 seconds and 4 git commands to generate.