Doc fixes to previous doc fixes.
[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
612dbd4c 13This document describes GNU stabs (debugging symbol tables) in a.out files.
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
e505224d 70* Simple types::
139741da 71* Example:: A comprehensive example in C
e505224d 72* Variables::
8d0dca57 73* Aggregate Types::
139741da 74* Symbol tables:: Symbol information in symbol tables
b32ae57b 75* GNU Cplusplus stabs::
e505224d
PB
76
77Appendixes:
139741da
RP
78* Example2.c:: Source code for extended example
79* Example2.s:: Assembly code for extended example
80* Quick reference:: Various refernce tables
81* Expanded reference:: Reference information by stab type
82* Questions:: Questions and anomolies
83* xcoff-differences:: Differences between GNU stabs in a.out
84 and GNU stabs in xcoff
85* Sun-differences:: Differences between GNU stabs and Sun
86 native stabs
e505224d 87@end menu
899bafeb 88@end ifinfo
e505224d
PB
89
90
899bafeb 91@node Overview
e505224d
PB
92@chapter Overview of stabs
93
139741da
RP
94@dfn{Stabs} refers to a format for information that describes a program
95to a debugger. This format was apparently invented by
96@c FIXME! <<name of inventor>> at
97the University of California at Berkeley, for the @code{pdx} Pascal
98debugger; the format has spread widely since then.
99
e505224d
PB
100@menu
101* Flow:: Overview of debugging information flow
102* Stabs format:: Overview of stab format
103* C example:: A simple example in C source
104* Assembly code:: The simple example at the assembly level
105@end menu
106
899bafeb 107@node Flow
e505224d
PB
108@section Overview of debugging information flow
109
139741da
RP
110The GNU C compiler compiles C source in a @file{.c} file into assembly
111language in a @file{.s} file, which is translated by the assembler into
112a @file{.o} file, and then linked with other @file{.o} files and
113libraries to produce an executable file.
e505224d 114
139741da
RP
115With the @samp{-g} option, GCC puts additional debugging information in
116the @file{.s} file, which is slightly transformed by the assembler and
e505224d
PB
117linker, and carried through into the final executable. This debugging
118information describes features of the source file like line numbers,
119the types and scopes of variables, and functions, their parameters and
120their scopes.
121
122For some object file formats, the debugging information is
139741da 123encapsulated in assembler directives known collectively as `stab' (symbol
e505224d
PB
124table) directives, interspersed with the generated code. Stabs are
125the native format for debugging information in the a.out and xcoff
126object file formats. The GNU tools can also emit stabs in the coff
127and ecoff object file formats.
128
139741da
RP
129The assembler adds the information from stabs to the symbol information
130it places by default in the symbol table and the string table of the
131@file{.o} file it is building. The linker consolidates the @file{.o}
132files into one executable file, with one symbol table and one string
133table. Debuggers use the symbol and string tables in the executable as
134a source of debugging information about the program.
e505224d 135
899bafeb 136@node Stabs format
e505224d
PB
137@section Overview of stab format
138
139There are three overall formats for stab assembler directives
139741da
RP
140differentiated by the first word of the stab. The name of the directive
141describes what combination of four possible data fields will follow. It
142is either @code{.stabs} (string), @code{.stabn} (number), or
143@code{.stabd} (dot).
e505224d
PB
144
145The overall format of each class of stab is:
146
147@example
139741da
RP
148.stabs "@var{string}",@var{type},0,@var{desc},@var{value}
149.stabn @var{type},0,@var{desc},@var{value}
150.stabd @var{type},0,@var{desc}
e505224d
PB
151@end example
152
139741da
RP
153In general, in @code{.stabs} the @var{string} field contains name and type
154information. For @code{.stabd} the value field is implicit and has the value
e505224d
PB
155of the current file location. Otherwise the value field often
156contains a relocatable address, frame pointer offset, or register
157number, that maps to the source code element described by the stab.
158
139741da
RP
159The real key to decoding the meaning of a stab is the number in its type
160field. Each possible type number defines a different stab type. The
161stab type further defines the exact interpretation of, and possible
162values for, any remaining @code{"@var{string}"}, @var{desc}, or
163@var{value} fields present in the stab. Table A (@pxref{Stab
164types,,Table A: Symbol types from stabs}) lists in numeric order
165the possible type field values for stab directives. The reference
166section that follows Table A describes the meaning of the fields for
167each stab type in detail. The examples that follow this overview
168introduce the stab types in terms of the source code elements they
169describe.
e505224d 170
139741da
RP
171For @code{.stabs} the @code{"@var{string}"} field holds the meat of the
172debugging information. The generally unstructured nature of this field
173is what makes stabs extensible. For some stab types the string field
174contains only a name. For other stab types the contents can be a great
175deal more complex.
e505224d 176
139741da 177The overall format is of the @code{"@var{string}"} field is:
e505224d
PB
178
179@example
139741da
RP
180"@var{name}@r{[}:@var{symbol_descriptor}@r{]}
181 @r{[}@var{type_number}@r{[}=@var{type_descriptor} @r{@dots{}]]}"
e505224d
PB
182@end example
183
139741da 184@var{name} is the name of the symbol represented by the stab.
e505224d 185
139741da
RP
186The @var{symbol_descriptor} following the @samp{:} is an alphabetic
187character that tells more specifically what kind of symbol the stab
188represents. If the @var{symbol_descriptor} is omitted, but type
189information follows, then the stab represents a local variable. For a
190list of symbol_descriptors, see @ref{Symbol descriptors,,Table C: Symbol
191descriptors}.
e505224d 192
139741da
RP
193Type information is either a @var{type_number}, or a
194@samp{@var{type_number}=}. The @var{type_number} alone is a type
195reference, referring directly to a type that has already been defined.
e505224d 196
139741da
RP
197The @samp{@var{type_number}=} is a type definition, where the number
198represents a new type which is about to be defined. The type definition
199may refer to other types by number, and those type numbers may be
200followed by @samp{=} and nested definitions.
e505224d
PB
201
202In a type definition, if the character that follows the equals sign is
139741da
RP
203non-numeric then it is a @var{type_descriptor}, and tells what kind of
204type is about to be defined. Any other values following the
205@var{type_descriptor} vary, depending on the @var{type_descriptor}. If
206a number follows the @samp{=} then the number is a @var{type_reference}.
207This is described more thoroughly in the section on types. @xref{Type
208Descriptors,,Table D: Type Descriptors}, for a list of
209@var{type_descriptor} values.
210
b6963343
JK
211All this can make the @code{"@var{string}"} field quite long. All
212versions of GDB, and some versions of DBX, can handle arbitrarily long
213strings. But many versions of DBX cretinously limit the strings to
214about 80 characters, so compilers which must work with such DBX's need
215to split the @code{.stabs} directive into several @code{.stabs}
216directives. Each stab duplicates exactly all but the
217@code{"@var{string}"} field. The @code{"@var{string}"} field of the
218every stab except the last is marked as continued with a
219double-backslash at the end. Removing the backslashes and concatenating
220the @code{"@var{string}"} fields of each stab produces the original,
221long string.
e505224d 222
899bafeb 223@node C example
e505224d
PB
224@section A simple example in C source
225
226To get the flavor of how stabs describe source information for a C
227program, let's look at the simple program:
228
229@example
230main()
231@{
139741da 232 printf("Hello world");
e505224d
PB
233@}
234@end example
235
139741da
RP
236When compiled with @samp{-g}, the program above yields the following
237@file{.s} file. Line numbers have been added to make it easier to refer
238to parts of the @file{.s} file in the description of the stabs that
239follows.
e505224d 240
899bafeb 241@node Assembly code
e505224d
PB
242@section The simple example at the assembly level
243
244@example
2451 gcc2_compiled.:
2462 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
2473 .stabs "hello.c",100,0,0,Ltext0
2484 .text
2495 Ltext0:
2506 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
2517 .stabs "char:t2=r2;0;127;",128,0,0,0
2528 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
2539 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
25410 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
25511 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0
25612 .stabs "long long int:t7=r1;0;-1;",128,0,0,0
25713 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
25814 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
25915 .stabs "signed char:t10=r1;-128;127;",128,0,0,0
26016 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0
26117 .stabs "float:t12=r1;4;0;",128,0,0,0
26218 .stabs "double:t13=r1;8;0;",128,0,0,0
26319 .stabs "long double:t14=r1;8;0;",128,0,0,0
26420 .stabs "void:t15=15",128,0,0,0
139741da 26521 .align 4
e505224d 26622 LC0:
139741da
RP
26723 .ascii "Hello, world!\12\0"
26824 .align 4
26925 .global _main
27026 .proc 1
e505224d
PB
27127 _main:
27228 .stabn 68,0,4,LM1
27329 LM1:
139741da
RP
27430 !#PROLOGUE# 0
27531 save %sp,-136,%sp
27632 !#PROLOGUE# 1
27733 call ___main,0
27834 nop
e505224d
PB
27935 .stabn 68,0,5,LM2
28036 LM2:
28137 LBB2:
139741da
RP
28238 sethi %hi(LC0),%o1
28339 or %o1,%lo(LC0),%o0
28440 call _printf,0
28541 nop
e505224d
PB
28642 .stabn 68,0,6,LM3
28743 LM3:
28844 LBE2:
28945 .stabn 68,0,6,LM4
29046 LM4:
29147 L1:
139741da
RP
29248 ret
29349 restore
e505224d
PB
29450 .stabs "main:F1",36,0,0,_main
29551 .stabn 192,0,0,LBB2
29652 .stabn 224,0,0,LBE2
297@end example
298
139741da 299This simple ``hello world'' example demonstrates several of the stab
e505224d
PB
300types used to describe C language source files.
301
899bafeb 302@node Program structure
139741da 303@chapter Encoding for the structure of the program
e505224d
PB
304
305@menu
306* Source file:: The path and name of the source file
307* Line numbers::
308* Procedures::
8d0dca57 309* Block Structure::
e505224d
PB
310@end menu
311
899bafeb 312@node Source file
e505224d
PB
313@section The path and name of the source file
314
139741da
RP
315@table @strong
316@item Directive:
317@code{.stabs}
318@item Type:
319@code{N_SO}
320@end table
e505224d
PB
321
322The first stabs in the .s file contain the name and path of the source
323file that was compiled to produce the .s file. This information is
324contained in two records of stab type N_SO (100).
325
326@example
327 .stabs "path_name", N_SO, NIL, NIL, Code_address_of_program_start
328 .stabs "file_name:", N_SO, NIL, NIL, Code_address_of_program_start
329@end example
330
331@example
3322 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
3333 .stabs "hello.c",100,0,0,Ltext0
139741da 3344 .text
e505224d
PB
3355 Ltext0:
336@end example
337
899bafeb 338@node Line numbers
e505224d
PB
339@section Line Numbers
340
139741da
RP
341@table @strong
342@item Directive:
343@code{.stabn}
344@item Type:
345@code{N_SLINE}
346@end table
e505224d 347
139741da 348The start of source lines is represented by the @code{N_SLINE} (68) stab
e505224d
PB
349type.
350
351@example
139741da 352.stabn N_SLINE, NIL, @var{line}, @var{address}
e505224d
PB
353@end example
354
139741da
RP
355@var{line} is a source line number; @var{address} represents the code
356address for the start of that source line.
357
e505224d
PB
358@example
35927 _main:
36028 .stabn 68,0,4,LM1
36129 LM1:
139741da 36230 !#PROLOGUE# 0
e505224d
PB
363@end example
364
899bafeb 365@node Procedures
e505224d
PB
366@section Procedures
367
139741da
RP
368@table @strong
369@item Directive:
370@code{.stabs}
371@item Type:
372@code{N_FUN}
373@item Symbol Descriptors:
374@code{f} (local), @code{F} (global)
375@end table
e505224d 376
139741da
RP
377Procedures are described by the @code{N_FUN} stab type. The symbol
378descriptor for a procedure is @samp{F} if the procedure is globally
379scoped and @samp{f} if the procedure is static (locally scoped).
e505224d 380
139741da
RP
381The @code{N_FUN} stab representing a procedure is located immediately
382following the code of the procedure. The @code{N_FUN} stab is in turn
e505224d
PB
383directly followed by a group of other stabs describing elements of the
384procedure. These other stabs describe the procedure's parameters, its
385block local variables and its block structure.
386
387@example
139741da
RP
38848 ret
38949 restore
e505224d
PB
390@end example
391
139741da
RP
392The @code{.stabs} entry after this code fragment shows the @var{name} of
393the procedure (@code{main}); the type descriptor @var{desc} (@code{F},
394for a global procedure); a reference to the predefined type @code{int}
395for the return type; and the starting @var{address} of the procedure.
396
397Here is an exploded summary (with whitespace introduced for clarity),
398followed by line 50 of our sample assembly output, which has this form:
399
e505224d 400@example
139741da
RP
401.stabs "@var{name}:
402 @var{desc} @r{(global proc @samp{F})}
403 @var{return_type_ref} @r{(int)}
404 ",N_FUN, NIL, NIL,
405 @var{address}
e505224d
PB
406@end example
407
408@example
40950 .stabs "main:F1",36,0,0,_main
410@end example
411
899bafeb 412@node Block Structure
e505224d
PB
413@section Block Structure
414
139741da
RP
415@table @strong
416@item Directive:
417@code{.stabn}
418@item Types:
419@code{N_LBRAC}, @code{N_RBRAC}
420@end table
e505224d 421
139741da
RP
422The program's block structure is represented by the @code{N_LBRAC} (left
423brace) and the @code{N_RBRAC} (right brace) stab types. The following code
424range, which is the body of @code{main}, is labeled with @samp{LBB2:} at the
425beginning and @samp{LBE2:} at the end.
e505224d
PB
426
427@example
42837 LBB2:
139741da
RP
42938 sethi %hi(LC0),%o1
43039 or %o1,%lo(LC0),%o0
43140 call _printf,0
43241 nop
e505224d
PB
43342 .stabn 68,0,6,LM3
43443 LM3:
43544 LBE2:
436@end example
437
139741da
RP
438The @code{N_LBRAC} and @code{N_RBRAC} stabs that describe the block
439scope of the procedure are located after the @code{N_FUNC} stab that
440represents the procedure itself. The @code{N_LBRAC} uses the
441@code{LBB2} label as the code address in its value field, and the
442@code{N_RBRAC} uses @code{LBE2}.
e505224d
PB
443
444@example
44550 .stabs "main:F1",36,0,0,_main
446@end example
447
448@example
139741da
RP
449 .stabn N_LBRAC, NIL, NIL, @var{left-brace-address}
450 .stabn N_RBRAC, NIL, NIL, @var{right-brace-address}
e505224d
PB
451@end example
452
453@example
45451 .stabn 192,0,0,LBB2
45552 .stabn 224,0,0,LBE2
456@end example
457
899bafeb 458@node Simple types
e505224d
PB
459@chapter Simple types
460
461@menu
139741da 462* Basic types:: Basic type definitions
e505224d 463* Range types:: Range types defined by min and max value
831c2e1d 464* Float "range" types:: Range type defined by size in bytes
e505224d
PB
465@end menu
466
899bafeb 467@node Basic types
e505224d
PB
468@section Basic type definitions
469
139741da
RP
470@table @strong
471@item Directive:
472@code{.stabs}
473@item Type:
474@code{N_LSYM}
475@item Symbol Descriptor:
476@code{t}
477@end table
e505224d 478
139741da 479The basic types for the language are described using the @code{N_LSYM} stab
e505224d
PB
480type. They are boilerplate and are emited by the compiler for each
481compilation unit. Basic type definitions are not always a complete
482description of the type and are sometimes circular. The debugger
483recognizes the type anyway, and knows how to read bits as that type.
484
485Each language and compiler defines a slightly different set of basic
486types. In this example we are looking at the basic types for C emited
487by the GNU compiler targeting the Sun4. Here the basic types are
488mostly defined as range types.
489
490
899bafeb 491@node Range types
e505224d
PB
492@section Range types defined by min and max value
493
139741da
RP
494@table @strong
495@item Type Descriptor:
496@code{r}
497@end table
e505224d
PB
498
499When defining a range type, if the number after the first semicolon is
500smaller than the number after the second one, then the two numbers
501represent the smallest and the largest values in the range.
502
503@example
5044 .text
5055 Ltext0:
506
139741da
RP
507.stabs "@var{name}:
508 @var{descriptor} @r{(type)}
509 @var{type-def}=
510 @var{type-desc}
511 @var{type-ref};
512 @var{low-bound};
513 @var{high-bound};
514 ",
515 N_LSYM, NIL, NIL, NIL
e505224d
PB
516
5176 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
5187 .stabs "char:t2=r2;0;127;",128,0,0,0
519@end example
520
139741da
RP
521Here the integer type (@code{1}) is defined as a range of the integer
522type (@code{1}). Likewise @code{char} is a range of @code{char}. This
523part of the definition is circular, but at least the high and low bound
524values of the range hold more information about the type.
e505224d
PB
525
526Here short unsigned int is defined as type number 8 and described as a
139741da 527range of type @code{int}, with a minimum value of 0 and a maximum of 65535.
e505224d
PB
528
529@example
53013 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
531@end example
532
831c2e1d
JG
533@node Float "range" types
534@section Range type defined by size in bytes
e505224d 535
139741da
RP
536@table @strong
537@item Type Descriptor:
538@code{r}
539@end table
e505224d 540
831c2e1d
JG
541In a range definition, if the first number after the semicolon is
542positive and the second is zero, then the type being defined is a
543floating point type, and the number after the first semicolon is the
544number of bytes needed to represent the type. Note that this does not
545provide a way to distinguish 8-byte real floating point types from
5468-byte complex floating point types.
e505224d
PB
547
548@example
139741da
RP
549.stabs "@var{name}:
550 @var{desc}
551 @var{type-def}=
552 @var{type-desc}
553 @var{type-ref};
554 @var{bit-count};
555 0;
556 ",
557 N_LSYM, NIL, NIL, NIL
e505224d
PB
558
55917 .stabs "float:t12=r1;4;0;",128,0,0,0
56018 .stabs "double:t13=r1;8;0;",128,0,0,0
56119 .stabs "long double:t14=r1;8;0;",128,0,0,0
562@end example
563
139741da 564Cosmically enough, the @code{void} type is defined directly in terms of
e505224d
PB
565itself.
566
567@example
139741da
RP
568.stabs "@var{name}:
569 @var{symbol-desc}
570 @var{type-def}=
571 @var{type-ref}
572 ",N_LSYM,NIL,NIL,NIL
e505224d 573
e505224d
PB
57420 .stabs "void:t15=15",128,0,0,0
575@end example
576
577
899bafeb 578@node Example
e505224d
PB
579@chapter A Comprehensive Example in C
580
139741da 581Now we'll examine a second program, @code{example2}, which builds on the
e505224d
PB
582first example to introduce the rest of the stab types, symbol
583descriptors, and type descriptors used in C.
139741da
RP
584@xref{Example2.c} for the complete @file{.c} source,
585and @pxref{Example2.s} for the @file{.s} assembly code.
e505224d
PB
586This description includes parts of those files.
587
588@section Flow of control and nested scopes
589
9cd64d11 590@table @strong
139741da
RP
591@item Directive:
592@code{.stabn}
593@item Types:
594@code{N_SLINE}, @code{N_LBRAC}, @code{N_RBRAC} (cont.)
595@end table
e505224d 596
899bafeb
RP
597Consider the body of @code{main}, from @file{example2.c}. It shows more
598about how @code{N_SLINE}, @code{N_RBRAC}, and @code{N_LBRAC} stabs are used.
e505224d
PB
599
600@example
60120 @{
60221 static float s_flap;
139741da
RP
60322 int times;
60423 for (times=0; times < s_g_repeat; times++)@{
60524 int inner;
60625 printf ("Hello world\n");
60726 @}
e505224d
PB
60827 @};
609@end example
610
899bafeb 611Here we have a single source line, the @samp{for} line, that generates
e505224d 612non-linear flow of control, and non-contiguous code. In this case, an
899bafeb 613@code{N_SLINE} stab with the same line number proceeds each block of
e505224d
PB
614non-contiguous code generated from the same source line.
615
139741da
RP
616The example also shows nested scopes. The @code{N_LBRAC} and
617@code{N_LBRAC} stabs that describe block structure are nested in the
618same order as the corresponding code blocks, those of the for loop
619inside those for the body of main.
e505224d 620
139741da
RP
621@noindent
622This is the label for the @code{N_LBRAC} (left brace) stab marking the
623start of @code{main}.
e505224d 624
139741da 625@example
e505224d 62657 LBB2:
139741da
RP
627@end example
628
629@noindent
630In the first code range for C source line 23, the @code{for} loop
631initialize and test, @code{N_SLINE} (68) records the line number:
e505224d 632
139741da
RP
633@example
634.stabn N_SLINE, NIL,
635 @var{line},
636 @var{address}
e505224d 637
e505224d
PB
63858 .stabn 68,0,23,LM2
63959 LM2:
139741da 64060 st %g0,[%fp-20]
e505224d 64161 L2:
139741da
RP
64262 sethi %hi(_s_g_repeat),%o0
64363 ld [%fp-20],%o1
64464 ld [%o0+%lo(_s_g_repeat)],%o0
64565 cmp %o1,%o0
64666 bge L3
64767 nop
e505224d 648
139741da 649@exdent label for the @code{N_LBRAC} (start block) marking the start of @code{for} loop
e505224d 650
e505224d
PB
65168 LBB3:
65269 .stabn 68,0,25,LM3
65370 LM3:
139741da
RP
65471 sethi %hi(LC0),%o1
65572 or %o1,%lo(LC0),%o0
65673 call _printf,0
65774 nop
e505224d
PB
65875 .stabn 68,0,26,LM4
65976 LM4:
e505224d 660
139741da 661@exdent label for the @code{N_RBRAC} (end block) stab marking the end of the @code{for} loop
e505224d 662
e505224d 66377 LBE3:
139741da 664@end example
e505224d 665
139741da
RP
666@noindent
667Now we come to the second code range for source line 23, the @code{for}
668loop increment and return. Once again, @code{N_SLINE} (68) records the
669source line number:
612dbd4c 670
139741da
RP
671@example
672.stabn, N_SLINE, NIL,
673 @var{line},
674 @var{address}
e505224d 675
e505224d
PB
67678 .stabn 68,0,23,LM5
67779 LM5:
67880 L4:
139741da
RP
67981 ld [%fp-20],%o0
68082 add %o0,1,%o1
68183 st %o1,[%fp-20]
68284 b,a L2
e505224d
PB
68385 L3:
68486 .stabn 68,0,27,LM6
68587 LM6:
e505224d 686
139741da 687@exdent label for the @code{N_RBRAC} (end block) stab marking the end of the @code{for} loop
e505224d 688
e505224d
PB
68988 LBE2:
69089 .stabn 68,0,27,LM7
69190 LM7:
69291 L1:
139741da
RP
69392 ret
69493 restore
e505224d
PB
69594 .stabs "main:F1",36,0,0,_main
69695 .stabs "argc:p1",160,0,0,68
69796 .stabs "argv:p20=*21=*2",160,0,0,72
69897 .stabs "s_flap:V12",40,0,0,_s_flap.0
69998 .stabs "times:1",128,0,0,-20
139741da
RP
700@end example
701
702@noindent
703Here is an illustration of stabs describing nested scopes. The scope
704nesting is reflected in the nested bracketing stabs (@code{N_LBRAC},
705192, appears here).
e505224d 706
139741da
RP
707@example
708.stabn N_LBRAC,NIL,NIL,
709 @var{block-start-address}
e505224d
PB
710
71199 .stabn 192,0,0,LBB2 ## begin proc label
712100 .stabs "inner:1",128,0,0,-24
713101 .stabn 192,0,0,LBB3 ## begin for label
139741da 714@end example
e505224d 715
139741da
RP
716@noindent
717@code{N_RBRAC} (224), ``right brace'' ends a lexical block (scope).
718
719@example
720.stabn N_RBRAC,NIL,NIL,
721 @var{block-end-address}
e505224d
PB
722
723102 .stabn 224,0,0,LBE3 ## end for label
724103 .stabn 224,0,0,LBE2 ## end proc label
725@end example
726
899bafeb 727@node Variables
e505224d
PB
728@chapter Variables
729
730@menu
731* Automatic variables:: locally scoped
8d0dca57 732* Global Variables::
e505224d
PB
733* Register variables::
734* Initialized statics::
735* Un-initialized statics::
736* Parameters::
737@end menu
738
899bafeb 739@node Automatic variables
e505224d
PB
740@section Locally scoped automatic variables
741
139741da
RP
742@table @strong
743@item Directive:
744@code{.stabs}
745@item Type:
746@code{N_LSYM}
747@item Symbol Descriptor:
748none
749@end table
e505224d
PB
750
751
139741da
RP
752In addition to describing types, the @code{N_LSYM} stab type also
753describes locally scoped automatic variables. Refer again to the body
754of @code{main} in @file{example2.c}. It allocates two automatic
755variables: @samp{times} is scoped to the body of @code{main}, and
756@samp{inner} is scoped to the body of the @code{for} loop.
757@samp{s_flap} is locally scoped but not automatic, and will be discussed
758later.
e505224d
PB
759
760@example
76120 @{
76221 static float s_flap;
139741da
RP
76322 int times;
76423 for (times=0; times < s_g_repeat; times++)@{
76524 int inner;
76625 printf ("Hello world\n");
76726 @}
e505224d
PB
76827 @};
769@end example
770
139741da
RP
771The @code{N_LSYM} stab for an automatic variable is located just before the
772@code{N_LBRAC} stab describing the open brace of the block to which it is
e505224d
PB
773scoped.
774
775@example
139741da
RP
776@exdent @code{N_LSYM} (128): automatic variable, scoped locally to @code{main}
777
778.stabs "@var{name}:
779 @var{type-ref}",
780 N_LSYM, NIL, NIL,
781 @var{frame-pointer-offset}
e505224d
PB
782
78398 .stabs "times:1",128,0,0,-20
78499 .stabn 192,0,0,LBB2 ## begin `main' N_LBRAC
785
139741da
RP
786@exdent @code{N_LSYM} (128): automatic variable, scoped locally to the @code{for} loop
787
788.stabs "@var{name}:
789 @var{type-ref}",
790 N_LSYM, NIL, NIL,
791 @var{frame-pointer-offset}
e505224d
PB
792
793100 .stabs "inner:1",128,0,0,-24
794101 .stabn 192,0,0,LBB3 ## begin `for' loop N_LBRAC
795@end example
796
797Since the character in the string field following the colon is not a
798letter, there is no symbol descriptor. This means that the stab
799describes a local variable, and that the number after the colon is a
139741da 800type reference. In this case it a a reference to the basic type @code{int}.
e505224d
PB
801Notice also that the frame pointer offset is negative number for
802automatic variables.
803
804
899bafeb 805@node Global Variables
e505224d
PB
806@section Global Variables
807
139741da
RP
808@table @strong
809@item Directive:
810@code{.stabs}
811@item Type:
812@code{N_GSYM}
813@item Symbol Descriptor:
814@code{G}
815@end table
e505224d 816
139741da
RP
817Global variables are represented by the @code{N_GSYM} stab type. The symbol
818descriptor, following the colon in the string field, is @samp{G}. Following
819the @samp{G} is a type reference or type definition. In this example it is a
820type reference to the basic C type, @code{char}. The first source line in
821@file{example2.c},
e505224d
PB
822
823@example
8241 char g_foo = 'c';
825@end example
826
139741da
RP
827@noindent
828yields the following stab. The stab immediately precedes the code that
e505224d
PB
829allocates storage for the variable it describes.
830
831@example
139741da
RP
832@exdent @code{N_GSYM} (32): global symbol
833
834.stabs "@var{name}:
835 @var{descriptor}
836 @var{type-ref}",
837 N_GSYM, NIL, NIL, NIL
e505224d 838
e505224d 83921 .stabs "g_foo:G2",32,0,0,0
139741da
RP
84022 .global _g_foo
84123 .data
e505224d 84224 _g_foo:
139741da 84325 .byte 99
e505224d
PB
844@end example
845
139741da
RP
846The address of the variable represented by the @code{N_GSYM} is not contained
847in the @code{N_GSYM} stab. The debugger gets this information from the
e505224d
PB
848external symbol for the global variable.
849
899bafeb 850@node Register variables
139741da
RP
851@section Global register variables
852
853@table @strong
854@item Directive:
855@code{.stabs}
856@item Type:
857@code{N_RSYM}
858@item Symbol Descriptor:
859@code{r}
860@end table
e505224d 861
139741da
RP
862The following source line defines a global variable, @code{g_bar}, which is
863explicitly allocated in global register @code{%g5}.
e505224d
PB
864
865@example
8662 register int g_bar asm ("%g5");
867@end example
868
139741da
RP
869Register variables have their own stab type, @code{N_RSYM}, and their own
870symbol descriptor, @code{r}. The stab's value field contains the number of
e505224d
PB
871the register where the variable data will be stored. Since the
872variable was not initialized in this compilation unit, the stab is
873emited at the end of the object file, with the stabs for other
139741da 874uninitialized globals (@code{bcc}).
e505224d
PB
875
876@example
139741da
RP
877@exdent @code{N_RSYM} (64): register variable
878
879.stabs "@var{name}:
880 @var{descriptor}
881 @var{type-ref}",
882 N_RSYM, NIL, NIL,
883 @var{register}
e505224d
PB
884
885133 .stabs "g_bar:r1",64,0,0,5
886@end example
887
888
899bafeb 889@node Initialized statics
e505224d
PB
890@section Initialized static variables
891
139741da
RP
892@table @strong
893@item Directive:
894@code{.stabs}
895@item Type:
896@code{N_STSYM}
897@item Symbol Descriptors:
898@code{S} (file scope), @code{V} (procedure scope)
899@end table
e505224d 900
139741da
RP
901Initialized static variables are represented by the @code{N_STSYM} stab
902type. The symbol descriptor part of the string field shows if the
903variable is file scope static (@samp{S}) or procedure scope static
904(@samp{V}). The source line
e505224d
PB
905
906@example
9073 static int s_g_repeat = 2;
908@end example
909
139741da
RP
910@noindent
911yields the following code. The stab is located immediately preceding
e505224d 912the storage for the variable it represents. Since the variable in
139741da 913this example is file scope static the symbol descriptor is @samp{S}.
e505224d
PB
914
915@example
139741da
RP
916@exdent @code{N_STSYM} (38): initialized static variable (data seg w/internal linkage)
917
918.stabs "@var{name}:
919 @var{descriptor}
920 @var{type-ref}",
921 N_STSYM,NIL,NIL,
922 @var{address}
923
e505224d 92426 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
139741da 92527 .align 4
e505224d 92628 _s_g_repeat:
139741da 92729 .word 2
e505224d
PB
928@end example
929
930
899bafeb 931@node Un-initialized statics
e505224d
PB
932@section Un-initialized static variables
933
139741da
RP
934@table @strong
935@item Directive:
936@code{.stabs}
937@item Type:
938@code{N_LCSYM}
939@item Symbol Descriptors:
940@code{S} (file scope), @code{V} (procedure scope)
941@end table
e505224d 942
139741da
RP
943Un-initialized static variables are represented by the @code{N_LCSYM}
944stab type. The symbol descriptor part of the string shows if the
945variable is file scope static (@samp{S}) or procedure scope static
946(@samp{V}). In this example it is procedure scope static. The source
947line allocating @code{s_flap} immediately follows the open brace for the
948procedure @code{main}.
e505224d
PB
949
950@example
95120 @{
95221 static float s_flap;
953@end example
954
139741da
RP
955The code that reserves storage for the variable @code{s_flap} precedes the
956body of body of @code{main}.
e505224d
PB
957
958@example
139741da 95939 .reserve _s_flap.0,4,"bss",4
e505224d
PB
960@end example
961
139741da
RP
962But since @code{s_flap} is scoped locally to @code{main}, its stab is
963located with the other stabs representing symbols local to @code{main}.
964The stab for @code{s_flap} is located just before the @code{N_LBRAC} for
965@code{main}.
e505224d
PB
966
967@example
139741da
RP
968@exdent @code{N_LCSYM} (40): uninitialized static var (BSS seg w/internal linkage)
969
970.stabs "@var{name}:
971 @var{descriptor}
972 @var{type-ref}",
973 N_LCSYM, NIL, NIL,
974 @var{address}
e505224d 975
e505224d
PB
97697 .stabs "s_flap:V12",40,0,0,_s_flap.0
97798 .stabs "times:1",128,0,0,-20
139741da 97899 .stabn 192,0,0,LBB2 # N_LBRAC for main.
e505224d
PB
979@end example
980
139741da
RP
981@c ............................................................
982
899bafeb 983@node Parameters
e505224d
PB
984@section Parameters
985
497e44a5 986The symbol descriptor @samp{p} is used to refer to parameters which are
b82ea042
JK
987in the arglist. Symbols have symbol type @samp{N_PSYM}. The value of
988the symbol is the offset relative to the argument list.
989
990If the parameter is passed in a register, then the traditional way to do
497e44a5 991this is to provide two symbols for each argument:
e505224d
PB
992
993@example
b82ea042
JK
994.stabs "arg:p1" . . . ; N_PSYM
995.stabs "arg:r1" . . . ; N_RSYM
e505224d
PB
996@end example
997
497e44a5
JK
998Debuggers are expected to use the second one to find the value, and the
999first one to know that it is an argument.
e505224d 1000
b82ea042
JK
1001Because this is kind of ugly, some compilers use symbol descriptor
1002@samp{P} or @samp{R} to indicate an argument which is in a register.
1003The symbol value is the register number. @samp{P} and @samp{R} mean the
1004same thing, the difference is that @samp{P} is a GNU invention and
1005@samp{R} is an IBM (xcoff) invention. As of version 4.9, GDB should
1006handle either one. Symbol type @samp{C_RPSYM} is used with @samp{R} and
1007@samp{N_RSYM} is used with @samp{P}.
1008
a2a2eac8
JK
1009There is at least one case where GCC uses a @samp{p}/@samp{r} pair
1010rather than @samp{P}; this is where the argument is passed in the
1011argument list and then loaded into a register.
1012
b82ea042 1013There is another case similar to an argument in a register, which is an
98ef6f31
JK
1014argument which is actually stored as a local variable. Sometimes this
1015happens when the argument was passed in a register and then the compiler
1016stores it as a local variable. If possible, the compiler should claim
1017that it's in a register, but this isn't always done. Some compilers use
1018the pair of symbols approach described above ("arg:p" followed by
1019"arg:"); this includes gcc1 (not gcc2) on the sparc when passing a small
1020structure and gcc2 when the argument type is float and it is passed as a
1021double and converted to float by the prologue (in the latter case the
1022type of the "arg:p" symbol is double and the type of the "arg:" symbol
1023is float). GCC, at least on the 960, uses a single @samp{p} symbol
1024descriptor for an argument which is stored as a local variable but uses
1025@samp{N_LSYM} instead of @samp{N_PSYM}. In this case the value of the
1026symbol is an offset relative to the local variables for that function,
1027not relative to the arguments (on some machines those are the same
1028thing, but not on all).
e505224d 1029
ed9708e2 1030The following are said to go with @samp{N_PSYM}:
a2a2eac8
JK
1031
1032@example
1033"name" -> "param_name:#type"
1034 # -> p (value parameter)
1035 -> i (value parameter by reference, indirect access)
1036 -> v (variable parameter by reference)
1037 -> C (read-only parameter, conformant array bound)
1038 -> x (conformant array value parameter)
1039 -> pP (<<??>>)
1040 -> pF (<<??>>)
1041 -> X (function result variable)
1042 -> b (based variable)
1043
1044value -> offset from the argument pointer (positive).
1045@end example
1046
497e44a5 1047As a simple example, the code
899bafeb 1048
497e44a5 1049@example
b82ea042
JK
1050main (argc, argv)
1051 int argc;
1052 char **argv;
1053@{
497e44a5
JK
1054@end example
1055
1056produces the stabs
899bafeb 1057
497e44a5 1058@example
b82ea042
JK
1059.stabs "main:F1",36,0,0,_main ; 36 is N_FUN
1060.stabs "argc:p1",160,0,0,68 ; 160 is N_PSYM
1061.stabs "argv:p20=*21=*2",160,0,0,72
e505224d
PB
1062@end example
1063
497e44a5 1064The type definition of argv is interesting because it contains several
a2a2eac8
JK
1065type definitions. Type 21 is pointer to type 2 (char) and argv (type 20) is
1066pointer to type 21.
e505224d 1067
899bafeb 1068@node Aggregate Types
e505224d
PB
1069@chapter Aggregate Types
1070
612dbd4c 1071Now let's look at some variable definitions involving complex types.
e505224d
PB
1072This involves understanding better how types are described. In the
1073examples so far types have been described as references to previously
1074defined types or defined in terms of subranges of or pointers to
1075previously defined types. The section that follows will talk about
1076the various other type descriptors that may follow the = sign in a
1077type definition.
1078
1079@menu
1080* Arrays::
1081* Enumerations::
1082* Structure tags::
1083* Typedefs::
1084* Unions::
1085* Function types::
1086@end menu
1087
899bafeb
RP
1088@node Arrays
1089@section Array types
e505224d 1090
139741da
RP
1091@table @strong
1092@item Directive:
1093@code{.stabs}
1094@item Types:
1095@code{N_GSYM}, @code{N_LSYM}
1096@item Symbol Descriptor:
1097@code{T}
1098@item Type Descriptor:
6aa83a79 1099@code{a}
139741da 1100@end table
e505224d
PB
1101
1102As an example of an array type consider the global variable below.
1103
1104@example
110515 char char_vec[3] = @{'a','b','c'@};
1106@end example
1107
1108Since the array is a global variable, it is described by the N_GSYM
1109stab type. The symbol descriptor G, following the colon in stab's
1110string field, also says the array is a global variable. Following the
1111G is a definition for type (19) as shown by the equals sign after the
1112type number.
1113
6aa83a79
JG
1114After the equals sign is a type descriptor, a, which says that the type
1115being defined is an array. Following the type descriptor for an array
1116is the type of the index, a semicolon, and the type of the array elements.
1117
1118The type of the index is often a range type, expressed as the letter r
1119and some parameters. It defines the size of the array. In in the
1120example below, the range @code{r1;0;2;} defines an index type which is
1121a subrange of type 1 (integer), with a lower bound of 0 and an upper
1122bound of 2. This defines the valid range of subscripts of a
1123three-element C array.
e505224d
PB
1124
1125The array definition above generates the assembly language that
1126follows.
1127
1128@example
899bafeb
RP
1129@exdent <32> N_GSYM - global variable
1130@exdent .stabs "name:sym_desc(global)type_def(19)=type_desc(array)
6aa83a79 1131@exdent index_type_ref(range of int from 0 to 2);element_type_ref(char)";
899bafeb 1132@exdent N_GSYM, NIL, NIL, NIL
e505224d
PB
1133
113432 .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
139741da
RP
113533 .global _char_vec
113634 .align 4
e505224d 113735 _char_vec:
139741da
RP
113836 .byte 97
113937 .byte 98
114038 .byte 99
e505224d
PB
1141@end example
1142
899bafeb 1143@node Enumerations
e505224d
PB
1144@section Enumerations
1145
139741da
RP
1146@table @strong
1147@item Directive:
1148@code{.stabs}
1149@item Type:
1150@code{N_LSYM}
1151@item Symbol Descriptor:
1152@code{T}
1153@item Type Descriptor:
1154@code{e}
1155@end table
e505224d
PB
1156
1157The source line below declares an enumeration type. It is defined at
1158file scope between the bodies of main and s_proc in example2.c.
1159Because the N_LSYM is located after the N_RBRAC that marks the end of
1160the previous procedure's block scope, and before the N_FUN that marks
1161the beginning of the next procedure's block scope, the N_LSYM does not
1162describe a block local symbol, but a file local one. The source line:
1163
1164@example
116529 enum e_places @{first,second=3,last@};
1166@end example
1167
899bafeb 1168@noindent
e505224d
PB
1169generates the following stab, located just after the N_RBRAC (close
1170brace stab) for main. The type definition is in an N_LSYM stab
1171because type definitions are file scope not global scope.
1172
899bafeb 1173@display
e505224d
PB
1174 <128> N_LSYM - local symbol
1175 .stab "name:sym_dec(type)type_def(22)=sym_desc(enum)
1176 enum_name:value(0),enum_name:value(3),enum_name:value(4),;",
139741da 1177 N_LSYM, NIL, NIL, NIL
899bafeb 1178@end display
e505224d 1179
899bafeb 1180@example
e505224d 1181104 .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0
899bafeb 1182@end example
e505224d
PB
1183
1184The symbol descriptor (T) says that the stab describes a structure,
1185enumeration, or type tag. The type descriptor e, following the 22= of
1186the type definition narrows it down to an enumeration type. Following
1187the e is a list of the elements of the enumeration. The format is
1188name:value,. The list of elements ends with a ;.
1189
899bafeb 1190@node Structure tags
e505224d
PB
1191@section Structure Tags
1192
139741da
RP
1193@table @strong
1194@item Directive:
1195@code{.stabs}
1196@item Type:
1197@code{N_LSYM}
1198@item Symbol Descriptor:
1199@code{T}
1200@item Type Descriptor:
1201@code{s}
1202@end table
e505224d
PB
1203
1204The following source code declares a structure tag and defines an
4d7f562d 1205instance of the structure in global scope. Then a typedef equates the
e505224d
PB
1206structure tag with a new type. A seperate stab is generated for the
1207structure tag, the structure typedef, and the structure instance. The
1208stabs for the tag and the typedef are emited when the definitions are
1209encountered. Since the structure elements are not initialized, the
1210stab and code for the structure variable itself is located at the end
1211of the program in .common.
1212
1213@example
12146 struct s_tag @{
12157 int s_int;
12168 float s_float;
12179 char s_char_vec[8];
121810 struct s_tag* s_next;
121911 @} g_an_s;
122012
122113 typedef struct s_tag s_typedef;
1222@end example
1223
1224The structure tag is an N_LSYM stab type because, like the enum, the
1225symbol is file scope. Like the enum, the symbol descriptor is T, for
1226enumeration, struct or tag type. The symbol descriptor s following
1227the 16= of the type definition narrows the symbol type to struct.
1228
1229Following the struct symbol descriptor is the number of bytes the
1230struct occupies, followed by a description of each structure element.
1231The structure element descriptions are of the form name:type, bit
1232offset from the start of the struct, and number of bits in the
1233element.
1234
1235
612dbd4c 1236@example
e505224d
PB
1237 <128> N_LSYM - type definition
1238 .stabs "name:sym_desc(struct tag) Type_def(16)=type_desc(struct type)
139741da 1239 struct_bytes
e505224d 1240 elem_name:type_ref(int),bit_offset,field_bits;
139741da 1241 elem_name:type_ref(float),bit_offset,field_bits;
6aa83a79
JG
1242 elem_name:type_def(17)=type_desc(array)
1243 index_type(range of int from 0 to 7);
1244 element_type(char),bit_offset,field_bits;;",
139741da 1245 N_LSYM,NIL,NIL,NIL
e505224d
PB
1246
124730 .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;
139741da 1248 s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
612dbd4c 1249@end example
e505224d
PB
1250
1251In this example, two of the structure elements are previously defined
1252types. For these, the type following the name: part of the element
1253description is a simple type reference. The other two structure
1254elements are new types. In this case there is a type definition
1255embedded after the name:. The type definition for the array element
1256looks just like a type definition for a standalone array. The s_next
1257field is a pointer to the same kind of structure that the field is an
1258element of. So the definition of structure type 16 contains an type
1259definition for an element which is a pointer to type 16.
1260
899bafeb 1261@node Typedefs
e505224d
PB
1262@section Typedefs
1263
139741da
RP
1264@table @strong
1265@item Directive:
1266@code{.stabs}
1267@item Type:
1268@code{N_LSYM}
1269@item Symbol Descriptor:
1270@code{t}
1271@end table
e505224d
PB
1272
1273Here is the stab for the typedef equating the structure tag with a
1274type.
1275
899bafeb 1276@display
e505224d
PB
1277 <128> N_LSYM - type definition
1278 .stabs "name:sym_desc(type name)type_ref(struct_tag)",N_LSYM,NIL,NIL,NIL
899bafeb 1279@end display
e505224d 1280
899bafeb 1281@example
e505224d 128231 .stabs "s_typedef:t16",128,0,0,0
899bafeb 1283@end example
e505224d
PB
1284
1285And here is the code generated for the structure variable.
1286
899bafeb 1287@display
e505224d
PB
1288 <32> N_GSYM - global symbol
1289 .stabs "name:sym_desc(global)type_ref(struct_tag)",N_GSYM,NIL,NIL,NIL
899bafeb 1290@end display
e505224d
PB
1291
1292@example
1293136 .stabs "g_an_s:G16",32,0,0,0
139741da 1294137 .common _g_an_s,20,"bss"
e505224d
PB
1295@end example
1296
1297Notice that the structure tag has the same type number as the typedef
1298for the structure tag. It is impossible to distinguish between a
1299variable of the struct type and one of its typedef by looking at the
1300debugging information.
1301
1302
899bafeb 1303@node Unions
e505224d
PB
1304@section Unions
1305
139741da
RP
1306@table @strong
1307@item Directive:
1308@code{.stabs}
1309@item Type:
1310@code{N_LSYM}
1311@item Symbol Descriptor:
1312@code{T}
1313@item Type Descriptor:
1314@code{u}
1315@end table
e505224d 1316
612dbd4c 1317Next let's look at unions. In example2 this union type is declared
e505224d
PB
1318locally to a procedure and an instance of the union is defined.
1319
1320@example
132136 union u_tag @{
132237 int u_int;
132338 float u_float;
132439 char* u_char;
132540 @} an_u;
1326@end example
1327
1328This code generates a stab for the union tag and a stab for the union
1329variable. Both use the N_LSYM stab type. Since the union variable is
1330scoped locally to the procedure in which it is defined, its stab is
139741da 1331located immediately preceding the N_LBRAC for the procedure's block
e505224d
PB
1332start.
1333
139741da 1334The stab for the union tag, however is located preceding the code for
e505224d
PB
1335the procedure in which it is defined. The stab type is N_LSYM. This
1336would seem to imply that the union type is file scope, like the struct
1337type s_tag. This is not true. The contents and position of the stab
1338for u_type do not convey any infomation about its procedure local
1339scope.
1340
899bafeb 1341@display
e505224d
PB
1342 <128> N_LSYM - type
1343 .stabs "name:sym_desc(union tag)type_def(22)=type_desc(union)
1344 byte_size(4)
1345 elem_name:type_ref(int),bit_offset(0),bit_size(32);
1346 elem_name:type_ref(float),bit_offset(0),bit_size(32);
1347 elem_name:type_ref(ptr to char),bit_offset(0),bit_size(32);;"
1348 N_LSYM, NIL, NIL, NIL
899bafeb 1349@end display
e505224d 1350
5bc927fb
RP
1351@smallexample
1352105 .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;",
1353 128,0,0,0
1354@end smallexample
e505224d
PB
1355
1356The symbol descriptor, T, following the name: means that the stab
4d7f562d 1357describes an enumeration, struct or type tag. The type descriptor u,
e505224d
PB
1358following the 23= of the type definition, narrows it down to a union
1359type definition. Following the u is the number of bytes in the union.
1360After that is a list of union element descriptions. Their format is
1361name:type, bit offset into the union, and number of bytes for the
1362element;.
1363
1364The stab for the union variable follows. Notice that the frame
1365pointer offset for local variables is negative.
1366
899bafeb 1367@display
e505224d
PB
1368 <128> N_LSYM - local variable (with no symbol descriptor)
1369 .stabs "name:type_ref(u_tag)", N_LSYM, NIL, NIL, frame_ptr_offset
899bafeb 1370@end display
e505224d 1371
899bafeb 1372@example
e505224d 1373130 .stabs "an_u:23",128,0,0,-20
899bafeb 1374@end example
e505224d 1375
899bafeb 1376@node Function types
e505224d
PB
1377@section Function types
1378
899bafeb 1379@display
e505224d 1380type descriptor f
899bafeb 1381@end display
e505224d
PB
1382
1383The last type descriptor in C which remains to be described is used
1384for function types. Consider the following source line defining a
1385global function pointer.
1386
1387@example
13884 int (*g_pf)();
1389@end example
1390
1391It generates the following code. Since the variable is not
1392initialized, the code is located in the common area at the end of the
1393file.
1394
899bafeb 1395@display
e505224d
PB
1396 <32> N_GSYM - global variable
1397 .stabs "name:sym_desc(global)type_def(24)=ptr_to(25)=
139741da 1398 type_def(func)type_ref(int)
899bafeb 1399@end display
e505224d 1400
899bafeb 1401@example
e505224d 1402134 .stabs "g_pf:G24=*25=f1",32,0,0,0
139741da 1403135 .common _g_pf,4,"bss"
899bafeb 1404@end example
e505224d
PB
1405
1406Since the variable is global, the stab type is N_GSYM and the symbol
1407descriptor is G. The variable defines a new type, 24, which is a
1408pointer to another new type, 25, which is defined as a function
1409returning int.
1410
899bafeb 1411@node Symbol tables
e505224d
PB
1412@chapter Symbol information in symbol tables
1413
1414This section examines more closely the format of symbol table entries
1415and how stab assembler directives map to them. It also describes what
1416transformations the assembler and linker make on data from stabs.
1417
1418Each time the assembler encounters a stab in its input file it puts
1419each field of the stab into corresponding fields in a symbol table
1420entry of its output file. If the stab contains a string field, the
1421symbol table entry for that stab points to a string table entry
1422containing the string data from the stab. Assembler labels become
1423relocatable addresses. Symbol table entries in a.out have the format:
1424
1425@example
1426struct internal_nlist @{
139741da
RP
1427 unsigned long n_strx; /* index into string table of name */
1428 unsigned char n_type; /* type of symbol */
1429 unsigned char n_other; /* misc info (usually empty) */
1430 unsigned short n_desc; /* description field */
1431 bfd_vma n_value; /* value of symbol */
e505224d
PB
1432@};
1433@end example
1434
1435For .stabs directives, the n_strx field holds the character offset
1436from the start of the string table to the string table entry
1437containing the "string" field. For other classes of stabs (.stabn and
1438.stabd) this field is null.
1439
1440Symbol table entries with n_type fields containing a value greater or
1441equal to 0x20 originated as stabs generated by the compiler (with one
1442random exception). Those with n_type values less than 0x20 were
1443placed in the symbol table of the executable by the assembler or the
1444linker.
1445
1446The linker concatenates object files and does fixups of externally
1447defined symbols. You can see the transformations made on stab data by
1448the assembler and linker by examining the symbol table after each pass
1449of the build, first the assemble and then the link.
1450
1451To do this use nm with the -ap options. This dumps the symbol table,
1452including debugging information, unsorted. For stab entries the
1453columns are: value, other, desc, type, string. For assembler and
1454linker symbols, the columns are: value, type, string.
1455
1456There are a few important things to notice about symbol tables. Where
1457the value field of a stab contains a frame pointer offset, or a
1458register number, that value is unchanged by the rest of the build.
1459
1460Where the value field of a stab contains an assembly language label,
1461it is transformed by each build step. The assembler turns it into a
1462relocatable address and the linker turns it into an absolute address.
1463This source line defines a static variable at file scope:
1464
899bafeb 1465@example
e505224d 14663 static int s_g_repeat
899bafeb 1467@end example
e505224d 1468
899bafeb 1469@noindent
e505224d
PB
1470The following stab describes the symbol.
1471
899bafeb 1472@example
e505224d 147326 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
899bafeb 1474@end example
e505224d 1475
899bafeb 1476@noindent
e505224d 1477The assembler transforms the stab into this symbol table entry in the
899bafeb 1478@file{.o} file. The location is expressed as a data segment offset.
e505224d 1479
899bafeb 1480@example
e505224d 148121 00000084 - 00 0000 STSYM s_g_repeat:S1
899bafeb 1482@end example
e505224d 1483
899bafeb 1484@noindent
e505224d
PB
1485in the symbol table entry from the executable, the linker has made the
1486relocatable address absolute.
1487
899bafeb 1488@example
e505224d 148922 0000e00c - 00 0000 STSYM s_g_repeat:S1
899bafeb 1490@end example
e505224d
PB
1491
1492Stabs for global variables do not contain location information. In
1493this case the debugger finds location information in the assembler or
1494linker symbol table entry describing the variable. The source line:
1495
899bafeb 1496@example
e505224d 14971 char g_foo = 'c';
899bafeb 1498@end example
e505224d 1499
899bafeb 1500@noindent
e505224d
PB
1501generates the stab:
1502
899bafeb 1503@example
e505224d 150421 .stabs "g_foo:G2",32,0,0,0
899bafeb 1505@end example
e505224d
PB
1506
1507The variable is represented by the following two symbol table entries
1508in the object file. The first one originated as a stab. The second
1509one is an external symbol. The upper case D signifies that the n_type
1510field of the symbol table contains 7, N_DATA with local linkage (see
1511Table B). The value field following the file's line number is empty
1512for the stab entry. For the linker symbol it contains the
1513rellocatable address corresponding to the variable.
1514
899bafeb 1515@example
e505224d
PB
151619 00000000 - 00 0000 GSYM g_foo:G2
151720 00000080 D _g_foo
899bafeb 1518@end example
e505224d 1519
899bafeb 1520@noindent
e505224d
PB
1521These entries as transformed by the linker. The linker symbol table
1522entry now holds an absolute address.
1523
899bafeb 1524@example
e505224d 152521 00000000 - 00 0000 GSYM g_foo:G2
899bafeb 1526@dots{}
e505224d 1527215 0000e008 D _g_foo
899bafeb 1528@end example
e505224d 1529
b32ae57b 1530@node GNU Cplusplus stabs
612dbd4c 1531@chapter GNU C++ stabs
e505224d
PB
1532
1533@menu
b32ae57b 1534* Basic Cplusplus types::
e505224d
PB
1535* Simple classes::
1536* Class instance::
1537* Methods:: Method definition
1538* Protections::
2dd00294
JG
1539* Method Modifiers:: (const, volatile, const volatile)
1540* Virtual Methods::
1541* Inheritence::
1542* Virtual Base Classes::
1543* Static Members::
e505224d
PB
1544@end menu
1545
1546
1547@subsection Symbol descriptors added for C++ descriptions:
1548
899bafeb 1549@display
e505224d 1550P - register parameter.
899bafeb 1551@end display
e505224d
PB
1552
1553@subsection type descriptors added for C++ descriptions
1554
1555@table @code
1556@item #
1557method type (two ## if minimal debug)
1558
1559@item xs
1560cross-reference
1561@end table
1562
2dd00294 1563
b32ae57b 1564@node Basic Cplusplus types
e505224d
PB
1565@section Basic types for C++
1566
1567<< the examples that follow are based on a01.C >>
1568
1569
1570C++ adds two more builtin types to the set defined for C. These are
1571the unknown type and the vtable record type. The unknown type, type
157216, is defined in terms of itself like the void type.
1573
1574The vtable record type, type 17, is defined as a structure type and
1575then as a structure tag. The structure has four fields, delta, index,
1576pfn, and delta2. pfn is the function pointer.
1577
1578<< In boilerplate $vtbl_ptr_type, what are the fields delta,
1579index, and delta2 used for? >>
1580
1581This basic type is present in all C++ programs even if there are no
1582virtual methods defined.
1583
899bafeb 1584@display
e505224d 1585.stabs "struct_name:sym_desc(type)type_def(17)=type_desc(struct)struct_bytes(8)
139741da
RP
1586 elem_name(delta):type_ref(short int),bit_offset(0),field_bits(16);
1587 elem_name(index):type_ref(short int),bit_offset(16),field_bits(16);
1588 elem_name(pfn):type_def(18)=type_desc(ptr to)type_ref(void),
1589 bit_offset(32),field_bits(32);
1590 elem_name(delta2):type_def(short int);bit_offset(32),field_bits(16);;"
1591 N_LSYM, NIL, NIL
899bafeb 1592@end display
139741da 1593
899bafeb 1594@smallexample
e505224d 1595.stabs "$vtbl_ptr_type:t17=s8
139741da
RP
1596 delta:6,0,16;index:6,16,16;pfn:18=*15,32,32;delta2:6,32,16;;"
1597 ,128,0,0,0
899bafeb 1598@end smallexample
e505224d 1599
899bafeb 1600@display
e505224d 1601.stabs "name:sym_dec(struct tag)type_ref($vtbl_ptr_type)",N_LSYM,NIL,NIL,NIL
899bafeb 1602@end display
e505224d 1603
899bafeb 1604@example
e505224d 1605.stabs "$vtbl_ptr_type:T17",128,0,0,0
899bafeb 1606@end example
e505224d 1607
899bafeb 1608@node Simple classes
e505224d
PB
1609@section Simple class definition
1610
1611The stabs describing C++ language features are an extension of the
1612stabs describing C. Stabs representing C++ class types elaborate
1613extensively on the stab format used to describe structure types in C.
1614Stabs representing class type variables look just like stabs
1615representing C language variables.
1616
1617Consider the following very simple class definition.
1618
1619@example
1620class baseA @{
1621public:
139741da
RP
1622 int Adat;
1623 int Ameth(int in, char other);
e505224d
PB
1624@};
1625@end example
1626
1627The class baseA is represented by two stabs. The first stab describes
1628the class as a structure type. The second stab describes a structure
1629tag of the class type. Both stabs are of stab type N_LSYM. Since the
1630stab is not located between an N_FUN and a N_LBRAC stab this indicates
1631that the class is defined at file scope. If it were, then the N_LSYM
1632would signify a local variable.
1633
1634A stab describing a C++ class type is similar in format to a stab
1635describing a C struct, with each class member shown as a field in the
1636structure. The part of the struct format describing fields is
1637expanded to include extra information relevent to C++ class members.
1638In addition, if the class has multiple base classes or virtual
1639functions the struct format outside of the field parts is also
1640augmented.
1641
1642In this simple example the field part of the C++ class stab
1643representing member data looks just like the field part of a C struct
1644stab. The section on protections describes how its format is
1645sometimes extended for member data.
1646
1647The field part of a C++ class stab representing a member function
1648differs substantially from the field part of a C struct stab. It
1649still begins with `name:' but then goes on to define a new type number
1650for the member function, describe its return type, its argument types,
1651its protection level, any qualifiers applied to the method definition,
1652and whether the method is virtual or not. If the method is virtual
1653then the method description goes on to give the vtable index of the
1654method, and the type number of the first base class defining the
1655method.
1656
1657When the field name is a method name it is followed by two colons
1658rather than one. This is followed by a new type definition for the
1659method. This is a number followed by an equal sign and then the
1660symbol descriptor `##', indicating a method type. This is followed by
1661a type reference showing the return type of the method and a
1662semi-colon.
1663
1664The format of an overloaded operator method name differs from that
1665of other methods. It is "op$::XXXX." where XXXX is the operator name
612dbd4c
JG
1666such as + or +=. The name ends with a period, and any characters except
1667the period can occur in the XXXX string.
e505224d
PB
1668
1669The next part of the method description represents the arguments to
1670the method, preceeded by a colon and ending with a semi-colon. The
1671types of the arguments are expressed in the same way argument types
1672are expressed in C++ name mangling. In this example an int and a char
1673map to `ic'.
1674
1675This is followed by a number, a letter, and an asterisk or period,
1676followed by another semicolon. The number indicates the protections
1677that apply to the member function. Here the 2 means public. The
1678letter encodes any qualifier applied to the method definition. In
1679this case A means that it is a normal function definition. The dot
1680shows that the method is not virtual. The sections that follow
1681elaborate further on these fields and describe the additional
1682information present for virtual methods.
1683
1684
899bafeb 1685@display
e505224d 1686.stabs "class_name:sym_desc(type)type_def(20)=type_desc(struct)struct_bytes(4)
139741da 1687 field_name(Adat):type(int),bit_offset(0),field_bits(32);
e505224d 1688
139741da
RP
1689 method_name(Ameth)::type_def(21)=type_desc(method)return_type(int);
1690 :arg_types(int char);
1691 protection(public)qualifier(normal)virtual(no);;"
1692 N_LSYM,NIL,NIL,NIL
899bafeb 1693@end display
e505224d 1694
899bafeb 1695@smallexample
e505224d
PB
1696.stabs "baseA:t20=s4Adat:1,0,32;Ameth::21=##1;:ic;2A.;;",128,0,0,0
1697
1698.stabs "class_name:sym_desc(struct tag)",N_LSYM,NIL,NIL,NIL
1699
1700.stabs "baseA:T20",128,0,0,0
899bafeb 1701@end smallexample
e505224d 1702
899bafeb 1703@node Class instance
e505224d
PB
1704@section Class instance
1705
1706As shown above, describing even a simple C++ class definition is
1707accomplished by massively extending the stab format used in C to
1708describe structure types. However, once the class is defined, C stabs
1709with no modifications can be used to describe class instances. The
1710following source:
1711
1712@example
1713main () @{
139741da 1714 baseA AbaseA;
e505224d
PB
1715@}
1716@end example
1717
899bafeb
RP
1718@noindent
1719yields the following stab describing the class instance. It looks no
e505224d
PB
1720different from a standard C stab describing a local variable.
1721
899bafeb 1722@display
e505224d 1723.stabs "name:type_ref(baseA)", N_LSYM, NIL, NIL, frame_ptr_offset
899bafeb 1724@end display
e505224d 1725
899bafeb 1726@example
e505224d 1727.stabs "AbaseA:20",128,0,0,-20
899bafeb 1728@end example
e505224d 1729
899bafeb 1730@node Methods
e505224d
PB
1731@section Method defintion
1732
1733The class definition shown above declares Ameth. The C++ source below
1734defines Ameth:
1735
1736@example
1737int
1738baseA::Ameth(int in, char other)
1739@{
139741da 1740 return in;
e505224d
PB
1741@};
1742@end example
1743
1744
1745This method definition yields three stabs following the code of the
1746method. One stab describes the method itself and following two
1747describe its parameters. Although there is only one formal argument
1748all methods have an implicit argument which is the `this' pointer.
1749The `this' pointer is a pointer to the object on which the method was
1750called. Note that the method name is mangled to encode the class name
1751and argument types. << Name mangling is not described by this
1752document - Is there already such a doc? >>
1753
612dbd4c 1754@example
e505224d 1755.stabs "name:symbol_desriptor(global function)return_type(int)",
139741da 1756 N_FUN, NIL, NIL, code_addr_of_method_start
e505224d
PB
1757
1758.stabs "Ameth__5baseAic:F1",36,0,0,_Ameth__5baseAic
612dbd4c 1759@end example
e505224d
PB
1760
1761Here is the stab for the `this' pointer implicit argument. The name
c2dc518b 1762of the `this' pointer is always `this.' Type 19, the `this' pointer is
e505224d
PB
1763defined as a pointer to type 20, baseA, but a stab defining baseA has
1764not yet been emited. Since the compiler knows it will be emited
1765shortly, here it just outputs a cross reference to the undefined
1766symbol, by prefixing the symbol name with xs.
1767
612dbd4c 1768@example
e505224d 1769.stabs "name:sym_desc(register param)type_def(19)=
139741da 1770 type_desc(ptr to)type_ref(baseA)=
e505224d
PB
1771 type_desc(cross-reference to)baseA:",N_RSYM,NIL,NIL,register_number
1772
c2dc518b 1773.stabs "this:P19=*20=xsbaseA:",64,0,0,8
612dbd4c 1774@end example
e505224d
PB
1775
1776The stab for the explicit integer argument looks just like a parameter
1777to a C function. The last field of the stab is the offset from the
1778argument pointer, which in most systems is the same as the frame
1779pointer.
1780
612dbd4c 1781@example
e505224d 1782.stabs "name:sym_desc(value parameter)type_ref(int)",
139741da 1783 N_PSYM,NIL,NIL,offset_from_arg_ptr
e505224d
PB
1784
1785.stabs "in:p1",160,0,0,72
612dbd4c 1786@end example
e505224d
PB
1787
1788<< The examples that follow are based on A1.C >>
1789
899bafeb 1790@node Protections
e505224d
PB
1791@section Protections
1792
1793
1794In the simple class definition shown above all member data and
1795functions were publicly accessable. The example that follows
1796contrasts public, protected and privately accessable fields and shows
1797how these protections are encoded in C++ stabs.
1798
1799Protections for class member data are signified by two characters
1800embeded in the stab defining the class type. These characters are
1801located after the name: part of the string. /0 means private, /1
1802means protected, and /2 means public. If these characters are omited
1803this means that the member is public. The following C++ source:
1804
1805@example
1806class all_data @{
139741da
RP
1807private:
1808 int priv_dat;
e505224d 1809protected:
139741da 1810 char prot_dat;
e505224d 1811public:
139741da 1812 float pub_dat;
e505224d
PB
1813@};
1814@end example
1815
899bafeb 1816@noindent
e505224d
PB
1817generates the following stab to describe the class type all_data.
1818
899bafeb 1819@display
e505224d 1820.stabs "class_name:sym_desc(type)type_def(19)=type_desc(struct)struct_bytes
139741da
RP
1821 data_name:/protection(private)type_ref(int),bit_offset,num_bits;
1822 data_name:/protection(protected)type_ref(char),bit_offset,num_bits;
1823 data_name:(/num omited, private)type_ref(float),bit_offset,num_bits;;"
1824 N_LSYM,NIL,NIL,NIL
899bafeb 1825@end display
e505224d 1826
899bafeb 1827@smallexample
e505224d 1828.stabs "all_data:t19=s12
139741da 1829 priv_dat:/01,0,32;prot_dat:/12,32,8;pub_dat:12,64,32;;",128,0,0,0
899bafeb 1830@end smallexample
e505224d
PB
1831
1832Protections for member functions are signified by one digit embeded in
1833the field part of the stab describing the method. The digit is 0 if
1834private, 1 if protected and 2 if public. Consider the C++ class
1835definition below:
1836
1837@example
1838class all_methods @{
1839private:
139741da 1840 int priv_meth(int in)@{return in;@};
e505224d 1841protected:
139741da 1842 char protMeth(char in)@{return in;@};
e505224d 1843public:
139741da 1844 float pubMeth(float in)@{return in;@};
e505224d
PB
1845@};
1846@end example
1847
1848It generates the following stab. The digit in question is to the left
1849of an `A' in each case. Notice also that in this case two symbol
1850descriptors apply to the class name struct tag and struct type.
1851
899bafeb 1852@display
e505224d 1853.stabs "class_name:sym_desc(struct tag&type)type_def(21)=
139741da
RP
1854 sym_desc(struct)struct_bytes(1)
1855 meth_name::type_def(22)=sym_desc(method)returning(int);
1856 :args(int);protection(private)modifier(normal)virtual(no);
1857 meth_name::type_def(23)=sym_desc(method)returning(char);
1858 :args(char);protection(protected)modifier(normal)virual(no);
1859 meth_name::type_def(24)=sym_desc(method)returning(float);
1860 :args(float);protection(public)modifier(normal)virtual(no);;",
1861 N_LSYM,NIL,NIL,NIL
899bafeb 1862@end display
139741da 1863
899bafeb 1864@smallexample
e505224d 1865.stabs "all_methods:Tt21=s1priv_meth::22=##1;:i;0A.;protMeth::23=##2;:c;1A.;
139741da 1866 pubMeth::24=##12;:f;2A.;;",128,0,0,0
899bafeb 1867@end smallexample
e505224d 1868
899bafeb
RP
1869@node Method Modifiers
1870@section Method Modifiers (const, volatile, const volatile)
e505224d
PB
1871
1872<< based on a6.C >>
1873
1874In the class example described above all the methods have the normal
1875modifier. This method modifier information is located just after the
1876protection information for the method. This field has four possible
1877character values. Normal methods use A, const methods use B, volatile
1878methods use C, and const volatile methods use D. Consider the class
1879definition below:
1880
1881@example
1882class A @{
1883public:
139741da
RP
1884 int ConstMeth (int arg) const @{ return arg; @};
1885 char VolatileMeth (char arg) volatile @{ return arg; @};
1886 float ConstVolMeth (float arg) const volatile @{return arg; @};
e505224d
PB
1887@};
1888@end example
1889
1890This class is described by the following stab:
1891
899bafeb 1892@display
e505224d 1893.stabs "class(A):sym_desc(struct)type_def(20)=type_desc(struct)struct_bytes(1)
139741da
RP
1894 meth_name(ConstMeth)::type_def(21)sym_desc(method)
1895 returning(int);:arg(int);protection(public)modifier(const)virtual(no);
1896 meth_name(VolatileMeth)::type_def(22)=sym_desc(method)
1897 returning(char);:arg(char);protection(public)modifier(volatile)virt(no)
1898 meth_name(ConstVolMeth)::type_def(23)=sym_desc(method)
1899 returning(float);:arg(float);protection(public)modifer(const volatile)
1900 virtual(no);;", @dots{}
899bafeb 1901@end display
139741da 1902
899bafeb 1903@example
e505224d 1904.stabs "A:T20=s1ConstMeth::21=##1;:i;2B.;VolatileMeth::22=##2;:c;2C.;
139741da 1905 ConstVolMeth::23=##12;:f;2D.;;",128,0,0,0
612dbd4c 1906@end example
e505224d 1907
899bafeb 1908@node Virtual Methods
e505224d
PB
1909@section Virtual Methods
1910
1911<< The following examples are based on a4.C >>
1912
1913The presence of virtual methods in a class definition adds additional
1914data to the class description. The extra data is appended to the
1915description of the virtual method and to the end of the class
1916description. Consider the class definition below:
1917
1918@example
1919class A @{
1920public:
139741da
RP
1921 int Adat;
1922 virtual int A_virt (int arg) @{ return arg; @};
e505224d
PB
1923@};
1924@end example
1925
1926This results in the stab below describing class A. It defines a new
1927type (20) which is an 8 byte structure. The first field of the class
1928struct is Adat, an integer, starting at structure offset 0 and
1929occupying 32 bits.
1930
1931The second field in the class struct is not explicitly defined by the
1932C++ class definition but is implied by the fact that the class
1933contains a virtual method. This field is the vtable pointer. The
1934name of the vtable pointer field starts with $vf and continues with a
1935type reference to the class it is part of. In this example the type
1936reference for class A is 20 so the name of its vtable pointer field is
1937$vf20, followed by the usual colon.
1938
1939Next there is a type definition for the vtable pointer type (21).
1940This is in turn defined as a pointer to another new type (22).
1941
1942Type 22 is the vtable itself, which is defined as an array, indexed by
6aa83a79
JG
1943a range of integers between 0 and 1, and whose elements are of type
194417. Type 17 was the vtable record type defined by the boilerplate C++
1945type definitions, as shown earlier.
e505224d
PB
1946
1947The bit offset of the vtable pointer field is 32. The number of bits
1948in the field are not specified when the field is a vtable pointer.
1949
1950Next is the method definition for the virtual member function A_virt.
1951Its description starts out using the same format as the non-virtual
1952member functions described above, except instead of a dot after the
1953`A' there is an asterisk, indicating that the function is virtual.
1954Since is is virtual some addition information is appended to the end
1955of the method description.
1956
1957The first number represents the vtable index of the method. This is a
195832 bit unsigned number with the high bit set, followed by a
1959semi-colon.
1960
1961The second number is a type reference to the first base class in the
1962inheritence hierarchy defining the virtual member function. In this
1963case the class stab describes a base class so the virtual function is
1964not overriding any other definition of the method. Therefore the
1965reference is to the type number of the class that the stab is
1966describing (20).
1967
1968This is followed by three semi-colons. One marks the end of the
1969current sub-section, one marks the end of the method field, and the
1970third marks the end of the struct definition.
1971
1972For classes containing virtual functions the very last section of the
1973string part of the stab holds a type reference to the first base
1974class. This is preceeded by `~%' and followed by a final semi-colon.
1975
899bafeb 1976@display
e505224d 1977.stabs "class_name(A):type_def(20)=sym_desc(struct)struct_bytes(8)
139741da
RP
1978 field_name(Adat):type_ref(int),bit_offset(0),field_bits(32);
1979 field_name(A virt func ptr):type_def(21)=type_desc(ptr to)type_def(22)=
6aa83a79
JG
1980 sym_desc(array)index_type_ref(range of int from 0 to 1);
1981 elem_type_ref(vtbl elem type),
139741da
RP
1982 bit_offset(32);
1983 meth_name(A_virt)::typedef(23)=sym_desc(method)returning(int);
1984 :arg_type(int),protection(public)normal(yes)virtual(yes)
1985 vtable_index(1);class_first_defining(A);;;~%first_base(A);",
1986 N_LSYM,NIL,NIL,NIL
899bafeb 1987@end display
e505224d 1988
899bafeb 1989@example
e505224d 1990.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 1991@end example
e505224d 1992
2dd00294
JG
1993@node Inheritence
1994@section Inheritence
e505224d
PB
1995
1996Stabs describing C++ derived classes include additional sections that
1997describe the inheritence hierarchy of the class. A derived class stab
1998also encodes the number of base classes. For each base class it tells
1999if the base class is virtual or not, and if the inheritence is private
2000or public. It also gives the offset into the object of the portion of
2001the object corresponding to each base class.
2002
2003This additional information is embeded in the class stab following the
2004number of bytes in the struct. First the number of base classes
2005appears bracketed by an exclamation point and a comma.
2006
2007Then for each base type there repeats a series: two digits, a number,
2008a comma, another number, and a semi-colon.
2009
2010The first of the two digits is 1 if the base class is virtual and 0 if
2011not. The second digit is 2 if the derivation is public and 0 if not.
2012
2013The number following the first two digits is the offset from the start
2014of the object to the part of the object pertaining to the base class.
2015
2016After the comma, the second number is a type_descriptor for the base
2017type. Finally a semi-colon ends the series, which repeats for each
2018base class.
2019
2020The source below defines three base classes A, B, and C and the
2021derived class D.
2022
2023
2024@example
2025class A @{
2026public:
139741da
RP
2027 int Adat;
2028 virtual int A_virt (int arg) @{ return arg; @};
e505224d
PB
2029@};
2030
2031class B @{
2032public:
139741da
RP
2033 int B_dat;
2034 virtual int B_virt (int arg) @{return arg; @};
e505224d
PB
2035@};
2036
2037class C @{
2038public:
139741da
RP
2039 int Cdat;
2040 virtual int C_virt (int arg) @{return arg; @};
e505224d
PB
2041@};
2042
2043class D : A, virtual B, public C @{
2044public:
139741da
RP
2045 int Ddat;
2046 virtual int A_virt (int arg ) @{ return arg+1; @};
2047 virtual int B_virt (int arg) @{ return arg+2; @};
2048 virtual int C_virt (int arg) @{ return arg+3; @};
2049 virtual int D_virt (int arg) @{ return arg; @};
e505224d
PB
2050@};
2051@end example
2052
2053Class stabs similar to the ones described earlier are generated for
2054each base class.
2055
5bc927fb
RP
2056@c FIXME!!! the linebreaks in the following example probably make the
2057@c examples literally unusable, but I don't know any other way to get
2058@c them on the page.
899bafeb 2059@smallexample
5bc927fb
RP
2060.stabs "A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
2061 A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
e505224d 2062
5bc927fb
RP
2063.stabs "B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1;
2064 :i;2A*-2147483647;25;;;~%25;",128,0,0,0
e505224d 2065
5bc927fb
RP
2066.stabs "C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1;
2067 :i;2A*-2147483647;28;;;~%28;",128,0,0,0
899bafeb 2068@end smallexample
e505224d
PB
2069
2070In the stab describing derived class D below, the information about
2071the derivation of this class is encoded as follows.
2072
899bafeb 2073@display
e505224d 2074.stabs "derived_class_name:symbol_descriptors(struct tag&type)=
139741da
RP
2075 type_descriptor(struct)struct_bytes(32)!num_bases(3),
2076 base_virtual(no)inheritence_public(no)base_offset(0),
2077 base_class_type_ref(A);
2078 base_virtual(yes)inheritence_public(no)base_offset(NIL),
2079 base_class_type_ref(B);
2080 base_virtual(no)inheritence_public(yes)base_offset(64),
2081 base_class_type_ref(C); @dots{}
899bafeb 2082@end display
139741da 2083
5bc927fb 2084@c FIXME! fake linebreaks.
899bafeb 2085@smallexample
5bc927fb
RP
2086.stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:
2087 1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt:
2088 :32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;
2089 28;;D_virt::32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
899bafeb 2090@end smallexample
e505224d 2091
2dd00294 2092@node Virtual Base Classes
e505224d
PB
2093@section Virtual Base Classes
2094
2095A derived class object consists of a concatination in memory of the
2096data areas defined by each base class, starting with the leftmost and
2097ending with the rightmost in the list of base classes. The exception
2098to this rule is for virtual inheritence. In the example above, class
2099D inherits virtually from base class B. This means that an instance
2100of a D object will not contain it's own B part but merely a pointer to
2101a B part, known as a virtual base pointer.
2102
2103In a derived class stab, the base offset part of the derivation
2104information, described above, shows how the base class parts are
2105ordered. The base offset for a virtual base class is always given as
21060. Notice that the base offset for B is given as 0 even though B is
2107not the first base class. The first base class A starts at offset 0.
2108
2109The field information part of the stab for class D describes the field
2110which is the pointer to the virtual base class B. The vbase pointer
2111name is $vb followed by a type reference to the virtual base class.
2112Since the type id for B in this example is 25, the vbase pointer name
2113is $vb25.
2114
5bc927fb 2115@c FIXME!! fake linebreaks below
899bafeb 2116@smallexample
5bc927fb
RP
2117.stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,
2118 160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;
2119 2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt:
2120 :32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
899bafeb 2121@end smallexample
e505224d
PB
2122
2123Following the name and a semicolon is a type reference describing the
2124type of the virtual base class pointer, in this case 24. Type 24 was
c2dc518b 2125defined earlier as the type of the B class `this` pointer. The
e505224d
PB
2126`this' pointer for a class is a pointer to the class type.
2127
899bafeb 2128@example
c2dc518b 2129.stabs "this:P24=*25=xsB:",64,0,0,8
899bafeb 2130@end example
e505224d
PB
2131
2132Finally the field offset part of the vbase pointer field description
2133shows that the vbase pointer is the first field in the D object,
2134before any data fields defined by the class. The layout of a D class
2135object is a follows, Adat at 0, the vtable pointer for A at 32, Cdat
2136at 64, the vtable pointer for C at 96, the virtual ase pointer for B
2137at 128, and Ddat at 160.
2138
2139
899bafeb 2140@node Static Members
e505224d
PB
2141@section Static Members
2142
446e5d80
JG
2143The data area for a class is a concatenation of the space used by the
2144data members of the class. If the class has virtual methods, a vtable
e505224d 2145pointer follows the class data. The field offset part of each field
446e5d80 2146description in the class stab shows this ordering.
e505224d 2147
446e5d80 2148<< How is this reflected in stabs? See Cygnus bug #677 for some info. >>
e505224d 2149
899bafeb 2150@node Example2.c
e505224d
PB
2151@appendix Example2.c - source code for extended example
2152
2153@example
21541 char g_foo = 'c';
21552 register int g_bar asm ("%g5");
21563 static int s_g_repeat = 2;
21574 int (*g_pf)();
21585
21596 struct s_tag @{
21607 int s_int;
21618 float s_float;
21629 char s_char_vec[8];
216310 struct s_tag* s_next;
216411 @} g_an_s;
216512
216613 typedef struct s_tag s_typedef;
216714
216815 char char_vec[3] = @{'a','b','c'@};
216916
217017 main (argc, argv)
217118 int argc;
217219 char* argv[];
217320 @{
217421 static float s_flap;
139741da
RP
217522 int times;
217623 for (times=0; times < s_g_repeat; times++)@{
217724 int inner;
217825 printf ("Hello world\n");
217926 @}
e505224d
PB
218027 @};
218128
218229 enum e_places @{first,second=3,last@};
218330
218431 static s_proc (s_arg, s_ptr_arg, char_vec)
218532 s_typedef s_arg;
218633 s_typedef* s_ptr_arg;
218734 char* char_vec;
218835 @{
218936 union u_tag @{
219037 int u_int;
219138 float u_float;
219239 char* u_char;
219340 @} an_u;
219441 @}
219542
219643
2197@end example
2198
899bafeb 2199@node Example2.s
e505224d
PB
2200@appendix Example2.s - assembly code for extended example
2201
2202@example
22031 gcc2_compiled.:
22042 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
22053 .stabs "example2.c",100,0,0,Ltext0
139741da 22064 .text
e505224d
PB
22075 Ltext0:
22086 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
22097 .stabs "char:t2=r2;0;127;",128,0,0,0
22108 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
22119 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
221210 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
221311 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0
221412 .stabs "long long int:t7=r1;0;-1;",128,0,0,0
221513 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
221614 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
221715 .stabs "signed char:t10=r1;-128;127;",128,0,0,0
221816 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0
221917 .stabs "float:t12=r1;4;0;",128,0,0,0
222018 .stabs "double:t13=r1;8;0;",128,0,0,0
222119 .stabs "long double:t14=r1;8;0;",128,0,0,0
222220 .stabs "void:t15=15",128,0,0,0
222321 .stabs "g_foo:G2",32,0,0,0
139741da
RP
222422 .global _g_foo
222523 .data
e505224d 222624 _g_foo:
139741da 222725 .byte 99
e505224d 222826 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
139741da 222927 .align 4
e505224d 223028 _s_g_repeat:
139741da 223129 .word 2
5bc927fb
RP
2232@c FIXME! fake linebreak in line 30
223330 .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;s_char_vec:
2234 17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
e505224d
PB
223531 .stabs "s_typedef:t16",128,0,0,0
223632 .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
139741da
RP
223733 .global _char_vec
223834 .align 4
e505224d 223935 _char_vec:
139741da
RP
224036 .byte 97
224137 .byte 98
224238 .byte 99
224339 .reserve _s_flap.0,4,"bss",4
224440 .text
224541 .align 4
e505224d 224642 LC0:
139741da
RP
224743 .ascii "Hello world\12\0"
224844 .align 4
224945 .global _main
225046 .proc 1
e505224d
PB
225147 _main:
225248 .stabn 68,0,20,LM1
225349 LM1:
139741da
RP
225450 !#PROLOGUE# 0
225551 save %sp,-144,%sp
225652 !#PROLOGUE# 1
225753 st %i0,[%fp+68]
225854 st %i1,[%fp+72]
225955 call ___main,0
226056 nop
e505224d
PB
226157 LBB2:
226258 .stabn 68,0,23,LM2
226359 LM2:
139741da 226460 st %g0,[%fp-20]
e505224d 226561 L2:
139741da
RP
226662 sethi %hi(_s_g_repeat),%o0
226763 ld [%fp-20],%o1
226864 ld [%o0+%lo(_s_g_repeat)],%o0
226965 cmp %o1,%o0
227066 bge L3
227167 nop
e505224d
PB
227268 LBB3:
227369 .stabn 68,0,25,LM3
227470 LM3:
139741da
RP
227571 sethi %hi(LC0),%o1
227672 or %o1,%lo(LC0),%o0
227773 call _printf,0
227874 nop
e505224d
PB
227975 .stabn 68,0,26,LM4
228076 LM4:
228177 LBE3:
228278 .stabn 68,0,23,LM5
228379 LM5:
228480 L4:
139741da
RP
228581 ld [%fp-20],%o0
228682 add %o0,1,%o1
228783 st %o1,[%fp-20]
228884 b,a L2
e505224d
PB
228985 L3:
229086 .stabn 68,0,27,LM6
229187 LM6:
229288 LBE2:
229389 .stabn 68,0,27,LM7
229490 LM7:
229591 L1:
139741da
RP
229692 ret
229793 restore
e505224d
PB
229894 .stabs "main:F1",36,0,0,_main
229995 .stabs "argc:p1",160,0,0,68
230096 .stabs "argv:p20=*21=*2",160,0,0,72
230197 .stabs "s_flap:V12",40,0,0,_s_flap.0
230298 .stabs "times:1",128,0,0,-20
230399 .stabn 192,0,0,LBB2
2304100 .stabs "inner:1",128,0,0,-24
2305101 .stabn 192,0,0,LBB3
2306102 .stabn 224,0,0,LBE3
2307103 .stabn 224,0,0,LBE2
2308104 .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0
5bc927fb
RP
2309@c FIXME: fake linebreak in line 105
2310105 .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;",
2311128,0,0,0
139741da
RP
2312106 .align 4
2313107 .proc 1
e505224d
PB
2314108 _s_proc:
2315109 .stabn 68,0,35,LM8
2316110 LM8:
139741da
RP
2317111 !#PROLOGUE# 0
2318112 save %sp,-120,%sp
2319113 !#PROLOGUE# 1
2320114 mov %i0,%o0
2321115 st %i1,[%fp+72]
2322116 st %i2,[%fp+76]
e505224d
PB
2323117 LBB4:
2324118 .stabn 68,0,41,LM9
2325119 LM9:
2326120 LBE4:
2327121 .stabn 68,0,41,LM10
2328122 LM10:
2329123 L5:
139741da
RP
2330124 ret
2331125 restore
e505224d
PB
2332126 .stabs "s_proc:f1",36,0,0,_s_proc
2333127 .stabs "s_arg:p16",160,0,0,0
2334128 .stabs "s_ptr_arg:p18",160,0,0,72
2335129 .stabs "char_vec:p21",160,0,0,76
2336130 .stabs "an_u:23",128,0,0,-20
2337131 .stabn 192,0,0,LBB4
2338132 .stabn 224,0,0,LBE4
2339133 .stabs "g_bar:r1",64,0,0,5
2340134 .stabs "g_pf:G24=*25=f1",32,0,0,0
139741da 2341135 .common _g_pf,4,"bss"
e505224d 2342136 .stabs "g_an_s:G16",32,0,0,0
139741da 2343137 .common _g_an_s,20,"bss"
e505224d
PB
2344@end example
2345
2346
899bafeb 2347@node Quick reference
e505224d
PB
2348@appendix Quick reference
2349
2350@menu
2351* Stab types:: Table A: Symbol types from stabs
2352* Assembler types:: Table B: Symbol types from assembler and linker
2353* Symbol descriptors:: Table C
2354* Type Descriptors:: Table D
2355@end menu
2356
899bafeb 2357@node Stab types
e505224d
PB
2358@section Table A: Symbol types from stabs
2359
2360Table A lists stab types sorted by type number. Stab type numbers are
236132 and greater. This is the full list of stab numbers, including stab
2362types that are used in languages other than C.
2363
2364The #define names for these stab types are defined in:
2365devo/include/aout/stab.def
2366
899bafeb 2367@smallexample
e505224d
PB
2368type type #define used to describe
2369dec hex name source program feature
5bc927fb 2370------------------------------------------------
139741da
RP
237132 0x20 N_GYSM global symbol
237234 0X22 N_FNAME function name (for BSD Fortran)
237336 0x24 N_FUN function name or text segment variable for C
237438 0x26 N_STSYM static symbol (data segment w/internal linkage)
237540 0x28 N_LCSYM .lcomm symbol(BSS-seg variable w/internal linkage)
237642 0x2a N_MAIN Name of main routine (not used in C)
237748 0x30 N_PC global symbol (for Pascal)
237850 0x32 N_NSYMS number of symbols (according to Ultrix V4.0)
237952 0x34 N_NOMAP no DST map for sym (according to Ultrix V4.0)
238064 0x40 N_RSYM register variable
238166 0x42 N_M2C Modula-2 compilation unit
238268 0x44 N_SLINE line number in text segment
238370 0x46 N_DSLINE line number in data segment
2384
238572 0x48 N_BSLINE line number in bss segment
238672 0x48 N_BROWS Sun source code browser, path to .cb file
2387
238874 0x4a N_DEFD GNU Modula2 definition module dependency
2389
239080 0x50 N_EHDECL GNU C++ exception variable
239180 0x50 N_MOD2 Modula2 info "for imc" (according to Ultrix V4.0)
2392
239384 0x54 N_CATCH GNU C++ "catch" clause
239496 0x60 N_SSYM structure of union element
2395100 0x64 N_SO path and name of source file
2396128 0x80 N_LSYM automatic var in the stack
2397 (also used for type desc.)
2398130 0x82 N_BINCL beginning of an include file (Sun only)
2399132 0x84 N_SOL Name of sub-source (#include) file.
2400160 0xa0 N_PSYM parameter variable
2401162 0xa2 N_EINCL end of an include file
2402164 0xa4 N_ENTRY alternate entry point
2403192 0xc0 N_LBRAC beginning of a lexical block
2404194 0xc2 N_EXCL place holder for a deleted include file
2405196 0xc4 N_SCOPE modula2 scope information (Sun linker)
2406224 0xe0 N_RBRAC end of a lexical block
2407226 0xe2 N_BCOMM begin named common block
2408228 0xe4 N_ECOMM end named common block
2409232 0xe8 N_ECOML end common (local name)
e505224d
PB
2410
2411 << used on Gould systems for non-base registers syms >>
139741da
RP
2412240 0xf0 N_NBTEXT ??
2413242 0xf2 N_NBDATA ??
2414244 0xf4 N_NBBSS ??
2415246 0xf6 N_NBSTS ??
2416248 0xf8 N_NBLCS ??
899bafeb 2417@end smallexample
e505224d 2418
899bafeb 2419@node Assembler types
e505224d
PB
2420@section Table B: Symbol types from assembler and linker
2421
2422Table B shows the types of symbol table entries that hold assembler
2423and linker symbols.
2424
2425The #define names for these n_types values are defined in
2426/include/aout/aout64.h
2427
899bafeb 2428@smallexample
139741da
RP
2429dec hex #define
2430n_type n_type name used to describe
5bc927fb 2431------------------------------------------
139741da
RP
24321 0x0 N_UNDF undefined symbol
24332 0x2 N_ABS absolute symbol -- defined at a particular address
24343 0x3 extern " (vs. file scope)
24354 0x4 N_TEXT text symbol -- defined at offset in text segment
24365 0x5 extern " (vs. file scope)
24376 0x6 N_DATA data symbol -- defined at offset in data segment
24387 0x7 extern " (vs. file scope)
24398 0x8 N_BSS BSS symbol -- defined at offset in zero'd segment
24409 extern " (vs. file scope)
2441
244212 0x0C N_FN_SEQ func name for Sequent compilers (stab exception)
2443
244449 0x12 N_COMM common sym -- visable after shared lib dynamic link
244531 0x1f N_FN file name of a .o file
899bafeb 2446@end smallexample
e505224d 2447
899bafeb 2448@node Symbol descriptors
e505224d
PB
2449@section Table C: Symbol descriptors
2450
ed9708e2 2451@c Please keep this alphabetical
497e44a5
JK
2452@table @code
2453@item (empty)
2454Local variable, @xref{Automatic variables}.
2455
ed9708e2
JK
2456@item C
2457@xref{Parameters}.
2458
497e44a5
JK
2459@item f
2460Local function, @xref{Procedures}.
2461
2462@item F
2463Global function, @xref{Procedures}.
2464
497e44a5
JK
2465@item G
2466Global variable, @xref{Global Variables}.
2467
ed9708e2
JK
2468@item i
2469@xref{Parameters}.
2470
2471@item p
2472Argument list parameter @xref{Parameters}.
2473
2474@item pP
2475@xref{Parameters}.
2476
2477@item pF
2478@xref{Parameters}.
2479
2480@item P
2481@itemx R
2482Register parameter @xref{Parameters}.
2483
497e44a5
JK
2484@item r
2485Register variable, @xref{Register variables}.
2486
2487@item S
2488Static file scope variable @xref{Initialized statics},
1b5c6c05 2489@xref{Un-initialized statics}.
497e44a5 2490
ed9708e2
JK
2491@item t
2492Type name, @xref{Typedefs}.
2493
2494@item T
2495enumeration, struct or union tag, @xref{Unions}.
2496
2497@item v
2498Call by reference, @xref{Parameters}.
2499
497e44a5
JK
2500@item V
2501Static procedure scope variable @xref{Initialized statics},
1b5c6c05 2502@xref{Un-initialized statics}.
497e44a5 2503
ed9708e2
JK
2504@item X
2505Function return variable, @xref{Parameters}.
497e44a5 2506@end table
e505224d 2507
899bafeb 2508@node Type Descriptors
e505224d
PB
2509@section Table D: Type Descriptors
2510
2511@example
139741da 2512descriptor meaning
e505224d 2513-------------------------------------
139741da
RP
2514(empty) type reference
2515 a array type
2516 e enumeration type
2517 f function type
2518 r range type
2519 s structure type
2520 u union specifications
2521 * pointer type
e505224d
PB
2522@end example
2523
2524
899bafeb 2525@node Expanded reference
e505224d
PB
2526@appendix Expanded reference by stab type.
2527
2528Format of an entry:
2529
2530The first line is the symbol type expressed in decimal, hexadecimal,
2531and as a #define (see devo/include/aout/stab.def).
2532
2533The second line describes the language constructs the symbol type
2534represents.
2535
2536The third line is the stab format with the significant stab fields
2537named and the rest NIL.
2538
2539Subsequent lines expand upon the meaning and possible values for each
2540significant stab field. # stands in for the type descriptor.
2541
2542Finally, any further information.
2543
899bafeb
RP
2544@menu
2545* N_GSYM:: Global variable
2546* N_FNAME:: Function name (BSD Fortran)
2547* N_FUN:: C Function name or text segment variable
2548* N_STSYM:: Initialized static symbol
2549* N_LCSYM:: Uninitialized static symbol
2550* N_MAIN:: Name of main routine (not for C)
2551* N_PC:: Pascal global symbol
2552* N_NSYMS:: Number of symbols
2553* N_NOMAP:: No DST map
2554* N_RSYM:: Register variable
2555* N_M2C:: Modula-2 compilation unit
2556* N_SLINE:: Line number in text segment
2557* N_DSLINE:: Line number in data segment
2558* N_BSLINE:: Line number in bss segment
2559* N_BROWS:: Path to .cb file for Sun source code browser
2560* N_DEFD:: GNU Modula2 definition module dependency
2561* N_EHDECL:: GNU C++ exception variable
2562* N_MOD2:: Modula2 information "for imc"
2563* N_CATCH:: GNU C++ "catch" clause
2564* N_SSYM:: Structure or union element
2565* N_SO:: Source file containing main
2566* N_LSYM:: Automatic variable
2567* N_BINCL:: Beginning of include file (Sun only)
2568* N_SOL:: Name of include file
2569* N_PSYM:: Parameter variable
2570* N_EINCL:: End of include file
2571* N_ENTRY:: Alternate entry point
2572* N_LBRAC:: Beginning of lexical block
2573* N_EXCL:: Deleted include file
2574* N_SCOPE:: Modula2 scope information (Sun only)
2575* N_RBRAC:: End of lexical block
2576* N_BCOMM:: Begin named common block
2577* N_ECOMM:: End named common block
2578* N_ECOML:: End common
2579* Gould:: non-base register symbols used on Gould systems
2580* N_LENG:: Length of preceding entry
2581@end menu
2582
2583@node N_GSYM
139741da 2584@section 32 - 0x20 - N_GYSM
899bafeb
RP
2585
2586@display
e505224d
PB
2587Global variable.
2588
2589.stabs "name", N_GSYM, NIL, NIL, NIL
899bafeb 2590@end display
e505224d 2591
899bafeb 2592@example
e505224d 2593"name" -> "symbol_name:#type"
139741da 2594 # -> G
899bafeb 2595@end example
e505224d 2596
4d7f562d 2597Only the "name" field is significant. The location of the variable is
e505224d
PB
2598obtained from the corresponding external symbol.
2599
899bafeb
RP
2600@node N_FNAME
2601@section 34 - 0x22 - N_FNAME
e505224d
PB
2602Function name (for BSD Fortran)
2603
899bafeb 2604@display
e505224d 2605.stabs "name", N_FNAME, NIL, NIL, NIL
899bafeb 2606@end display
e505224d 2607
899bafeb 2608@example
e505224d 2609"name" -> "function_name"
899bafeb 2610@end example
e505224d
PB
2611
2612Only the "name" field is significant. The location of the symbol is
2613obtained from the corresponding extern symbol.
2614
899bafeb 2615@node N_FUN
139741da 2616@section 36 - 0x24 - N_FUN
e505224d
PB
2617Function name or text segment variable for C.
2618
899bafeb 2619@display
e505224d 2620.stabs "name", N_FUN, NIL, desc, value
899bafeb 2621@end display
e505224d 2622
899bafeb
RP
2623@example
2624@exdent @emph{For functions:}
e505224d 2625"name" -> "proc_name:#return_type"
139741da
RP
2626 # -> F (global function)
2627 f (local function)
e505224d
PB
2628desc -> line num for proc start. (GCC doesn't set and DBX doesn't miss it.)
2629value -> Code address of proc start.
2630
899bafeb 2631@exdent @emph{For text segment variables:}
e505224d 2632<<How to create one?>>
899bafeb 2633@end example
e505224d 2634
899bafeb
RP
2635@node N_STSYM
2636@section 38 - 0x26 - N_STSYM
e505224d
PB
2637Initialized static symbol (data segment w/internal linkage).
2638
899bafeb 2639@display
e505224d 2640.stabs "name", N_STSYM, NIL, NIL, value
899bafeb 2641@end display
e505224d 2642
899bafeb 2643@example
e505224d 2644"name" -> "symbol_name#type"
139741da
RP
2645 # -> S (scope global to compilation unit)
2646 -> V (scope local to a procedure)
e505224d 2647value -> Data Address
899bafeb 2648@end example
e505224d 2649
899bafeb
RP
2650@node N_LCSYM
2651@section 40 - 0x28 - N_LCSYM
e505224d
PB
2652Unitialized static (.lcomm) symbol(BSS segment w/internal linkage).
2653
899bafeb 2654@display
e505224d 2655.stabs "name", N_LCLSYM, NIL, NIL, value
899bafeb 2656@end display
e505224d 2657
899bafeb 2658@example
e505224d 2659"name" -> "symbol_name#type"
139741da
RP
2660 # -> S (scope global to compilation unit)
2661 -> V (scope local to procedure)
e505224d 2662value -> BSS Address
899bafeb 2663@end example
e505224d 2664
899bafeb 2665@node N_MAIN
139741da 2666@section 42 - 0x2a - N_MAIN
e505224d
PB
2667Name of main routine (not used in C)
2668
899bafeb 2669@display
e505224d 2670.stabs "name", N_MAIN, NIL, NIL, NIL
899bafeb 2671@end display
e505224d 2672
899bafeb 2673@example
e505224d 2674"name" -> "name_of_main_routine"
899bafeb 2675@end example
e505224d 2676
899bafeb 2677@node N_PC
139741da 2678@section 48 - 0x30 - N_PC
e505224d
PB
2679Global symbol (for Pascal)
2680
899bafeb 2681@display
e505224d 2682.stabs "name", N_PC, NIL, NIL, value
899bafeb 2683@end display
e505224d 2684
899bafeb 2685@example
e505224d
PB
2686"name" -> "symbol_name" <<?>>
2687value -> supposedly the line number (stab.def is skeptical)
899bafeb 2688@end example
e505224d 2689
899bafeb 2690@display
e505224d
PB
2691stabdump.c says:
2692
2693global pascal symbol: name,,0,subtype,line
2694<< subtype? >>
899bafeb 2695@end display
e505224d 2696
899bafeb 2697@node N_NSYMS
139741da 2698@section 50 - 0x32 - N_NSYMS
e505224d
PB
2699Number of symbols (according to Ultrix V4.0)
2700
899bafeb 2701@display
139741da 2702 0, files,,funcs,lines (stab.def)
899bafeb 2703@end display
e505224d 2704
899bafeb
RP
2705@node N_NOMAP
2706@section 52 - 0x34 - N_NOMAP
e505224d
PB
2707no DST map for sym (according to Ultrix V4.0)
2708
899bafeb 2709@display
139741da 2710 name, ,0,type,ignored (stab.def)
899bafeb
RP
2711@end display
2712
2713@node N_RSYM
139741da 2714@section 64 - 0x40 - N_RSYM
e505224d
PB
2715 register variable
2716
899bafeb 2717@display
e505224d 2718.stabs "name:type",N_RSYM,0,RegSize,RegNumber (Sun doc)
899bafeb 2719@end display
e505224d 2720
899bafeb 2721@node N_M2C
139741da 2722@section 66 - 0x42 - N_M2C
e505224d
PB
2723Modula-2 compilation unit
2724
899bafeb 2725@display
e505224d 2726.stabs "name", N_M2C, 0, desc, value
899bafeb 2727@end display
e505224d 2728
899bafeb 2729@example
e505224d
PB
2730"name" -> "unit_name,unit_time_stamp[,code_time_stamp]
2731desc -> unit_number
2732value -> 0 (main unit)
139741da 2733 1 (any other unit)
899bafeb 2734@end example
e505224d 2735
899bafeb 2736@node N_SLINE
139741da 2737@section 68 - 0x44 - N_SLINE
e505224d
PB
2738Line number in text segment
2739
899bafeb 2740@display
e505224d 2741.stabn N_SLINE, 0, desc, value
899bafeb 2742@end display
e505224d 2743
899bafeb 2744@example
e505224d
PB
2745desc -> line_number
2746value -> code_address (relocatable addr where the corresponding code starts)
899bafeb 2747@end example
e505224d
PB
2748
2749For single source lines that generate discontiguous code, such as flow
2750of control statements, there may be more than one N_SLINE stab for the
2751same source line. In this case there is a stab at the start of each
2752code range, each with the same line number.
2753
899bafeb
RP
2754@node N_DSLINE
2755@section 70 - 0x46 - N_DSLINE
e505224d
PB
2756Line number in data segment
2757
899bafeb 2758@display
e505224d 2759.stabn N_DSLINE, 0, desc, value
899bafeb 2760@end display
e505224d 2761
899bafeb 2762@example
e505224d 2763desc -> line_number
899bafeb
RP
2764value -> data_address (relocatable addr where the corresponding code
2765starts)
2766@end example
e505224d
PB
2767
2768See comment for N_SLINE above.
2769
899bafeb
RP
2770@node N_BSLINE
2771@section 72 - 0x48 - N_BSLINE
e505224d
PB
2772Line number in bss segment
2773
899bafeb 2774@display
e505224d 2775.stabn N_BSLINE, 0, desc, value
899bafeb 2776@end display
e505224d 2777
899bafeb 2778@example
e505224d 2779desc -> line_number
899bafeb
RP
2780value -> bss_address (relocatable addr where the corresponding code
2781starts)
2782@end example
e505224d
PB
2783
2784See comment for N_SLINE above.
2785
899bafeb 2786@node N_BROWS
139741da 2787@section 72 - 0x48 - N_BROWS
e505224d
PB
2788Sun source code browser, path to .cb file
2789
2790<<?>>
2791"path to associated .cb file"
2792
2793Note: type field value overlaps with N_BSLINE
2794
899bafeb 2795@node N_DEFD
139741da 2796@section 74 - 0x4a - N_DEFD
612dbd4c 2797GNU Modula2 definition module dependency
e505224d
PB
2798
2799GNU Modula-2 definition module dependency. Value is the modification
2800time of the definition file. Other is non-zero if it is imported with
2801the GNU M2 keyword %INITIALIZE. Perhaps N_M2C can be used if there
2802are enough empty fields?
2803
899bafeb
RP
2804@node N_EHDECL
2805@section 80 - 0x50 - N_EHDECL
612dbd4c 2806GNU C++ exception variable <<?>>
e505224d
PB
2807
2808"name is variable name"
2809
2810Note: conflicts with N_MOD2.
2811
899bafeb
RP
2812@node N_MOD2
2813@section 80 - 0x50 - N_MOD2
2814Modula2 info "for imc" (according to Ultrix V4.0)
e505224d
PB
2815
2816Note: conflicts with N_EHDECL <<?>>
2817
899bafeb
RP
2818@node N_CATCH
2819@section 84 - 0x54 - N_CATCH
2820GNU C++ "catch" clause
e505224d
PB
2821
2822GNU C++ `catch' clause. Value is its address. Desc is nonzero if
2823this entry is immediately followed by a CAUGHT stab saying what
2824exception was caught. Multiple CAUGHT stabs means that multiple
2825exceptions can be caught here. If Desc is 0, it means all exceptions
2826are caught here.
2827
899bafeb 2828@node N_SSYM
139741da 2829@section 96 - 0x60 - N_SSYM
e505224d
PB
2830Structure or union element
2831
899bafeb
RP
2832Value is offset in the structure.
2833
2834<<?looking at structs and unions in C I didn't see these>>
e505224d 2835
899bafeb 2836@node N_SO
139741da 2837@section 100 - 0x64 - N_SO
e505224d
PB
2838Path and name of source file containing main routine
2839
899bafeb 2840@display
e505224d 2841.stabs "name", N_SO, NIL, NIL, value
899bafeb 2842@end display
e505224d 2843
899bafeb 2844@example
c0264596
JK
2845"name" -> /source/directory/
2846 -> source_file
e505224d
PB
2847
2848value -> the starting text address of the compilation.
899bafeb 2849@end example
e505224d 2850
c0264596
JK
2851These are found two in a row. The name field of the first N_SO contains
2852the directory that the source file is relative to. The name field of
2853the second N_SO contains the name of the source file itself.
2854
2855Only some compilers (e.g. gcc2, Sun cc) include the directory; this
2856symbol can be distinguished by the fact that it ends in a slash.
2857According to a comment in GDB's partial-stab.h, other compilers
2858(especially unnamed C++ compilers) put out useless N_SO's for
2859nonexistent source files (after the N_SO for the real source file).
e505224d 2860
899bafeb 2861@node N_LSYM
139741da 2862@section 128 - 0x80 - N_LSYM
e505224d
PB
2863Automatic var in the stack (also used for type descriptors.)
2864
899bafeb 2865@display
e505224d 2866.stabs "name" N_LSYM, NIL, NIL, value
899bafeb 2867@end display
e505224d 2868
899bafeb
RP
2869@example
2870@exdent @emph{For stack based local variables:}
e505224d
PB
2871
2872"name" -> name of the variable
2873value -> offset from frame pointer (negative)
2874
899bafeb 2875@exdent @emph{For type descriptors:}
e505224d
PB
2876
2877"name" -> "name_of_the_type:#type"
139741da 2878 # -> t
e505224d 2879
139741da 2880type -> type_ref (or) type_def
e505224d
PB
2881
2882type_ref -> type_number
2883type_def -> type_number=type_desc etc.
899bafeb 2884@end example
e505224d
PB
2885
2886Type may be either a type reference or a type definition. A type
2887reference is a number that refers to a previously defined type. A
2888type definition is the number that will refer to this type, followed
2889by an equals sign, a type descriptor and the additional data that
2890defines the type. See the Table D for type descriptors and the
2891section on types for what data follows each type descriptor.
2892
899bafeb 2893@node N_BINCL
139741da 2894@section 130 - 0x82 - N_BINCL
e505224d
PB
2895
2896Beginning of an include file (Sun only)
2897
2898Beginning of an include file. Only Sun uses this. In an object file,
2899only the name is significant. The Sun linker puts data into some of
2900the other fields.
2901
899bafeb
RP
2902@node N_SOL
2903@section 132 - 0x84 - N_SOL
e505224d
PB
2904
2905Name of a sub-source file (#include file). Value is starting address
2906of the compilation.
2907<<?>>
2908
899bafeb 2909@node N_PSYM
139741da 2910@section 160 - 0xa0 - N_PSYM
e505224d 2911
a2a2eac8 2912Parameter variable. @xref{Parameters}.
e505224d 2913
899bafeb
RP
2914@node N_EINCL
2915@section 162 - 0xa2 - N_EINCL
e505224d
PB
2916
2917End of an include file. This and N_BINCL act as brackets around the
2918file's output. In an ojbect file, there is no significant data in
899bafeb 2919this entry. The Sun linker puts data into some of the fields.
e505224d
PB
2920<<?>>
2921
899bafeb
RP
2922@node N_ENTRY
2923@section 164 - 0xa4 - N_ENTRY
e505224d
PB
2924
2925Alternate entry point.
2926Value is its address.
2927<<?>>
2928
899bafeb
RP
2929@node N_LBRAC
2930@section 192 - 0xc0 - N_LBRAC
e505224d
PB
2931
2932Beginning of a lexical block (left brace). The variable defined
2933inside the block precede the N_LBRAC symbol. Or can they follow as
2934well as long as a new N_FUNC was not encountered. <<?>>
2935
899bafeb 2936@display
e505224d 2937.stabn N_LBRAC, NIL, NIL, value
899bafeb 2938@end display
e505224d 2939
899bafeb 2940@example
e505224d 2941value -> code address of block start.
899bafeb 2942@end example
e505224d 2943
899bafeb
RP
2944@node N_EXCL
2945@section 194 - 0xc2 - N_EXCL
e505224d
PB
2946
2947Place holder for a deleted include file. Replaces a N_BINCL and
2948everything up to the corresponding N_EINCL. The Sun linker generates
2949these when it finds multiple indentical copies of the symbols from an
2950included file. This appears only in output from the Sun linker.
2951<<?>>
2952
899bafeb
RP
2953@node N_SCOPE
2954@section 196 - 0xc4 - N_SCOPE
e505224d
PB
2955
2956Modula2 scope information (Sun linker)
2957<<?>>
2958
899bafeb 2959@node N_RBRAC
139741da 2960@section 224 - 0xe0 - N_RBRAC
e505224d
PB
2961
2962End of a lexical block (right brace)
2963
899bafeb 2964@display
e505224d 2965.stabn N_RBRAC, NIL, NIL, value
899bafeb 2966@end display
e505224d 2967
899bafeb 2968@example
e505224d 2969value -> code address of the end of the block.
899bafeb 2970@end example
e505224d 2971
899bafeb 2972@node N_BCOMM
139741da 2973@section 226 - 0xe2 - N_BCOMM
e505224d
PB
2974
2975Begin named common block.
2976
2977Only the name is significant.
2978<<?>>
2979
899bafeb 2980@node N_ECOMM
139741da 2981@section 228 - 0xe4 - N_ECOMM
e505224d
PB
2982
2983End named common block.
2984
2985Only the name is significant and it should match the N_BCOMM
2986<<?>>
2987
899bafeb
RP
2988@node N_ECOML
2989@section 232 - 0xe8 - N_ECOML
e505224d
PB
2990
2991End common (local name)
2992
2993value is address.
2994<<?>>
2995
899bafeb
RP
2996@node Gould
2997@section Non-base registers on Gould systems
e505224d
PB
2998<< used on Gould systems for non-base registers syms, values assigned
2999at random, need real info from Gould. >>
3000<<?>>
3001
899bafeb 3002@example
139741da
RP
3003240 0xf0 N_NBTEXT ??
3004242 0xf2 N_NBDATA ??
3005244 0xf4 N_NBBSS ??
3006246 0xf6 N_NBSTS ??
3007248 0xf8 N_NBLCS ??
899bafeb 3008@end example
e505224d 3009
899bafeb
RP
3010@node N_LENG
3011@section - 0xfe - N_LENG
e505224d
PB
3012
3013Second symbol entry containing a length-value for the preceding entry.
3014The value is the length.
3015
899bafeb
RP
3016@node Questions
3017@appendix Questions and anomalies
e505224d
PB
3018
3019@itemize @bullet
3020@item
3021For GNU C stabs defining local and global variables (N_LSYM and
3022N_GSYM), the desc field is supposed to contain the source line number
3023on which the variable is defined. In reality the desc field is always
30240. (This behavour is defined in dbxout.c and putting a line number in
3025desc is controlled by #ifdef WINNING_GDB which defaults to false). Gdb
3026supposedly uses this information if you say 'list var'. In reality
3027var can be a variable defined in the program and gdb says `function
3028var not defined'
3029
3030@item
612dbd4c 3031In GNU C stabs there seems to be no way to differentiate tag types:
e505224d
PB
3032structures, unions, and enums (symbol descriptor T) and typedefs
3033(symbol descriptor t) defined at file scope from types defined locally
3034to a procedure or other more local scope. They all use the N_LSYM
3035stab type. Types defined at procedure scope are emited after the
139741da 3036N_RBRAC of the preceding function and before the code of the
e505224d
PB
3037procedure in which they are defined. This is exactly the same as
3038types defined in the source file between the two procedure bodies.
4d7f562d 3039GDB overcompensates by placing all types in block #1, the block for
e505224d 3040symbols of file scope. This is true for default, -ansi and
4d7f562d 3041-traditional compiler options. (Bugs gcc/1063, gdb/1066.)
e505224d
PB
3042
3043@item
3044What ends the procedure scope? Is it the proc block's N_RBRAC or the
3045next N_FUN? (I believe its the first.)
3046
3047@item
3048The comment in xcoff.h says DBX_STATIC_CONST_VAR_CODE is used for
3049static const variables. DBX_STATIC_CONST_VAR_CODE is set to N_FUN by
3050default, in dbxout.c. If included, xcoff.h redefines it to N_STSYM.
3051But testing the default behaviour, my Sun4 native example shows
3052N_STSYM not N_FUN is used to describe file static initialized
3053variables. (the code tests for TREE_READONLY(decl) &&
3054!TREE_THIS_VOLATILE(decl) and if true uses DBX_STATIC_CONST_VAR_CODE).
3055
3056@item
3057Global variable stabs don't have location information. This comes
3058from the external symbol for the same variable. The external symbol
3059has a leading underbar on the _name of the variable and the stab does
3060not. How do we know these two symbol table entries are talking about
3061the same symbol when their names are different?
3062
3063@item
3064Can gcc be configured to output stabs the way the Sun compiler
3065does, so that their native debugging tools work? <NO?> It doesn't by
3066default. GDB reads either format of stab. (gcc or SunC). How about
3067dbx?
3068@end itemize
3069
899bafeb 3070@node xcoff-differences
e505224d
PB
3071@appendix Differences between GNU stabs in a.out and GNU stabs in xcoff
3072
497e44a5
JK
3073@c FIXME: Merge *all* these into the main body of the document.
3074(The AIX/RS6000 native object file format is xcoff with stabs). This
3075appendix only covers those differences which are not covered in the main
3076body of this document.
e505224d
PB
3077
3078@itemize @bullet
3079@item
3080Instead of .stabs, xcoff uses .stabx.
3081
3082@item
3083The data fields of an xcoff .stabx are in a different order than an
3084a.out .stabs. The order is: string, value, type. The desc and null
3085fields present in a.out stabs are missing in xcoff stabs. For N_GSYM
3086the value field is the name of the symbol.
3087
3088@item
5bc927fb 3089BSD a.out stab types correspond to AIX xcoff storage classes. In general the
e505224d
PB
3090mapping is N_STABTYPE becomes C_STABTYPE. Some stab types in a.out
3091are not supported in xcoff. See Table E. for full mappings.
3092
3093exception:
3094initialised static N_STSYM and un-initialized static N_LCSYM both map
3095to the C_STSYM storage class. But the destinction is preserved
3096because in xcoff N_STSYM and N_LCSYM must be emited in a named static
3097block. Begin the block with .bs s[RW] data_section_name for N_STSYM
3098or .bs s bss_section_name for N_LCSYM. End the block with .es
3099
3100@item
3101xcoff stabs describing tags and typedefs use the N_DECL (0x8c)instead
3102of N_LSYM stab type.
3103
3104@item
3105xcoff uses N_RPSYM (0x8e) instead of the N_RSYM stab type for register
3106variables. If the register variable is also a value parameter, then
3107use R instead of P for the symbol descriptor.
3108
31096.
3110xcoff uses negative numbers as type references to the basic types.
3111There are no boilerplate type definitions emited for these basic
3112types. << make table of basic types and type numbers for C >>
3113
3114@item
3115xcoff .stabx sometimes don't have the name part of the string field.
3116
3117@item
3118xcoff uses a .file stab type to represent the source file name. There
3119is no stab for the path to the source file.
3120
3121@item
3122xcoff uses a .line stab type to represent source lines. The format
3123is: .line line_number.
3124
3125@item
3126xcoff emits line numbers relative to the start of the current
3127function. The start of a function is marked by .bf. If a function
3128includes lines from a seperate file, then those line numbers are
3129absolute line numbers in the <<sub-?>> file being compiled.
3130
3131@item
3132The start of current include file is marked with: .bi "filename" and
3133the end marked with .ei "filename"
3134
3135@item
3136If the xcoff stab is a N_FUN (C_FUN) then follow the string field with
3137,. instead of just ,
e505224d
PB
3138@end itemize
3139
3140
3141(I think that's it for .s file differences. They could stand to be
3142better presented. This is just a list of what I have noticed so far.
3143There are a *lot* of differences in the information in the symbol
3144tables of the executable and object files.)
3145
3146Table E: mapping a.out stab types to xcoff storage classes
3147
3148@example
139741da 3149stab type storage class
e505224d 3150-------------------------------
139741da
RP
3151N_GSYM C_GSYM
3152N_FNAME unknown
3153N_FUN C_FUN
3154N_STSYM C_STSYM
3155N_LCSYM C_STSYM
3156N_MAIN unkown
3157N_PC unknown
3158N_RSYM C_RSYM
3159N_RPSYM (0x8e) C_RPSYM
3160N_M2C unknown
3161N_SLINE unknown
3162N_DSLINE unknown
3163N_BSLINE unknown
3164N_BROWSE unchanged
3165N_CATCH unknown
3166N_SSYM unknown
3167N_SO unknown
3168N_LSYM C_LSYM
3169N_DECL (0x8c) C_DECL
3170N_BINCL unknown
3171N_SOL unknown
3172N_PSYM C_PSYM
3173N_EINCL unknown
3174N_ENTRY C_ENTRY
3175N_LBRAC unknown
3176N_EXCL unknown
3177N_SCOPE unknown
3178N_RBRAC unknown
3179N_BCOMM C_BCOMM
3180N_ECOMM C_ECOMM
3181N_ECOML C_ECOML
3182
3183N_LENG unknown
e505224d
PB
3184@end example
3185
899bafeb 3186@node Sun-differences
e505224d
PB
3187@appendix Differences between GNU stabs and Sun native stabs.
3188
497e44a5
JK
3189@c FIXME: Merge all this stuff into the main body of the document.
3190
e505224d
PB
3191@itemize @bullet
3192@item
612dbd4c 3193GNU C stabs define *all* types, file or procedure scope, as
e505224d
PB
3194N_LSYM. Sun doc talks about using N_GSYM too.
3195
e505224d
PB
3196@item
3197Stabs describing block scopes, N_LBRAC and N_RBRAC are supposed to
3198contain the nesting level of the block in the desc field, re Sun doc.
497e44a5 3199GNU stabs always have 0 in that field. dbx seems not to care.
e505224d
PB
3200
3201@item
3202Sun C stabs use type number pairs in the format (a,b) where a is a
3203number starting with 1 and incremented for each sub-source file in the
3204compilation. b is a number starting with 1 and incremented for each
612dbd4c 3205new type defined in the compilation. GNU C stabs use the type number
e505224d
PB
3206alone, with no source file number.
3207@end itemize
3208
3209@contents
3210@bye
This page took 0.194135 seconds and 4 git commands to generate.