1 This is Info file stabs.info, produced by Makeinfo version 1.68 from
2 the input file ./stabs.texinfo.
5 * Stabs: (stabs). The "stabs" debugging information format.
8 This document describes the stabs debugging symbol tables.
10 Copyright 1992, 93, 94, 95, 97, 1998 Free Software Foundation, Inc.
11 Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
14 Permission is granted to make and distribute verbatim copies of this
15 manual provided the copyright notice and this permission notice are
16 preserved on all copies.
18 Permission is granted to copy or distribute modified versions of this
19 manual under the terms of the GPL (for which purpose this text may be
20 regarded as a program in the language TeX).
23 File: stabs.info, Node: Class Instance, Next: Methods, Prev: Simple Classes, Up: Cplusplus
28 As shown above, describing even a simple C++ class definition is
29 accomplished by massively extending the stab format used in C to
30 describe structure types. However, once the class is defined, C stabs
31 with no modifications can be used to describe class instances. The
38 yields the following stab describing the class instance. It looks no
39 different from a standard C stab describing a local variable.
41 .stabs "name:type_ref(baseA)", N_LSYM, NIL, NIL, frame_ptr_offset
43 .stabs "AbaseA:20",128,0,0,-20
46 File: stabs.info, Node: Methods, Next: Method Type Descriptor, Prev: Class Instance, Up: Cplusplus
51 The class definition shown above declares Ameth. The C++ source
55 baseA::Ameth(int in, char other)
60 This method definition yields three stabs following the code of the
61 method. One stab describes the method itself and following two describe
62 its parameters. Although there is only one formal argument all methods
63 have an implicit argument which is the `this' pointer. The `this'
64 pointer is a pointer to the object on which the method was called. Note
65 that the method name is mangled to encode the class name and argument
66 types. Name mangling is described in the ARM (`The Annotated C++
67 Reference Manual', by Ellis and Stroustrup, ISBN 0-201-51459-1);
68 `gpcompare.texi' in Cygnus GCC distributions describes the differences
69 between GNU mangling and ARM mangling.
71 .stabs "name:symbol_desriptor(global function)return_type(int)",
72 N_FUN, NIL, NIL, code_addr_of_method_start
74 .stabs "Ameth__5baseAic:F1",36,0,0,_Ameth__5baseAic
76 Here is the stab for the `this' pointer implicit argument. The name
77 of the `this' pointer is always `this'. Type 19, the `this' pointer is
78 defined as a pointer to type 20, `baseA', but a stab defining `baseA'
79 has not yet been emited. Since the compiler knows it will be emited
80 shortly, here it just outputs a cross reference to the undefined
81 symbol, by prefixing the symbol name with `xs'.
83 .stabs "name:sym_desc(register param)type_def(19)=
84 type_desc(ptr to)type_ref(baseA)=
85 type_desc(cross-reference to)baseA:",N_RSYM,NIL,NIL,register_number
87 .stabs "this:P19=*20=xsbaseA:",64,0,0,8
89 The stab for the explicit integer argument looks just like a
90 parameter to a C function. The last field of the stab is the offset
91 from the argument pointer, which in most systems is the same as the
94 .stabs "name:sym_desc(value parameter)type_ref(int)",
95 N_PSYM,NIL,NIL,offset_from_arg_ptr
97 .stabs "in:p1",160,0,0,72
99 << The examples that follow are based on A1.C >>
102 File: stabs.info, Node: Method Type Descriptor, Next: Member Type Descriptor, Prev: Methods, Up: Cplusplus
104 The `#' Type Descriptor
105 =======================
107 This is used to describe a class method. This is a function which
108 takes an extra argument as its first argument, for the `this' pointer.
110 If the `#' is immediately followed by another `#', the second one
111 will be followed by the return type and a semicolon. The class and
112 argument types are not specified, and must be determined by demangling
113 the name of the method if it is available.
115 Otherwise, the single `#' is followed by the class type, a comma,
116 the return type, a comma, and zero or more parameter types separated by
117 commas. The list of arguments is terminated by a semicolon. In the
118 debugging output generated by gcc, a final argument type of `void'
119 indicates a method which does not take a variable number of arguments.
120 If the final argument type of `void' does not appear, the method was
121 declared with an ellipsis.
123 Note that although such a type will normally be used to describe
124 fields in structures, unions, or classes, for at least some versions of
125 the compiler it can also be used in other contexts.
128 File: stabs.info, Node: Member Type Descriptor, Next: Protections, Prev: Method Type Descriptor, Up: Cplusplus
130 The `@' Type Descriptor
131 =======================
133 The `@' type descriptor is for a member (class and variable) type.
134 It is followed by type information for the offset basetype, a comma, and
135 type information for the type of the field being pointed to. (FIXME:
136 this is acknowledged to be gibberish. Can anyone say what really goes
139 Note that there is a conflict between this and type attributes
140 (*note String Field::.); both use type descriptor `@'. Fortunately,
141 the `@' type descriptor used in this C++ sense always will be followed
142 by a digit, `(', or `-', and type attributes never start with those
146 File: stabs.info, Node: Protections, Next: Method Modifiers, Prev: Member Type Descriptor, Up: Cplusplus
151 In the simple class definition shown above all member data and
152 functions were publicly accessable. The example that follows contrasts
153 public, protected and privately accessable fields and shows how these
154 protections are encoded in C++ stabs.
156 If the character following the `FIELD-NAME:' part of the string is
157 `/', then the next character is the visibility. `0' means private, `1'
158 means protected, and `2' means public. Debuggers should ignore
159 visibility characters they do not recognize, and assume a reasonable
160 default (such as public) (GDB 4.11 does not, but this should be fixed
161 in the next GDB release). If no visibility is specified the field is
162 public. The visibility `9' means that the field has been optimized out
163 and is public (there is no way to specify an optimized out field with a
164 private or protected visibility). Visibility `9' is not supported by
165 GDB 4.11; this should be fixed in the next GDB release.
167 The following C++ source:
178 generates the following stab:
181 .stabs "vis:T19=s12priv:/01,0,32;prot:/12,32,8;pub:12,64,32;;",128,0,0,0
183 `vis:T19=s12' indicates that type number 19 is a 12 byte structure
184 named `vis' The `priv' field has public visibility (`/0'), type int
185 (`1'), and offset and size `,0,32;'. The `prot' field has protected
186 visibility (`/1'), type char (`2') and offset and size `,32,8;'. The
187 `pub' field has type float (`12'), and offset and size `,64,32;'.
189 Protections for member functions are signified by one digit embeded
190 in the field part of the stab describing the method. The digit is 0 if
191 private, 1 if protected and 2 if public. Consider the C++ class
196 int priv_meth(int in){return in;};
198 char protMeth(char in){return in;};
200 float pubMeth(float in){return in;};
203 It generates the following stab. The digit in question is to the
204 left of an `A' in each case. Notice also that in this case two symbol
205 descriptors apply to the class name struct tag and struct type.
207 .stabs "class_name:sym_desc(struct tag&type)type_def(21)=
208 sym_desc(struct)struct_bytes(1)
209 meth_name::type_def(22)=sym_desc(method)returning(int);
210 :args(int);protection(private)modifier(normal)virtual(no);
211 meth_name::type_def(23)=sym_desc(method)returning(char);
212 :args(char);protection(protected)modifier(normal)virual(no);
213 meth_name::type_def(24)=sym_desc(method)returning(float);
214 :args(float);protection(public)modifier(normal)virtual(no);;",
217 .stabs "all_methods:Tt21=s1priv_meth::22=##1;:i;0A.;protMeth::23=##2;:c;1A.;
218 pubMeth::24=##12;:f;2A.;;",128,0,0,0
221 File: stabs.info, Node: Method Modifiers, Next: Virtual Methods, Prev: Protections, Up: Cplusplus
223 Method Modifiers (`const', `volatile', `const volatile')
224 ========================================================
228 In the class example described above all the methods have the normal
229 modifier. This method modifier information is located just after the
230 protection information for the method. This field has four possible
231 character values. Normal methods use `A', const methods use `B',
232 volatile methods use `C', and const volatile methods use `D'. Consider
233 the class definition below:
237 int ConstMeth (int arg) const { return arg; };
238 char VolatileMeth (char arg) volatile { return arg; };
239 float ConstVolMeth (float arg) const volatile {return arg; };
242 This class is described by the following stab:
244 .stabs "class(A):sym_desc(struct)type_def(20)=type_desc(struct)struct_bytes(1)
245 meth_name(ConstMeth)::type_def(21)sym_desc(method)
246 returning(int);:arg(int);protection(public)modifier(const)virtual(no);
247 meth_name(VolatileMeth)::type_def(22)=sym_desc(method)
248 returning(char);:arg(char);protection(public)modifier(volatile)virt(no)
249 meth_name(ConstVolMeth)::type_def(23)=sym_desc(method)
250 returning(float);:arg(float);protection(public)modifer(const volatile)
253 .stabs "A:T20=s1ConstMeth::21=##1;:i;2B.;VolatileMeth::22=##2;:c;2C.;
254 ConstVolMeth::23=##12;:f;2D.;;",128,0,0,0
257 File: stabs.info, Node: Virtual Methods, Next: Inheritence, Prev: Method Modifiers, Up: Cplusplus
262 << The following examples are based on a4.C >>
264 The presence of virtual methods in a class definition adds additional
265 data to the class description. The extra data is appended to the
266 description of the virtual method and to the end of the class
267 description. Consider the class definition below:
272 virtual int A_virt (int arg) { return arg; };
275 This results in the stab below describing class A. It defines a new
276 type (20) which is an 8 byte structure. The first field of the class
277 struct is `Adat', an integer, starting at structure offset 0 and
280 The second field in the class struct is not explicitly defined by the
281 C++ class definition but is implied by the fact that the class contains
282 a virtual method. This field is the vtable pointer. The name of the
283 vtable pointer field starts with `$vf' and continues with a type
284 reference to the class it is part of. In this example the type
285 reference for class A is 20 so the name of its vtable pointer field is
286 `$vf20', followed by the usual colon.
288 Next there is a type definition for the vtable pointer type (21).
289 This is in turn defined as a pointer to another new type (22).
291 Type 22 is the vtable itself, which is defined as an array, indexed
292 by a range of integers between 0 and 1, and whose elements are of type
293 17. Type 17 was the vtable record type defined by the boilerplate C++
294 type definitions, as shown earlier.
296 The bit offset of the vtable pointer field is 32. The number of bits
297 in the field are not specified when the field is a vtable pointer.
299 Next is the method definition for the virtual member function
300 `A_virt'. Its description starts out using the same format as the
301 non-virtual member functions described above, except instead of a dot
302 after the `A' there is an asterisk, indicating that the function is
303 virtual. Since is is virtual some addition information is appended to
304 the end of the method description.
306 The first number represents the vtable index of the method. This is
307 a 32 bit unsigned number with the high bit set, followed by a
310 The second number is a type reference to the first base class in the
311 inheritence hierarchy defining the virtual member function. In this
312 case the class stab describes a base class so the virtual function is
313 not overriding any other definition of the method. Therefore the
314 reference is to the type number of the class that the stab is
317 This is followed by three semi-colons. One marks the end of the
318 current sub-section, one marks the end of the method field, and the
319 third marks the end of the struct definition.
321 For classes containing virtual functions the very last section of the
322 string part of the stab holds a type reference to the first base class.
323 This is preceeded by `~%' and followed by a final semi-colon.
325 .stabs "class_name(A):type_def(20)=sym_desc(struct)struct_bytes(8)
326 field_name(Adat):type_ref(int),bit_offset(0),field_bits(32);
327 field_name(A virt func ptr):type_def(21)=type_desc(ptr to)type_def(22)=
328 sym_desc(array)index_type_ref(range of int from 0 to 1);
329 elem_type_ref(vtbl elem type),
331 meth_name(A_virt)::typedef(23)=sym_desc(method)returning(int);
332 :arg_type(int),protection(public)normal(yes)virtual(yes)
333 vtable_index(1);class_first_defining(A);;;~%first_base(A);",
336 .stabs "A:t20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
337 A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
340 File: stabs.info, Node: Inheritence, Next: Virtual Base Classes, Prev: Virtual Methods, Up: Cplusplus
345 Stabs describing C++ derived classes include additional sections that
346 describe the inheritence hierarchy of the class. A derived class stab
347 also encodes the number of base classes. For each base class it tells
348 if the base class is virtual or not, and if the inheritence is private
349 or public. It also gives the offset into the object of the portion of
350 the object corresponding to each base class.
352 This additional information is embeded in the class stab following
353 the number of bytes in the struct. First the number of base classes
354 appears bracketed by an exclamation point and a comma.
356 Then for each base type there repeats a series: a virtual character,
357 a visibilty character, a number, a comma, another number, and a
360 The virtual character is `1' if the base class is virtual and `0' if
361 not. The visibility character is `2' if the derivation is public, `1'
362 if it is protected, and `0' if it is private. Debuggers should ignore
363 virtual or visibility characters they do not recognize, and assume a
364 reasonable default (such as public and non-virtual) (GDB 4.11 does not,
365 but this should be fixed in the next GDB release).
367 The number following the virtual and visibility characters is the
368 offset from the start of the object to the part of the object
369 pertaining to the base class.
371 After the comma, the second number is a type_descriptor for the base
372 type. Finally a semi-colon ends the series, which repeats for each
375 The source below defines three base classes `A', `B', and `C' and
376 the derived class `D'.
381 virtual int A_virt (int arg) { return arg; };
387 virtual int B_virt (int arg) {return arg; };
393 virtual int C_virt (int arg) {return arg; };
396 class D : A, virtual B, public C {
399 virtual int A_virt (int arg ) { return arg+1; };
400 virtual int B_virt (int arg) { return arg+2; };
401 virtual int C_virt (int arg) { return arg+3; };
402 virtual int D_virt (int arg) { return arg; };
405 Class stabs similar to the ones described earlier are generated for
408 .stabs "A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;
409 A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
411 .stabs "B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1;
412 :i;2A*-2147483647;25;;;~%25;",128,0,0,0
414 .stabs "C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1;
415 :i;2A*-2147483647;28;;;~%28;",128,0,0,0
417 In the stab describing derived class `D' below, the information about
418 the derivation of this class is encoded as follows.
420 .stabs "derived_class_name:symbol_descriptors(struct tag&type)=
421 type_descriptor(struct)struct_bytes(32)!num_bases(3),
422 base_virtual(no)inheritence_public(no)base_offset(0),
423 base_class_type_ref(A);
424 base_virtual(yes)inheritence_public(no)base_offset(NIL),
425 base_class_type_ref(B);
426 base_virtual(no)inheritence_public(yes)base_offset(64),
427 base_class_type_ref(C); ...
429 .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:
430 1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt:
431 :32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;
432 28;;D_virt::32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
435 File: stabs.info, Node: Virtual Base Classes, Next: Static Members, Prev: Inheritence, Up: Cplusplus
440 A derived class object consists of a concatination in memory of the
441 data areas defined by each base class, starting with the leftmost and
442 ending with the rightmost in the list of base classes. The exception
443 to this rule is for virtual inheritence. In the example above, class
444 `D' inherits virtually from base class `B'. This means that an
445 instance of a `D' object will not contain its own `B' part but merely a
446 pointer to a `B' part, known as a virtual base pointer.
448 In a derived class stab, the base offset part of the derivation
449 information, described above, shows how the base class parts are
450 ordered. The base offset for a virtual base class is always given as 0.
451 Notice that the base offset for `B' is given as 0 even though `B' is
452 not the first base class. The first base class `A' starts at offset 0.
454 The field information part of the stab for class `D' describes the
455 field which is the pointer to the virtual base class `B'. The vbase
456 pointer name is `$vb' followed by a type reference to the virtual base
457 class. Since the type id for `B' in this example is 25, the vbase
458 pointer name is `$vb25'.
460 .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,
461 160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;
462 2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt:
463 :32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
465 Following the name and a semicolon is a type reference describing the
466 type of the virtual base class pointer, in this case 24. Type 24 was
467 defined earlier as the type of the `B' class `this' pointer. The
468 `this' pointer for a class is a pointer to the class type.
470 .stabs "this:P24=*25=xsB:",64,0,0,8
472 Finally the field offset part of the vbase pointer field description
473 shows that the vbase pointer is the first field in the `D' object,
474 before any data fields defined by the class. The layout of a `D' class
475 object is a follows, `Adat' at 0, the vtable pointer for `A' at 32,
476 `Cdat' at 64, the vtable pointer for C at 96, the virtual base pointer
477 for `B' at 128, and `Ddat' at 160.
480 File: stabs.info, Node: Static Members, Prev: Virtual Base Classes, Up: Cplusplus
485 The data area for a class is a concatenation of the space used by the
486 data members of the class. If the class has virtual methods, a vtable
487 pointer follows the class data. The field offset part of each field
488 description in the class stab shows this ordering.
490 << How is this reflected in stabs? See Cygnus bug #677 for some
494 File: stabs.info, Node: Stab Types, Next: Symbol Descriptors, Prev: Cplusplus, Up: Top
499 The following are all the possible values for the stab type field,
500 for a.out files, in numeric order. This does not apply to XCOFF, but
501 it does apply to stabs in sections (*note Stab Sections::.). Stabs in
502 ECOFF use these values but add 0x8f300 to distinguish them from non-stab
505 The symbolic names are defined in the file `include/aout/stabs.def'.
509 * Non-Stab Symbol Types:: Types from 0 to 0x1f
510 * Stab Symbol Types:: Types from 0x20 to 0xff
513 File: stabs.info, Node: Non-Stab Symbol Types, Next: Stab Symbol Types, Up: Stab Types
515 Non-Stab Symbol Types
516 =====================
518 The following types are used by the linker and assembler, not by stab
519 directives. Since this document does not attempt to describe aspects of
520 object file format other than the debugging format, no details are
527 File scope absolute symbol
530 External absolute symbol
533 File scope text symbol
539 File scope data symbol
545 File scope BSS symbol
551 Same as `N_FN', for Sequent compilers
554 Symbol is indirected to another symbol
557 Common--visible after shared library dynamic link
560 `0x15 N_SETA | N_EXT'
564 `0x17 N_SETT | N_EXT'
565 Text segment set element
568 `0x19 N_SETD | N_EXT'
569 Data segment set element
572 `0x1b N_SETB | N_EXT'
573 BSS segment set element
576 `0x1d N_SETV | N_EXT'
577 Pointer to set vector
580 Print a warning message during linking
583 File name of a `.o' file
586 File: stabs.info, Node: Stab Symbol Types, Prev: Non-Stab Symbol Types, Up: Stab Types
591 The following symbol types indicate that this is a stab. This is the
592 full list of stab numbers, including stab types that are used in
593 languages other than C.
596 Global symbol; see *Note Global Variables::.
599 Function name (for BSD Fortran); see *Note Procedures::.
602 Function name (*note Procedures::.) or text segment variable
606 Data segment file-scope variable; see *Note Statics::.
609 BSS segment file-scope variable; see *Note Statics::.
612 Name of main routine; see *Note Main Program::.
615 Variable in `.rodata' section; see *Note Statics::.
618 Global symbol (for Pascal); see *Note N_PC::.
621 Number of symbols (according to Ultrix V4.0); see *Note N_NSYMS::.
624 No DST map; see *Note N_NOMAP::.
627 Object file (Solaris2).
630 Debugger options (Solaris2).
633 Register variable; see *Note Register Variables::.
636 Modula-2 compilation unit; see *Note N_M2C::.
639 Line number in text segment; see *Note Line Numbers::.
642 Line number in data segment; see *Note Line Numbers::.
645 Line number in bss segment; see *Note Line Numbers::.
648 Sun source code browser, path to `.cb' file; see *Note N_BROWS::.
651 GNU Modula2 definition module dependency; see *Note N_DEFD::.
654 Function start/body/end line numbers (Solaris2).
657 GNU C++ exception variable; see *Note N_EHDECL::.
660 Modula2 info "for imc" (according to Ultrix V4.0); see *Note
664 GNU C++ `catch' clause; see *Note N_CATCH::.
667 Structure of union element; see *Note N_SSYM::.
670 Last stab for module (Solaris2).
673 Path and name of source file; see *Note Source Files::.
676 Stack variable (*note Stack Variables::.) or type (*note
680 Beginning of an include file (Sun only); see *Note Include Files::.
683 Name of include file; see *Note Include Files::.
686 Parameter variable; see *Note Parameters::.
689 End of an include file; see *Note Include Files::.
692 Alternate entry point; see *Note Alternate Entry Points::.
695 Beginning of a lexical block; see *Note Block Structure::.
698 Place holder for a deleted include file; see *Note Include Files::.
701 Modula2 scope information (Sun linker); see *Note N_SCOPE::.
704 End of a lexical block; see *Note Block Structure::.
707 Begin named common block; see *Note Common Blocks::.
710 End named common block; see *Note Common Blocks::.
713 Member of a common block; see *Note Common Blocks::.
716 Pascal `with' statement: type,,0,0,offset (Solaris2).
719 Gould non-base registers; see *Note Gould::.
722 Gould non-base registers; see *Note Gould::.
725 Gould non-base registers; see *Note Gould::.
728 Gould non-base registers; see *Note Gould::.
731 Gould non-base registers; see *Note Gould::.
734 File: stabs.info, Node: Symbol Descriptors, Next: Type Descriptors, Prev: Stab Types, Up: Top
736 Table of Symbol Descriptors
737 ***************************
739 The symbol descriptor is the character which follows the colon in
740 many stabs, and which tells what kind of stab it is. *Note String
741 Field::, for more information about their use.
746 Variable on the stack; see *Note Stack Variables::.
749 C++ nested symbol; see *Note Nested Symbols::
752 Parameter passed by reference in register; see *Note Reference
756 Based variable; see *Note Based Variables::.
759 Constant; see *Note Constants::.
762 Conformant array bound (Pascal, maybe other languages); *Note
763 Conformant Arrays::. Name of a caught exception (GNU C++). These
764 can be distinguished because the latter uses `N_CATCH' and the
765 former uses another symbol type.
768 Floating point register variable; see *Note Register Variables::.
771 Parameter in floating point register; see *Note Register
775 File scope function; see *Note Procedures::.
778 Global function; see *Note Procedures::.
781 Global variable; see *Note Global Variables::.
784 *Note Register Parameters::.
787 Internal (nested) procedure; see *Note Nested Procedures::.
790 Internal (nested) function; see *Note Nested Procedures::.
793 Label name (documented by AIX, no further information known).
796 Module; see *Note Procedures::.
799 Argument list parameter; see *Note Parameters::.
805 Fortran Function parameter; see *Note Parameters::.
808 Unfortunately, three separate meanings have been independently
809 invented for this symbol descriptor. At least the GNU and Sun
810 uses can be distinguished by the symbol type. Global Procedure
811 (AIX) (symbol type used unknown); see *Note Procedures::.
812 Register parameter (GNU) (symbol type `N_PSYM'); see *Note
813 Parameters::. Prototype of function referenced by this file (Sun
814 `acc') (symbol type `N_FUN').
817 Static Procedure; see *Note Procedures::.
820 Register parameter; see *Note Register Parameters::.
823 Register variable; see *Note Register Variables::.
826 File scope variable; see *Note Statics::.
829 Local variable (OS9000).
832 Type name; see *Note Typedefs::.
835 Enumeration, structure, or union tag; see *Note Typedefs::.
838 Parameter passed by reference; see *Note Reference Parameters::.
841 Procedure scope static variable; see *Note Statics::.
844 Conformant array; see *Note Conformant Arrays::.
847 Function return variable; see *Note Parameters::.
850 File: stabs.info, Node: Type Descriptors, Next: Expanded Reference, Prev: Symbol Descriptors, Up: Top
852 Table of Type Descriptors
853 *************************
855 The type descriptor is the character which follows the type number
856 and an equals sign. It specifies what kind of type is being defined.
857 *Note String Field::, for more information about their use.
861 Type reference; see *Note String Field::.
864 Reference to builtin type; see *Note Negative Type Numbers::.
867 Method (C++); see *Note Method Type Descriptor::.
870 Pointer; see *Note Miscellaneous Types::.
876 Type Attributes (AIX); see *Note String Field::. Member (class
877 and variable) type (GNU C++); see *Note Member Type Descriptor::.
880 Array; see *Note Arrays::.
883 Open array; see *Note Arrays::.
886 Pascal space type (AIX); see *Note Miscellaneous Types::. Builtin
887 integer type (Sun); see *Note Builtin Type Descriptors::. Const
888 and volatile qualfied type (OS9000).
891 Volatile-qualified type; see *Note Miscellaneous Types::.
894 Complex builtin type (AIX); see *Note Builtin Type Descriptors::.
895 Const-qualified type (OS9000).
898 COBOL Picture type. See AIX documentation for details.
901 File type; see *Note Miscellaneous Types::.
904 N-dimensional dynamic array; see *Note Arrays::.
907 Enumeration type; see *Note Enumerations::.
910 N-dimensional subarray; see *Note Arrays::.
913 Function type; see *Note Function Types::.
916 Pascal function parameter; see *Note Function Types::
919 Builtin floating point type; see *Note Builtin Type Descriptors::.
922 COBOL Group. See AIX documentation for details.
925 Imported type (AIX); see *Note Cross-References::.
926 Volatile-qualified type (OS9000).
929 Const-qualified type; see *Note Miscellaneous Types::.
932 COBOL File Descriptor. See AIX documentation for details.
935 Multiple instance type; see *Note Miscellaneous Types::.
938 String type; see *Note Strings::.
941 Stringptr; see *Note Strings::.
944 Opaque type; see *Note Typedefs::.
947 Procedure; see *Note Function Types::.
950 Packed array; see *Note Arrays::.
953 Range type; see *Note Subranges::.
956 Builtin floating type; see *Note Builtin Type Descriptors:: (Sun).
957 Pascal subroutine parameter; see *Note Function Types:: (AIX).
958 Detecting this conflict is possible with careful parsing (hint: a
959 Pascal subroutine parameter type will always contain a comma, and
960 a builtin type descriptor never will).
963 Structure type; see *Note Structures::.
966 Set type; see *Note Miscellaneous Types::.
969 Union; see *Note Unions::.
972 Variant record. This is a Pascal and Modula-2 feature which is
973 like a union within a struct in C. See AIX documentation for
977 Wide character; see *Note Builtin Type Descriptors::.
980 Cross-reference; see *Note Cross-References::.
983 Used by IBM's xlC C++ compiler (for structures, I think).
986 gstring; see *Note Strings::.
989 File: stabs.info, Node: Expanded Reference, Next: Questions, Prev: Type Descriptors, Up: Top
991 Expanded Reference by Stab Type
992 *******************************
994 For a full list of stab types, and cross-references to where they are
995 described, see *Note Stab Types::. This appendix just covers certain
996 stabs which are not yet described in the main body of this document;
997 eventually the information will all be in one place.
1001 The first line is the symbol type (see `include/aout/stab.def').
1003 The second line describes the language constructs the symbol type
1006 The third line is the stab format with the significant stab fields
1007 named and the rest NIL.
1009 Subsequent lines expand upon the meaning and possible values for each
1010 significant stab field.
1012 Finally, any further information.
1016 * N_PC:: Pascal global symbol
1017 * N_NSYMS:: Number of symbols
1018 * N_NOMAP:: No DST map
1019 * N_M2C:: Modula-2 compilation unit
1020 * N_BROWS:: Path to .cb file for Sun source code browser
1021 * N_DEFD:: GNU Modula2 definition module dependency
1022 * N_EHDECL:: GNU C++ exception variable
1023 * N_MOD2:: Modula2 information "for imc"
1024 * N_CATCH:: GNU C++ "catch" clause
1025 * N_SSYM:: Structure or union element
1026 * N_SCOPE:: Modula2 scope information (Sun only)
1027 * Gould:: non-base register symbols used on Gould systems
1028 * N_LENG:: Length of preceding entry
1031 File: stabs.info, Node: N_PC, Next: N_NSYMS, Up: Expanded Reference
1037 Global symbol (for Pascal).
1039 "name" -> "symbol_name" <<?>>
1040 value -> supposedly the line number (stab.def is skeptical)
1044 global pascal symbol: name,,0,subtype,line
1048 File: stabs.info, Node: N_NSYMS, Next: N_NOMAP, Prev: N_PC, Up: Expanded Reference
1054 Number of symbols (according to Ultrix V4.0).
1056 0, files,,funcs,lines (stab.def)
1059 File: stabs.info, Node: N_NOMAP, Next: N_M2C, Prev: N_NSYMS, Up: Expanded Reference
1065 No DST map for symbol (according to Ultrix V4.0). I think this
1066 means a variable has been optimized out.
1068 name, ,0,type,ignored (stab.def)
1071 File: stabs.info, Node: N_M2C, Next: N_BROWS, Prev: N_NOMAP, Up: Expanded Reference
1077 Modula-2 compilation unit.
1079 "string" -> "unit_name,unit_time_stamp[,code_time_stamp]"
1081 value -> 0 (main unit)
1084 See `Dbx and Dbxtool Interfaces', 2nd edition, by Sun, 1988, for
1089 File: stabs.info, Node: N_BROWS, Next: N_DEFD, Prev: N_M2C, Up: Expanded Reference
1095 Sun source code browser, path to `.cb' file
1097 <<?>> "path to associated `.cb' file"
1099 Note: N_BROWS has the same value as N_BSLINE.
1102 File: stabs.info, Node: N_DEFD, Next: N_EHDECL, Prev: N_BROWS, Up: Expanded Reference
1108 GNU Modula2 definition module dependency.
1110 GNU Modula-2 definition module dependency. The value is the
1111 modification time of the definition file. The other field is
1112 non-zero if it is imported with the GNU M2 keyword `%INITIALIZE'.
1113 Perhaps `N_M2C' can be used if there are enough empty fields?
1116 File: stabs.info, Node: N_EHDECL, Next: N_MOD2, Prev: N_DEFD, Up: Expanded Reference
1121 - `.stabs': N_EHDECL
1122 GNU C++ exception variable <<?>>.
1124 "STRING is variable name"
1126 Note: conflicts with `N_MOD2'.
1129 File: stabs.info, Node: N_MOD2, Next: N_CATCH, Prev: N_EHDECL, Up: Expanded Reference
1135 Modula2 info "for imc" (according to Ultrix V4.0)
1137 Note: conflicts with `N_EHDECL' <<?>>
1140 File: stabs.info, Node: N_CATCH, Next: N_SSYM, Prev: N_MOD2, Up: Expanded Reference
1146 GNU C++ `catch' clause
1148 GNU C++ `catch' clause. The value is its address. The desc field
1149 is nonzero if this entry is immediately followed by a `CAUGHT' stab
1150 saying what exception was caught. Multiple `CAUGHT' stabs means
1151 that multiple exceptions can be caught here. If desc is 0, it
1152 means all exceptions are caught here.
1155 File: stabs.info, Node: N_SSYM, Next: N_SCOPE, Prev: N_CATCH, Up: Expanded Reference
1161 Structure or union element.
1163 The value is the offset in the structure.
1165 <<?looking at structs and unions in C I didn't see these>>
1168 File: stabs.info, Node: N_SCOPE, Next: Gould, Prev: N_SSYM, Up: Expanded Reference
1174 Modula2 scope information (Sun linker) <<?>>
1177 File: stabs.info, Node: Gould, Next: N_LENG, Prev: N_SCOPE, Up: Expanded Reference
1179 Non-base registers on Gould systems
1180 ===================================
1182 - `.stab?': N_NBTEXT
1183 - `.stab?': N_NBDATA
1187 These are used on Gould systems for non-base registers syms.
1189 However, the following values are not the values used by Gould;
1190 they are the values which GNU has been documenting for these
1191 values for a long time, without actually checking what Gould uses.
1192 I include these values only because perhaps some someone actually
1193 did something with the GNU information (I hope not, why GNU
1194 knowingly assigned wrong values to these in the header file is a
1195 complete mystery to me).
1197 240 0xf0 N_NBTEXT ??
1198 242 0xf2 N_NBDATA ??
1204 File: stabs.info, Node: N_LENG, Prev: Gould, Up: Expanded Reference
1210 Second symbol entry containing a length-value for the preceding
1211 entry. The value is the length.
1214 File: stabs.info, Node: Questions, Next: Stab Sections, Prev: Expanded Reference, Up: Top
1216 Questions and Anomalies
1217 ***********************
1219 * For GNU C stabs defining local and global variables (`N_LSYM' and
1220 `N_GSYM'), the desc field is supposed to contain the source line
1221 number on which the variable is defined. In reality the desc
1222 field is always 0. (This behavior is defined in `dbxout.c' and
1223 putting a line number in desc is controlled by `#ifdef
1224 WINNING_GDB', which defaults to false). GDB supposedly uses this
1225 information if you say `list VAR'. In reality, VAR can be a
1226 variable defined in the program and GDB says `function VAR not
1229 * In GNU C stabs, there seems to be no way to differentiate tag
1230 types: structures, unions, and enums (symbol descriptor `T') and
1231 typedefs (symbol descriptor `t') defined at file scope from types
1232 defined locally to a procedure or other more local scope. They
1233 all use the `N_LSYM' stab type. Types defined at procedure scope
1234 are emited after the `N_RBRAC' of the preceding function and
1235 before the code of the procedure in which they are defined. This
1236 is exactly the same as types defined in the source file between
1237 the two procedure bodies. GDB overcompensates by placing all
1238 types in block #1, the block for symbols of file scope. This is
1239 true for default, `-ansi' and `-traditional' compiler options.
1240 (Bugs gcc/1063, gdb/1066.)
1242 * What ends the procedure scope? Is it the proc block's `N_RBRAC'
1243 or the next `N_FUN'? (I believe its the first.)
1246 File: stabs.info, Node: Stab Sections, Next: Symbol Types Index, Prev: Questions, Up: Top
1248 Using Stabs in Their Own Sections
1249 *********************************
1251 Many object file formats allow tools to create object files with
1252 custom sections containing any arbitrary data. For any such object file
1253 format, stabs can be embedded in special sections. This is how stabs
1254 are used with ELF and SOM, and aside from ECOFF and XCOFF, is how stabs
1259 * Stab Section Basics:: How to embed stabs in sections
1260 * ELF Linker Relocation:: Sun ELF hacks
1263 File: stabs.info, Node: Stab Section Basics, Next: ELF Linker Relocation, Up: Stab Sections
1265 How to Embed Stabs in Sections
1266 ==============================
1268 The assembler creates two custom sections, a section named `.stab'
1269 which contains an array of fixed length structures, one struct per stab,
1270 and a section named `.stabstr' containing all the variable length
1271 strings that are referenced by stabs in the `.stab' section. The byte
1272 order of the stabs binary data depends on the object file format. For
1273 ELF, it matches the byte order of the ELF file itself, as determined
1274 from the `EI_DATA' field in the `e_ident' member of the ELF header.
1275 For SOM, it is always big-endian (is this true??? FIXME). For COFF, it
1276 matches the byte order of the COFF headers. The meaning of the fields
1277 is the same as for a.out (*note Symbol Table Format::.), except that
1278 the `n_strx' field is relative to the strings for the current
1279 compilation unit (which can be found using the synthetic N_UNDF stab
1280 described below), rather than the entire string table.
1282 The first stab in the `.stab' section for each compilation unit is
1283 synthetic, generated entirely by the assembler, with no corresponding
1284 `.stab' directive as input to the assembler. This stab contains the
1288 Offset in the `.stabstr' section to the source filename.
1294 Unused field, always zero. This may eventually be used to hold
1295 overflows from the count in the `n_desc' field.
1298 Count of upcoming symbols, i.e., the number of remaining stabs for
1302 Size of the string table fragment associated with this source
1305 The `.stabstr' section always starts with a null byte (so that string
1306 offsets of zero reference a null string), followed by random length
1307 strings, each of which is null byte terminated.
1309 The ELF section header for the `.stab' section has its `sh_link'
1310 member set to the section number of the `.stabstr' section, and the
1311 `.stabstr' section has its ELF section header `sh_type' member set to
1312 `SHT_STRTAB' to mark it as a string table. SOM and COFF have no way of
1313 linking the sections together or marking them as string tables.
1315 For COFF, the `.stab' and `.stabstr' sections may be simply
1316 concatenated by the linker. GDB then uses the `n_desc' fields to
1317 figure out the extent of the original sections. Similarly, the
1318 `n_value' fields of the header symbols are added together in order to
1319 get the actual position of the strings in a desired `.stabstr' section.
1320 Although this design obviates any need for the linker to relocate or
1321 otherwise manipulate `.stab' and `.stabstr' sections, it also requires
1322 some care to ensure that the offsets are calculated correctly. For
1323 instance, if the linker were to pad in between the `.stabstr' sections
1324 before concatenating, then the offsets to strings in the middle of the
1325 executable's `.stabstr' section would be wrong.
1327 The GNU linker is able to optimize stabs information by merging
1328 duplicate strings and removing duplicate header file information (*note
1329 Include Files::.). When some versions of the GNU linker optimize stabs
1330 in sections, they remove the leading `N_UNDF' symbol and arranges for
1331 all the `n_strx' fields to be relative to the start of the `.stabstr'
1335 File: stabs.info, Node: ELF Linker Relocation, Prev: Stab Section Basics, Up: Stab Sections
1337 Having the Linker Relocate Stabs in ELF
1338 =======================================
1340 This section describes some Sun hacks for Stabs in ELF; it does not
1341 apply to COFF or SOM.
1343 To keep linking fast, you don't want the linker to have to relocate
1344 very many stabs. Making sure this is done for `N_SLINE', `N_RBRAC',
1345 and `N_LBRAC' stabs is the most important thing (see the descriptions
1346 of those stabs for more information). But Sun's stabs in ELF has taken
1347 this further, to make all addresses in the `n_value' field (functions
1348 and static variables) relative to the source file. For the `N_SO'
1349 symbol itself, Sun simply omits the address. To find the address of
1350 each section corresponding to a given source file, the compiler puts
1351 out symbols giving the address of each section for a given source file.
1352 Since these are ELF (not stab) symbols, the linker relocates them
1353 correctly without having to touch the stabs section. They are named
1354 `Bbss.bss' for the bss section, `Ddata.data' for the data section, and
1355 `Drodata.rodata' for the rodata section. For the text section, there
1356 is no such symbol (but there should be, see below). For an example of
1357 how these symbols work, *Note Stab Section Transformations::. GCC does
1358 not provide these symbols; it instead relies on the stabs getting
1359 relocated. Thus addresses which would normally be relative to
1360 `Bbss.bss', etc., are already relocated. The Sun linker provided with
1361 Solaris 2.2 and earlier relocates stabs using normal ELF relocation
1362 information, as it would do for any section. Sun has been threatening
1363 to kludge their linker to not do this (to speed up linking), even
1364 though the correct way to avoid having the linker do these relocations
1365 is to have the compiler no longer output relocatable values. Last I
1366 heard they had been talked out of the linker kludge. See Sun point
1367 patch 101052-01 and Sun bug 1142109. With the Sun compiler this
1368 affects `S' symbol descriptor stabs (*note Statics::.) and functions
1369 (*note Procedures::.). In the latter case, to adopt the clean solution
1370 (making the value of the stab relative to the start of the compilation
1371 unit), it would be necessary to invent a `Ttext.text' symbol, analogous
1372 to the `Bbss.bss', etc., symbols. I recommend this rather than using a
1373 zero value and getting the address from the ELF symbols.
1375 Finding the correct `Bbss.bss', etc., symbol is difficult, because
1376 the linker simply concatenates the `.stab' sections from each `.o' file
1377 without including any information about which part of a `.stab' section
1378 comes from which `.o' file. The way GDB does this is to look for an
1379 ELF `STT_FILE' symbol which has the same name as the last component of
1380 the file name from the `N_SO' symbol in the stabs (for example, if the
1381 file name is `../../gdb/main.c', it looks for an ELF `STT_FILE' symbol
1382 named `main.c'). This loses if different files have the same name
1383 (they could be in different directories, a library could have been
1384 copied from one system to another, etc.). It would be much cleaner to
1385 have the `Bbss.bss' symbols in the stabs themselves. Having the linker
1386 relocate them there is no more work than having the linker relocate ELF
1387 symbols, and it solves the problem of having to associate the ELF and
1388 stab symbols. However, no one has yet designed or implemented such a