1This is stabs.info, produced by makeinfo version 4.6 from 2./stabs.texinfo. 3 4INFO-DIR-SECTION Software development 5START-INFO-DIR-ENTRY 6* Stabs: (stabs). The "stabs" debugging information format. 7END-INFO-DIR-ENTRY 8 9 This document describes the stabs debugging symbol tables. 10 11 Copyright 1992,1993,1994,1995,1997,1998,2000,2001 Free Software 12Foundation, Inc. Contributed by Cygnus Support. Written by Julia 13Menapace, Jim Kingdon, and David MacKenzie. 14 15 Permission is granted to copy, distribute and/or modify this document 16under the terms of the GNU Free Documentation License, Version 1.1 or 17any later version published by the Free Software Foundation; with no 18Invariant Sections, with no Front-Cover Texts, and with no Back-Cover 19Texts. A copy of the license is included in the section entitled "GNU 20Free Documentation License". 21 22 23File: stabs.info, Node: Top, Next: Overview, Up: (dir) 24 25The "stabs" representation of debugging information 26*************************************************** 27 28This document describes the stabs debugging format. 29 30* Menu: 31 32* Overview:: Overview of stabs 33* Program Structure:: Encoding of the structure of the program 34* Constants:: Constants 35* Variables:: 36* Types:: Type definitions 37* Symbol Tables:: Symbol information in symbol tables 38* Cplusplus:: Stabs specific to C++ 39* Stab Types:: Symbol types in a.out files 40* Symbol Descriptors:: Table of symbol descriptors 41* Type Descriptors:: Table of type descriptors 42* Expanded Reference:: Reference information by stab type 43* Questions:: Questions and anomalies 44* Stab Sections:: In some object file formats, stabs are 45 in sections. 46* Symbol Types Index:: Index of symbolic stab symbol type names. 47* GNU Free Documentation License:: The license for this documentation 48 49 50File: stabs.info, Node: Overview, Next: Program Structure, Prev: Top, Up: Top 51 52Overview of Stabs 53***************** 54 55"Stabs" refers to a format for information that describes a program to 56a debugger. This format was apparently invented by Peter Kessler at 57the University of California at Berkeley, for the `pdx' Pascal 58debugger; the format has spread widely since then. 59 60 This document is one of the few published sources of documentation on 61stabs. It is believed to be comprehensive for stabs used by C. The 62lists of symbol descriptors (*note Symbol Descriptors::) and type 63descriptors (*note Type Descriptors::) are believed to be completely 64comprehensive. Stabs for COBOL-specific features and for variant 65records (used by Pascal and Modula-2) are poorly documented here. 66 67 Other sources of information on stabs are `Dbx and Dbxtool 68Interfaces', 2nd edition, by Sun, 1988, and `AIX Version 3.2 Files 69Reference', Fourth Edition, September 1992, "dbx Stabstring Grammar" in 70the a.out section, page 2-31. This document is believed to incorporate 71the information from those two sources except where it explicitly 72directs you to them for more information. 73 74* Menu: 75 76* Flow:: Overview of debugging information flow 77* Stabs Format:: Overview of stab format 78* String Field:: The string field 79* C Example:: A simple example in C source 80* Assembly Code:: The simple example at the assembly level 81 82 83File: stabs.info, Node: Flow, Next: Stabs Format, Up: Overview 84 85Overview of Debugging Information Flow 86====================================== 87 88The GNU C compiler compiles C source in a `.c' file into assembly 89language in a `.s' file, which the assembler translates into a `.o' 90file, which the linker combines with other `.o' files and libraries to 91produce an executable file. 92 93 With the `-g' option, GCC puts in the `.s' file additional debugging 94information, which is slightly transformed by the assembler and linker, 95and carried through into the final executable. This debugging 96information describes features of the source file like line numbers, 97the types and scopes of variables, and function names, parameters, and 98scopes. 99 100 For some object file formats, the debugging information is 101encapsulated in assembler directives known collectively as "stab" 102(symbol table) directives, which are interspersed with the generated 103code. Stabs are the native format for debugging information in the 104a.out and XCOFF object file formats. The GNU tools can also emit stabs 105in the COFF and ECOFF object file formats. 106 107 The assembler adds the information from stabs to the symbol 108information it places by default in the symbol table and the string 109table of the `.o' file it is building. The linker consolidates the `.o' 110files into one executable file, with one symbol table and one string 111table. Debuggers use the symbol and string tables in the executable as 112a source of debugging information about the program. 113 114 115File: stabs.info, Node: Stabs Format, Next: String Field, Prev: Flow, Up: Overview 116 117Overview of Stab Format 118======================= 119 120There are three overall formats for stab assembler directives, 121differentiated by the first word of the stab. The name of the directive 122describes which combination of four possible data fields follows. It is 123either `.stabs' (string), `.stabn' (number), or `.stabd' (dot). IBM's 124XCOFF assembler uses `.stabx' (and some other directives such as 125`.file' and `.bi') instead of `.stabs', `.stabn' or `.stabd'. 126 127 The overall format of each class of stab is: 128 129 .stabs "STRING",TYPE,OTHER,DESC,VALUE 130 .stabn TYPE,OTHER,DESC,VALUE 131 .stabd TYPE,OTHER,DESC 132 .stabx "STRING",VALUE,TYPE,SDB-TYPE 133 134 For `.stabn' and `.stabd', there is no STRING (the `n_strx' field is 135zero; see *Note Symbol Tables::). For `.stabd', the VALUE field is 136implicit and has the value of the current file location. For `.stabx', 137the SDB-TYPE field is unused for stabs and can always be set to zero. 138The OTHER field is almost always unused and can be set to zero. 139 140 The number in the TYPE field gives some basic information about 141which type of stab this is (or whether it _is_ a stab, as opposed to an 142ordinary symbol). Each valid type number defines a different stab 143type; further, the stab type defines the exact interpretation of, and 144possible values for, any remaining STRING, DESC, or VALUE fields 145present in the stab. *Note Stab Types::, for a list in numeric order 146of the valid TYPE field values for stab directives. 147 148 149File: stabs.info, Node: String Field, Next: C Example, Prev: Stabs Format, Up: Overview 150 151The String Field 152================ 153 154For most stabs the string field holds the meat of the debugging 155information. The flexible nature of this field is what makes stabs 156extensible. For some stab types the string field contains only a name. 157For other stab types the contents can be a great deal more complex. 158 159 The overall format of the string field for most stab types is: 160 161 "NAME:SYMBOL-DESCRIPTOR TYPE-INFORMATION" 162 163 NAME is the name of the symbol represented by the stab; it can 164contain a pair of colons (*note Nested Symbols::). NAME can be 165omitted, which means the stab represents an unnamed object. For 166example, `:t10=*2' defines type 10 as a pointer to type 2, but does not 167give the type a name. Omitting the NAME field is supported by AIX dbx 168and GDB after about version 4.8, but not other debuggers. GCC 169sometimes uses a single space as the name instead of omitting the name 170altogether; apparently that is supported by most debuggers. 171 172 The SYMBOL-DESCRIPTOR following the `:' is an alphabetic character 173that tells more specifically what kind of symbol the stab represents. 174If the SYMBOL-DESCRIPTOR is omitted, but type information follows, then 175the stab represents a local variable. For a list of symbol 176descriptors, see *Note Symbol Descriptors::. The `c' symbol descriptor 177is an exception in that it is not followed by type information. *Note 178Constants::. 179 180 TYPE-INFORMATION is either a TYPE-NUMBER, or `TYPE-NUMBER='. A 181TYPE-NUMBER alone is a type reference, referring directly to a type 182that has already been defined. 183 184 The `TYPE-NUMBER=' form is a type definition, where the number 185represents a new type which is about to be defined. The type 186definition may refer to other types by number, and those type numbers 187may be followed by `=' and nested definitions. Also, the Lucid 188compiler will repeat `TYPE-NUMBER=' more than once if it wants to 189define several type numbers at once. 190 191 In a type definition, if the character that follows the equals sign 192is non-numeric then it is a TYPE-DESCRIPTOR, and tells what kind of 193type is about to be defined. Any other values following the 194TYPE-DESCRIPTOR vary, depending on the TYPE-DESCRIPTOR. *Note Type 195Descriptors::, for a list of TYPE-DESCRIPTOR values. If a number 196follows the `=' then the number is a TYPE-REFERENCE. For a full 197description of types, *Note Types::. 198 199 A TYPE-NUMBER is often a single number. The GNU and Sun tools 200additionally permit a TYPE-NUMBER to be a pair 201(FILE-NUMBER,FILETYPE-NUMBER) (the parentheses appear in the string, 202and serve to distinguish the two cases). The FILE-NUMBER is 0 for the 203base source file, 1 for the first included file, 2 for the next, and so 204on. The FILETYPE-NUMBER is a number starting with 1 which is 205incremented for each new type defined in the file. (Separating the 206file number and the type number permits the `N_BINCL' optimization to 207succeed more often; see *Note Include Files::). 208 209 There is an AIX extension for type attributes. Following the `=' 210are any number of type attributes. Each one starts with `@' and ends 211with `;'. Debuggers, including AIX's dbx and GDB 4.10, skip any type 212attributes they do not recognize. GDB 4.9 and other versions of dbx 213may not do this. Because of a conflict with C++ (*note Cplusplus::), 214new attributes should not be defined which begin with a digit, `(', or 215`-'; GDB may be unable to distinguish those from the C++ type 216descriptor `@'. The attributes are: 217 218`aBOUNDARY' 219 BOUNDARY is an integer specifying the alignment. I assume it 220 applies to all variables of this type. 221 222`pINTEGER' 223 Pointer class (for checking). Not sure what this means, or how 224 INTEGER is interpreted. 225 226`P' 227 Indicate this is a packed type, meaning that structure fields or 228 array elements are placed more closely in memory, to save memory 229 at the expense of speed. 230 231`sSIZE' 232 Size in bits of a variable of this type. This is fully supported 233 by GDB 4.11 and later. 234 235`S' 236 Indicate that this type is a string instead of an array of 237 characters, or a bitstring instead of a set. It doesn't change 238 the layout of the data being represented, but does enable the 239 debugger to know which type it is. 240 241`V' 242 Indicate that this type is a vector instead of an array. The only 243 major difference between vectors and arrays is that vectors are 244 passed by value instead of by reference (vector coprocessor 245 extension). 246 247 248 All of this can make the string field quite long. All versions of 249GDB, and some versions of dbx, can handle arbitrarily long strings. 250But many versions of dbx (or assemblers or linkers, I'm not sure which) 251cretinously limit the strings to about 80 characters, so compilers which 252must work with such systems need to split the `.stabs' directive into 253several `.stabs' directives. Each stab duplicates every field except 254the string field. The string field of every stab except the last is 255marked as continued with a backslash at the end (in the assembly code 256this may be written as a double backslash, depending on the assembler). 257Removing the backslashes and concatenating the string fields of each 258stab produces the original, long string. Just to be incompatible (or so 259they don't have to worry about what the assembler does with 260backslashes), AIX can use `?' instead of backslash. 261 262 263File: stabs.info, Node: C Example, Next: Assembly Code, Prev: String Field, Up: Overview 264 265A Simple Example in C Source 266============================ 267 268To get the flavor of how stabs describe source information for a C 269program, let's look at the simple program: 270 271 main() 272 { 273 printf("Hello world"); 274 } 275 276 When compiled with `-g', the program above yields the following `.s' 277file. Line numbers have been added to make it easier to refer to parts 278of the `.s' file in the description of the stabs that follows. 279 280 281File: stabs.info, Node: Assembly Code, Prev: C Example, Up: Overview 282 283The Simple Example at the Assembly Level 284======================================== 285 286This simple "hello world" example demonstrates several of the stab 287types used to describe C language source files. 288 289 1 gcc2_compiled.: 290 2 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0 291 3 .stabs "hello.c",100,0,0,Ltext0 292 4 .text 293 5 Ltext0: 294 6 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0 295 7 .stabs "char:t2=r2;0;127;",128,0,0,0 296 8 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0 297 9 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0 298 10 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0 299 11 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0 300 12 .stabs "long long int:t7=r1;0;-1;",128,0,0,0 301 13 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0 302 14 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0 303 15 .stabs "signed char:t10=r1;-128;127;",128,0,0,0 304 16 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0 305 17 .stabs "float:t12=r1;4;0;",128,0,0,0 306 18 .stabs "double:t13=r1;8;0;",128,0,0,0 307 19 .stabs "long double:t14=r1;8;0;",128,0,0,0 308 20 .stabs "void:t15=15",128,0,0,0 309 21 .align 4 310 22 LC0: 311 23 .ascii "Hello, world!\12\0" 312 24 .align 4 313 25 .global _main 314 26 .proc 1 315 27 _main: 316 28 .stabn 68,0,4,LM1 317 29 LM1: 318 30 !#PROLOGUE# 0 319 31 save %sp,-136,%sp 320 32 !#PROLOGUE# 1 321 33 call ___main,0 322 34 nop 323 35 .stabn 68,0,5,LM2 324 36 LM2: 325 37 LBB2: 326 38 sethi %hi(LC0),%o1 327 39 or %o1,%lo(LC0),%o0 328 40 call _printf,0 329 41 nop 330 42 .stabn 68,0,6,LM3 331 43 LM3: 332 44 LBE2: 333 45 .stabn 68,0,6,LM4 334 46 LM4: 335 47 L1: 336 48 ret 337 49 restore 338 50 .stabs "main:F1",36,0,0,_main 339 51 .stabn 192,0,0,LBB2 340 52 .stabn 224,0,0,LBE2 341 342 343File: stabs.info, Node: Program Structure, Next: Constants, Prev: Overview, Up: Top 344 345Encoding the Structure of the Program 346************************************* 347 348The elements of the program structure that stabs encode include the name 349of the main function, the names of the source and include files, the 350line numbers, procedure names and types, and the beginnings and ends of 351blocks of code. 352 353* Menu: 354 355* Main Program:: Indicate what the main program is 356* Source Files:: The path and name of the source file 357* Include Files:: Names of include files 358* Line Numbers:: 359* Procedures:: 360* Nested Procedures:: 361* Block Structure:: 362* Alternate Entry Points:: Entering procedures except at the beginning. 363 364 365File: stabs.info, Node: Main Program, Next: Source Files, Up: Program Structure 366 367Main Program 368============ 369 370Most languages allow the main program to have any name. The `N_MAIN' 371stab type tells the debugger the name that is used in this program. 372Only the string field is significant; it is the name of a function 373which is the main program. Most C compilers do not use this stab (they 374expect the debugger to assume that the name is `main'), but some C 375compilers emit an `N_MAIN' stab for the `main' function. I'm not sure 376how XCOFF handles this. 377 378 379File: stabs.info, Node: Source Files, Next: Include Files, Prev: Main Program, Up: Program Structure 380 381Paths and Names of the Source Files 382=================================== 383 384Before any other stabs occur, there must be a stab specifying the source 385file. This information is contained in a symbol of stab type `N_SO'; 386the string field contains the name of the file. The value of the 387symbol is the start address of the portion of the text section 388corresponding to that file. 389 390 With the Sun Solaris2 compiler, the desc field contains a 391source-language code. 392 393 Some compilers (for example, GCC2 and SunOS4 `/bin/cc') also include 394the directory in which the source was compiled, in a second `N_SO' 395symbol preceding the one containing the file name. This symbol can be 396distinguished by the fact that it ends in a slash. Code from the 397`cfront' C++ compiler can have additional `N_SO' symbols for 398nonexistent source files after the `N_SO' for the real source file; 399these are believed to contain no useful information. 400 401 For example: 402 403 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0 # 100 is N_SO 404 .stabs "hello.c",100,0,0,Ltext0 405 .text 406 Ltext0: 407 408 Instead of `N_SO' symbols, XCOFF uses a `.file' assembler directive 409which assembles to a `C_FILE' symbol; explaining this in detail is 410outside the scope of this document. 411 412 If it is useful to indicate the end of a source file, this is done 413with an `N_SO' symbol with an empty string for the name. The value is 414the address of the end of the text section for the file. For some 415systems, there is no indication of the end of a source file, and you 416just need to figure it ended when you see an `N_SO' for a different 417source file, or a symbol ending in `.o' (which at least some linkers 418insert to mark the start of a new `.o' file). 419 420 421File: stabs.info, Node: Include Files, Next: Line Numbers, Prev: Source Files, Up: Program Structure 422 423Names of Include Files 424====================== 425 426There are several schemes for dealing with include files: the 427traditional `N_SOL' approach, Sun's `N_BINCL' approach, and the XCOFF 428`C_BINCL' approach (which despite the similar name has little in common 429with `N_BINCL'). 430 431 An `N_SOL' symbol specifies which include file subsequent symbols 432refer to. The string field is the name of the file and the value is the 433text address corresponding to the end of the previous include file and 434the start of this one. To specify the main source file again, use an 435`N_SOL' symbol with the name of the main source file. 436 437 The `N_BINCL' approach works as follows. An `N_BINCL' symbol 438specifies the start of an include file. In an object file, only the 439string is significant; the linker puts data into some of the other 440fields. The end of the include file is marked by an `N_EINCL' symbol 441(which has no string field). In an object file, there is no 442significant data in the `N_EINCL' symbol. `N_BINCL' and `N_EINCL' can 443be nested. 444 445 If the linker detects that two source files have identical stabs 446between an `N_BINCL' and `N_EINCL' pair (as will generally be the case 447for a header file), then it only puts out the stabs once. Each 448additional occurrence is replaced by an `N_EXCL' symbol. I believe the 449GNU linker and the Sun (both SunOS4 and Solaris) linker are the only 450ones which supports this feature. 451 452 A linker which supports this feature will set the value of a 453`N_BINCL' symbol to the total of all the characters in the stabs 454strings included in the header file, omitting any file numbers. The 455value of an `N_EXCL' symbol is the same as the value of the `N_BINCL' 456symbol it replaces. This information can be used to match up `N_EXCL' 457and `N_BINCL' symbols which have the same filename. The `N_EINCL' 458value, and the values of the other and description fields for all 459three, appear to always be zero. 460 461 For the start of an include file in XCOFF, use the `.bi' assembler 462directive, which generates a `C_BINCL' symbol. A `.ei' directive, 463which generates a `C_EINCL' symbol, denotes the end of the include 464file. Both directives are followed by the name of the source file in 465quotes, which becomes the string for the symbol. The value of each 466symbol, produced automatically by the assembler and linker, is the 467offset into the executable of the beginning (inclusive, as you'd 468expect) or end (inclusive, as you would not expect) of the portion of 469the COFF line table that corresponds to this include file. `C_BINCL' 470and `C_EINCL' do not nest. 471 472 473File: stabs.info, Node: Line Numbers, Next: Procedures, Prev: Include Files, Up: Program Structure 474 475Line Numbers 476============ 477 478An `N_SLINE' symbol represents the start of a source line. The desc 479field contains the line number and the value contains the code address 480for the start of that source line. On most machines the address is 481absolute; for stabs in sections (*note Stab Sections::), it is relative 482to the function in which the `N_SLINE' symbol occurs. 483 484 GNU documents `N_DSLINE' and `N_BSLINE' symbols for line numbers in 485the data or bss segments, respectively. They are identical to 486`N_SLINE' but are relocated differently by the linker. They were 487intended to be used to describe the source location of a variable 488declaration, but I believe that GCC2 actually puts the line number in 489the desc field of the stab for the variable itself. GDB has been 490ignoring these symbols (unless they contain a string field) since at 491least GDB 3.5. 492 493 For single source lines that generate discontiguous code, such as 494flow of control statements, there may be more than one line number 495entry for the same source line. In this case there is a line number 496entry at the start of each code range, each with the same line number. 497 498 XCOFF does not use stabs for line numbers. Instead, it uses COFF 499line numbers (which are outside the scope of this document). Standard 500COFF line numbers cannot deal with include files, but in XCOFF this is 501fixed with the `C_BINCL' method of marking include files (*note Include 502Files::). 503 504 505File: stabs.info, Node: Procedures, Next: Nested Procedures, Prev: Line Numbers, Up: Program Structure 506 507Procedures 508========== 509 510All of the following stabs normally use the `N_FUN' symbol type. 511However, Sun's `acc' compiler on SunOS4 uses `N_GSYM' and `N_STSYM', 512which means that the value of the stab for the function is useless and 513the debugger must get the address of the function from the non-stab 514symbols instead. On systems where non-stab symbols have leading 515underscores, the stabs will lack underscores and the debugger needs to 516know about the leading underscore to match up the stab and the non-stab 517symbol. BSD Fortran is said to use `N_FNAME' with the same 518restriction; the value of the symbol is not useful (I'm not sure it 519really does use this, because GDB doesn't handle this and no one has 520complained). 521 522 A function is represented by an `F' symbol descriptor for a global 523(extern) function, and `f' for a static (local) function. For a.out, 524the value of the symbol is the address of the start of the function; it 525is already relocated. For stabs in ELF, the SunPRO compiler version 5262.0.1 and GCC put out an address which gets relocated by the linker. 527In a future release SunPRO is planning to put out zero, in which case 528the address can be found from the ELF (non-stab) symbol. Because 529looking things up in the ELF symbols would probably be slow, I'm not 530sure how to find which symbol of that name is the right one, and this 531doesn't provide any way to deal with nested functions, it would 532probably be better to make the value of the stab an address relative to 533the start of the file, or just absolute. See *Note ELF Linker 534Relocation:: for more information on linker relocation of stabs in ELF 535files. For XCOFF, the stab uses the `C_FUN' storage class and the 536value of the stab is meaningless; the address of the function can be 537found from the csect symbol (XTY_LD/XMC_PR). 538 539 The type information of the stab represents the return type of the 540function; thus `foo:f5' means that foo is a function returning type 5. 541There is no need to try to get the line number of the start of the 542function from the stab for the function; it is in the next `N_SLINE' 543symbol. 544 545 Some compilers (such as Sun's Solaris compiler) support an extension 546for specifying the types of the arguments. I suspect this extension is 547not used for old (non-prototyped) function definitions in C. If the 548extension is in use, the type information of the stab for the function 549is followed by type information for each argument, with each argument 550preceded by `;'. An argument type of 0 means that additional arguments 551are being passed, whose types and number may vary (`...' in ANSI C). 552GDB has tolerated this extension (parsed the syntax, if not necessarily 553used the information) since at least version 4.8; I don't know whether 554all versions of dbx tolerate it. The argument types given here are not 555redundant with the symbols for the formal parameters (*note 556Parameters::); they are the types of the arguments as they are passed, 557before any conversions might take place. For example, if a C function 558which is declared without a prototype takes a `float' argument, the 559value is passed as a `double' but then converted to a `float'. 560Debuggers need to use the types given in the arguments when printing 561values, but when calling the function they need to use the types given 562in the symbol defining the function. 563 564 If the return type and types of arguments of a function which is 565defined in another source file are specified (i.e., a function 566prototype in ANSI C), traditionally compilers emit no stab; the only 567way for the debugger to find the information is if the source file 568where the function is defined was also compiled with debugging symbols. 569As an extension the Solaris compiler uses symbol descriptor `P' 570followed by the return type of the function, followed by the arguments, 571each preceded by `;', as in a stab with symbol descriptor `f' or `F'. 572This use of symbol descriptor `P' can be distinguished from its use for 573register parameters (*note Register Parameters::) by the fact that it 574has symbol type `N_FUN'. 575 576 The AIX documentation also defines symbol descriptor `J' as an 577internal function. I assume this means a function nested within another 578function. It also says symbol descriptor `m' is a module in Modula-2 579or extended Pascal. 580 581 Procedures (functions which do not return values) are represented as 582functions returning the `void' type in C. I don't see why this couldn't 583be used for all languages (inventing a `void' type for this purpose if 584necessary), but the AIX documentation defines `I', `P', and `Q' for 585internal, global, and static procedures, respectively. These symbol 586descriptors are unusual in that they are not followed by type 587information. 588 589 The following example shows a stab for a function `main' which 590returns type number `1'. The `_main' specified for the value is a 591reference to an assembler label which is used to fill in the start 592address of the function. 593 594 .stabs "main:F1",36,0,0,_main # 36 is N_FUN 595 596 The stab representing a procedure is located immediately following 597the code of the procedure. This stab is in turn directly followed by a 598group of other stabs describing elements of the procedure. These other 599stabs describe the procedure's parameters, its block local variables, 600and its block structure. 601 602 If functions can appear in different sections, then the debugger may 603not be able to find the end of a function. Recent versions of GCC will 604mark the end of a function with an `N_FUN' symbol with an empty string 605for the name. The value is the address of the end of the current 606function. Without such a symbol, there is no indication of the address 607of the end of a function, and you must assume that it ended at the 608starting address of the next function or at the end of the text section 609for the program. 610 611 612File: stabs.info, Node: Nested Procedures, Next: Block Structure, Prev: Procedures, Up: Program Structure 613 614Nested Procedures 615================= 616 617For any of the symbol descriptors representing procedures, after the 618symbol descriptor and the type information is optionally a scope 619specifier. This consists of a comma, the name of the procedure, another 620comma, and the name of the enclosing procedure. The first name is local 621to the scope specified, and seems to be redundant with the name of the 622symbol (before the `:'). This feature is used by GCC, and presumably 623Pascal, Modula-2, etc., compilers, for nested functions. 624 625 If procedures are nested more than one level deep, only the 626immediately containing scope is specified. For example, this code: 627 628 int 629 foo (int x) 630 { 631 int bar (int y) 632 { 633 int baz (int z) 634 { 635 return x + y + z; 636 } 637 return baz (x + 2 * y); 638 } 639 return x + bar (3 * x); 640 } 641 642produces the stabs: 643 644 .stabs "baz:f1,baz,bar",36,0,0,_baz.15 # 36 is N_FUN 645 .stabs "bar:f1,bar,foo",36,0,0,_bar.12 646 .stabs "foo:F1",36,0,0,_foo 647 648 649File: stabs.info, Node: Block Structure, Next: Alternate Entry Points, Prev: Nested Procedures, Up: Program Structure 650 651Block Structure 652=============== 653 654The program's block structure is represented by the `N_LBRAC' (left 655brace) and the `N_RBRAC' (right brace) stab types. The variables 656defined inside a block precede the `N_LBRAC' symbol for most compilers, 657including GCC. Other compilers, such as the Convex, Acorn RISC 658machine, and Sun `acc' compilers, put the variables after the `N_LBRAC' 659symbol. The values of the `N_LBRAC' and `N_RBRAC' symbols are the 660start and end addresses of the code of the block, respectively. For 661most machines, they are relative to the starting address of this source 662file. For the Gould NP1, they are absolute. For stabs in sections 663(*note Stab Sections::), they are relative to the function in which 664they occur. 665 666 The `N_LBRAC' and `N_RBRAC' stabs that describe the block scope of a 667procedure are located after the `N_FUN' stab that represents the 668procedure itself. 669 670 Sun documents the desc field of `N_LBRAC' and `N_RBRAC' symbols as 671containing the nesting level of the block. However, dbx seems to not 672care, and GCC always sets desc to zero. 673 674 For XCOFF, block scope is indicated with `C_BLOCK' symbols. If the 675name of the symbol is `.bb', then it is the beginning of the block; if 676the name of the symbol is `.be'; it is the end of the block. 677 678 679File: stabs.info, Node: Alternate Entry Points, Prev: Block Structure, Up: Program Structure 680 681Alternate Entry Points 682====================== 683 684Some languages, like Fortran, have the ability to enter procedures at 685some place other than the beginning. One can declare an alternate entry 686point. The `N_ENTRY' stab is for this; however, the Sun FORTRAN 687compiler doesn't use it. According to AIX documentation, only the name 688of a `C_ENTRY' stab is significant; the address of the alternate entry 689point comes from the corresponding external symbol. A previous 690revision of this document said that the value of an `N_ENTRY' stab was 691the address of the alternate entry point, but I don't know the source 692for that information. 693 694 695File: stabs.info, Node: Constants, Next: Variables, Prev: Program Structure, Up: Top 696 697Constants 698********* 699 700The `c' symbol descriptor indicates that this stab represents a 701constant. This symbol descriptor is an exception to the general rule 702that symbol descriptors are followed by type information. Instead, it 703is followed by `=' and one of the following: 704 705`b VALUE' 706 Boolean constant. VALUE is a numeric value; I assume it is 0 for 707 false or 1 for true. 708 709`c VALUE' 710 Character constant. VALUE is the numeric value of the constant. 711 712`e TYPE-INFORMATION , VALUE' 713 Constant whose value can be represented as integral. 714 TYPE-INFORMATION is the type of the constant, as it would appear 715 after a symbol descriptor (*note String Field::). VALUE is the 716 numeric value of the constant. GDB 4.9 does not actually get the 717 right value if VALUE does not fit in a host `int', but it does not 718 do anything violent, and future debuggers could be extended to 719 accept integers of any size (whether unsigned or not). This 720 constant type is usually documented as being only for enumeration 721 constants, but GDB has never imposed that restriction; I don't 722 know about other debuggers. 723 724`i VALUE' 725 Integer constant. VALUE is the numeric value. The type is some 726 sort of generic integer type (for GDB, a host `int'); to specify 727 the type explicitly, use `e' instead. 728 729`r VALUE' 730 Real constant. VALUE is the real value, which can be `INF' 731 (optionally preceded by a sign) for infinity, `QNAN' for a quiet 732 NaN (not-a-number), or `SNAN' for a signalling NaN. If it is a 733 normal number the format is that accepted by the C library function 734 `atof'. 735 736`s STRING' 737 String constant. STRING is a string enclosed in either `'' (in 738 which case `'' characters within the string are represented as 739 `\'' or `"' (in which case `"' characters within the string are 740 represented as `\"'). 741 742`S TYPE-INFORMATION , ELEMENTS , BITS , PATTERN' 743 Set constant. TYPE-INFORMATION is the type of the constant, as it 744 would appear after a symbol descriptor (*note String Field::). 745 ELEMENTS is the number of elements in the set (does this means how 746 many bits of PATTERN are actually used, which would be redundant 747 with the type, or perhaps the number of bits set in PATTERN? I 748 don't get it), BITS is the number of bits in the constant (meaning 749 it specifies the length of PATTERN, I think), and PATTERN is a 750 hexadecimal representation of the set. AIX documentation refers 751 to a limit of 32 bytes, but I see no reason why this limit should 752 exist. This form could probably be used for arbitrary constants, 753 not just sets; the only catch is that PATTERN should be understood 754 to be target, not host, byte order and format. 755 756 The boolean, character, string, and set constants are not supported 757by GDB 4.9, but it ignores them. GDB 4.8 and earlier gave an error 758message and refused to read symbols from the file containing the 759constants. 760 761 The above information is followed by `;'. 762 763 764File: stabs.info, Node: Variables, Next: Types, Prev: Constants, Up: Top 765 766Variables 767********* 768 769Different types of stabs describe the various ways that variables can be 770allocated: on the stack, globally, in registers, in common blocks, 771statically, or as arguments to a function. 772 773* Menu: 774 775* Stack Variables:: Variables allocated on the stack. 776* Global Variables:: Variables used by more than one source file. 777* Register Variables:: Variables in registers. 778* Common Blocks:: Variables statically allocated together. 779* Statics:: Variables local to one source file. 780* Based Variables:: Fortran pointer based variables. 781* Parameters:: Variables for arguments to functions. 782 783 784File: stabs.info, Node: Stack Variables, Next: Global Variables, Up: Variables 785 786Automatic Variables Allocated on the Stack 787========================================== 788 789If a variable's scope is local to a function and its lifetime is only as 790long as that function executes (C calls such variables "automatic"), it 791can be allocated in a register (*note Register Variables::) or on the 792stack. 793 794 Each variable allocated on the stack has a stab with the symbol 795descriptor omitted. Since type information should begin with a digit, 796`-', or `(', only those characters precluded from being used for symbol 797descriptors. However, the Acorn RISC machine (ARM) is said to get this 798wrong: it puts out a mere type definition here, without the preceding 799`TYPE-NUMBER='. This is a bad idea; there is no guarantee that type 800descriptors are distinct from symbol descriptors. Stabs for stack 801variables use the `N_LSYM' stab type, or `C_LSYM' for XCOFF. 802 803 The value of the stab is the offset of the variable within the local 804variables. On most machines this is an offset from the frame pointer 805and is negative. The location of the stab specifies which block it is 806defined in; see *Note Block Structure::. 807 808 For example, the following C code: 809 810 int 811 main () 812 { 813 int x; 814 } 815 816 produces the following stabs: 817 818 .stabs "main:F1",36,0,0,_main # 36 is N_FUN 819 .stabs "x:1",128,0,0,-12 # 128 is N_LSYM 820 .stabn 192,0,0,LBB2 # 192 is N_LBRAC 821 .stabn 224,0,0,LBE2 # 224 is N_RBRAC 822 823 See *Note Procedures:: for more information on the `N_FUN' stab, and 824*Note Block Structure:: for more information on the `N_LBRAC' and 825`N_RBRAC' stabs. 826 827 828File: stabs.info, Node: Global Variables, Next: Register Variables, Prev: Stack Variables, Up: Variables 829 830Global Variables 831================ 832 833A variable whose scope is not specific to just one source file is 834represented by the `G' symbol descriptor. These stabs use the `N_GSYM' 835stab type (C_GSYM for XCOFF). The type information for the stab (*note 836String Field::) gives the type of the variable. 837 838 For example, the following source code: 839 840 char g_foo = 'c'; 841 842yields the following assembly code: 843 844 .stabs "g_foo:G2",32,0,0,0 # 32 is N_GSYM 845 .global _g_foo 846 .data 847 _g_foo: 848 .byte 99 849 850 The address of the variable represented by the `N_GSYM' is not 851contained in the `N_GSYM' stab. The debugger gets this information 852from the external symbol for the global variable. In the example above, 853the `.global _g_foo' and `_g_foo:' lines tell the assembler to produce 854an external symbol. 855 856 Some compilers, like GCC, output `N_GSYM' stabs only once, where the 857variable is defined. Other compilers, like SunOS4 /bin/cc, output a 858`N_GSYM' stab for each compilation unit which references the variable. 859 860 861File: stabs.info, Node: Register Variables, Next: Common Blocks, Prev: Global Variables, Up: Variables 862 863Register Variables 864================== 865 866Register variables have their own stab type, `N_RSYM' (`C_RSYM' for 867XCOFF), and their own symbol descriptor, `r'. The stab's value is the 868number of the register where the variable data will be stored. 869 870 AIX defines a separate symbol descriptor `d' for floating point 871registers. This seems unnecessary; why not just just give floating 872point registers different register numbers? I have not verified whether 873the compiler actually uses `d'. 874 875 If the register is explicitly allocated to a global variable, but not 876initialized, as in: 877 878 register int g_bar asm ("%g5"); 879 880then the stab may be emitted at the end of the object file, with the 881other bss symbols. 882 883 884File: stabs.info, Node: Common Blocks, Next: Statics, Prev: Register Variables, Up: Variables 885 886Common Blocks 887============= 888 889A common block is a statically allocated section of memory which can be 890referred to by several source files. It may contain several variables. 891I believe Fortran is the only language with this feature. 892 893 A `N_BCOMM' stab begins a common block and an `N_ECOMM' stab ends 894it. The only field that is significant in these two stabs is the 895string, which names a normal (non-debugging) symbol that gives the 896address of the common block. According to IBM documentation, only the 897`N_BCOMM' has the name of the common block (even though their compiler 898actually puts it both places). 899 900 The stabs for the members of the common block are between the 901`N_BCOMM' and the `N_ECOMM'; the value of each stab is the offset 902within the common block of that variable. IBM uses the `C_ECOML' stab 903type, and there is a corresponding `N_ECOML' stab type, but Sun's 904Fortran compiler uses `N_GSYM' instead. The variables within a common 905block use the `V' symbol descriptor (I believe this is true of all 906Fortran variables). Other stabs (at least type declarations using 907`C_DECL') can also be between the `N_BCOMM' and the `N_ECOMM'. 908 909 910File: stabs.info, Node: Statics, Next: Based Variables, Prev: Common Blocks, Up: Variables 911 912Static Variables 913================ 914 915Initialized static variables are represented by the `S' and `V' symbol 916descriptors. `S' means file scope static, and `V' means procedure 917scope static. One exception: in XCOFF, IBM's xlc compiler always uses 918`V', and whether it is file scope or not is distinguished by whether 919the stab is located within a function. 920 921 In a.out files, `N_STSYM' means the data section, `N_FUN' means the 922text section, and `N_LCSYM' means the bss section. For those systems 923with a read-only data section separate from the text section (Solaris), 924`N_ROSYM' means the read-only data section. 925 926 For example, the source lines: 927 928 static const int var_const = 5; 929 static int var_init = 2; 930 static int var_noinit; 931 932yield the following stabs: 933 934 .stabs "var_const:S1",36,0,0,_var_const # 36 is N_FUN 935 ... 936 .stabs "var_init:S1",38,0,0,_var_init # 38 is N_STSYM 937 ... 938 .stabs "var_noinit:S1",40,0,0,_var_noinit # 40 is N_LCSYM 939 940 In XCOFF files, the stab type need not indicate the section; 941`C_STSYM' can be used for all statics. Also, each static variable is 942enclosed in a static block. A `C_BSTAT' (emitted with a `.bs' 943assembler directive) symbol begins the static block; its value is the 944symbol number of the csect symbol whose value is the address of the 945static block, its section is the section of the variables in that 946static block, and its name is `.bs'. A `C_ESTAT' (emitted with a `.es' 947assembler directive) symbol ends the static block; its name is `.es' 948and its value and section are ignored. 949 950 In ECOFF files, the storage class is used to specify the section, so 951the stab type need not indicate the section. 952 953 In ELF files, for the SunPRO compiler version 2.0.1, symbol 954descriptor `S' means that the address is absolute (the linker relocates 955it) and symbol descriptor `V' means that the address is relative to the 956start of the relevant section for that compilation unit. SunPRO has 957plans to have the linker stop relocating stabs; I suspect that their the 958debugger gets the address from the corresponding ELF (not stab) symbol. 959I'm not sure how to find which symbol of that name is the right one. 960The clean way to do all this would be to have a the value of a symbol 961descriptor `S' symbol be an offset relative to the start of the file, 962just like everything else, but that introduces obvious compatibility 963problems. For more information on linker stab relocation, *Note ELF 964Linker Relocation::. 965 966 967File: stabs.info, Node: Based Variables, Next: Parameters, Prev: Statics, Up: Variables 968 969Fortran Based Variables 970======================= 971 972Fortran (at least, the Sun and SGI dialects of FORTRAN-77) has a feature 973which allows allocating arrays with `malloc', but which avoids blurring 974the line between arrays and pointers the way that C does. In stabs 975such a variable uses the `b' symbol descriptor. 976 977 For example, the Fortran declarations 978 979 real foo, foo10(10), foo10_5(10,5) 980 pointer (foop, foo) 981 pointer (foo10p, foo10) 982 pointer (foo105p, foo10_5) 983 984 produce the stabs 985 986 foo:b6 987 foo10:bar3;1;10;6 988 foo10_5:bar3;1;5;ar3;1;10;6 989 990 In this example, `real' is type 6 and type 3 is an integral type 991which is the type of the subscripts of the array (probably `integer'). 992 993 The `b' symbol descriptor is like `V' in that it denotes a 994statically allocated symbol whose scope is local to a function; see 995*Note Statics::. The value of the symbol, instead of being the address 996of the variable itself, is the address of a pointer to that variable. 997So in the above example, the value of the `foo' stab is the address of 998a pointer to a real, the value of the `foo10' stab is the address of a 999pointer to a 10-element array of reals, and the value of the `foo10_5' 1000stab is the address of a pointer to a 5-element array of 10-element 1001arrays of reals. 1002 1003 1004File: stabs.info, Node: Parameters, Prev: Based Variables, Up: Variables 1005 1006Parameters 1007========== 1008 1009Formal parameters to a function are represented by a stab (or sometimes 1010two; see below) for each parameter. The stabs are in the order in which 1011the debugger should print the parameters (i.e., the order in which the 1012parameters are declared in the source file). The exact form of the stab 1013depends on how the parameter is being passed. 1014 1015 Parameters passed on the stack use the symbol descriptor `p' and the 1016`N_PSYM' symbol type (or `C_PSYM' for XCOFF). The value of the symbol 1017is an offset used to locate the parameter on the stack; its exact 1018meaning is machine-dependent, but on most machines it is an offset from 1019the frame pointer. 1020 1021 As a simple example, the code: 1022 1023 main (argc, argv) 1024 int argc; 1025 char **argv; 1026 1027 produces the stabs: 1028 1029 .stabs "main:F1",36,0,0,_main # 36 is N_FUN 1030 .stabs "argc:p1",160,0,0,68 # 160 is N_PSYM 1031 .stabs "argv:p20=*21=*2",160,0,0,72 1032 1033 The type definition of `argv' is interesting because it contains 1034several type definitions. Type 21 is pointer to type 2 (char) and 1035`argv' (type 20) is pointer to type 21. 1036 1037 The following symbol descriptors are also said to go with `N_PSYM'. 1038The value of the symbol is said to be an offset from the argument 1039pointer (I'm not sure whether this is true or not). 1040 1041 pP (<<??>>) 1042 pF Fortran function parameter 1043 X (function result variable) 1044 1045* Menu: 1046 1047* Register Parameters:: 1048* Local Variable Parameters:: 1049* Reference Parameters:: 1050* Conformant Arrays:: 1051 1052 1053File: stabs.info, Node: Register Parameters, Next: Local Variable Parameters, Up: Parameters 1054 1055Passing Parameters in Registers 1056------------------------------- 1057 1058If the parameter is passed in a register, then traditionally there are 1059two symbols for each argument: 1060 1061 .stabs "arg:p1" . . . ; N_PSYM 1062 .stabs "arg:r1" . . . ; N_RSYM 1063 1064 Debuggers use the second one to find the value, and the first one to 1065know that it is an argument. 1066 1067 Because that approach is kind of ugly, some compilers use symbol 1068descriptor `P' or `R' to indicate an argument which is in a register. 1069Symbol type `C_RPSYM' is used in XCOFF and `N_RSYM' is used otherwise. 1070The symbol's value is the register number. `P' and `R' mean the same 1071thing; the difference is that `P' is a GNU invention and `R' is an IBM 1072(XCOFF) invention. As of version 4.9, GDB should handle either one. 1073 1074 There is at least one case where GCC uses a `p' and `r' pair rather 1075than `P'; this is where the argument is passed in the argument list and 1076then loaded into a register. 1077 1078 According to the AIX documentation, symbol descriptor `D' is for a 1079parameter passed in a floating point register. This seems 1080unnecessary--why not just use `R' with a register number which 1081indicates that it's a floating point register? I haven't verified 1082whether the system actually does what the documentation indicates. 1083 1084 On the sparc and hppa, for a `P' symbol whose type is a structure or 1085union, the register contains the address of the structure. On the 1086sparc, this is also true of a `p' and `r' pair (using Sun `cc') or a 1087`p' symbol. However, if a (small) structure is really in a register, 1088`r' is used. And, to top it all off, on the hppa it might be a 1089structure which was passed on the stack and loaded into a register and 1090for which there is a `p' and `r' pair! I believe that symbol 1091descriptor `i' is supposed to deal with this case (it is said to mean 1092"value parameter by reference, indirect access"; I don't know the 1093source for this information), but I don't know details or what 1094compilers or debuggers use it, if any (not GDB or GCC). It is not 1095clear to me whether this case needs to be dealt with differently than 1096parameters passed by reference (*note Reference Parameters::). 1097 1098 1099File: stabs.info, Node: Local Variable Parameters, Next: Reference Parameters, Prev: Register Parameters, Up: Parameters 1100 1101Storing Parameters as Local Variables 1102------------------------------------- 1103 1104There is a case similar to an argument in a register, which is an 1105argument that is actually stored as a local variable. Sometimes this 1106happens when the argument was passed in a register and then the compiler 1107stores it as a local variable. If possible, the compiler should claim 1108that it's in a register, but this isn't always done. 1109 1110 If a parameter is passed as one type and converted to a smaller type 1111by the prologue (for example, the parameter is declared as a `float', 1112but the calling conventions specify that it is passed as a `double'), 1113then GCC2 (sometimes) uses a pair of symbols. The first symbol uses 1114symbol descriptor `p' and the type which is passed. The second symbol 1115has the type and location which the parameter actually has after the 1116prologue. For example, suppose the following C code appears with no 1117prototypes involved: 1118 1119 void 1120 subr (f) 1121 float f; 1122 { 1123 1124 if `f' is passed as a double at stack offset 8, and the prologue 1125converts it to a float in register number 0, then the stabs look like: 1126 1127 .stabs "f:p13",160,0,3,8 # 160 is `N_PSYM', here 13 is `double' 1128 .stabs "f:r12",64,0,3,0 # 64 is `N_RSYM', here 12 is `float' 1129 1130 In both stabs 3 is the line number where `f' is declared (*note Line 1131Numbers::). 1132 1133 GCC, at least on the 960, has another solution to the same problem. 1134It uses a single `p' symbol descriptor for an argument which is stored 1135as a local variable but uses `N_LSYM' instead of `N_PSYM'. In this 1136case, the value of the symbol is an offset relative to the local 1137variables for that function, not relative to the arguments; on some 1138machines those are the same thing, but not on all. 1139 1140 On the VAX or on other machines in which the calling convention 1141includes the number of words of arguments actually passed, the debugger 1142(GDB at least) uses the parameter symbols to keep track of whether it 1143needs to print nameless arguments in addition to the formal parameters 1144which it has printed because each one has a stab. For example, in 1145 1146 extern int fprintf (FILE *stream, char *format, ...); 1147 ... 1148 fprintf (stdout, "%d\n", x); 1149 1150 there are stabs for `stream' and `format'. On most machines, the 1151debugger can only print those two arguments (because it has no way of 1152knowing that additional arguments were passed), but on the VAX or other 1153machines with a calling convention which indicates the number of words 1154of arguments, the debugger can print all three arguments. To do so, 1155the parameter symbol (symbol descriptor `p') (not necessarily `r' or 1156symbol descriptor omitted symbols) needs to contain the actual type as 1157passed (for example, `double' not `float' if it is passed as a double 1158and converted to a float). 1159 1160 1161File: stabs.info, Node: Reference Parameters, Next: Conformant Arrays, Prev: Local Variable Parameters, Up: Parameters 1162 1163Passing Parameters by Reference 1164------------------------------- 1165 1166If the parameter is passed by reference (e.g., Pascal `VAR' 1167parameters), then the symbol descriptor is `v' if it is in the argument 1168list, or `a' if it in a register. Other than the fact that these 1169contain the address of the parameter rather than the parameter itself, 1170they are identical to `p' and `R', respectively. I believe `a' is an 1171AIX invention; `v' is supported by all stabs-using systems as far as I 1172know. 1173 1174 1175File: stabs.info, Node: Conformant Arrays, Prev: Reference Parameters, Up: Parameters 1176 1177Passing Conformant Array Parameters 1178----------------------------------- 1179 1180Conformant arrays are a feature of Modula-2, and perhaps other 1181languages, in which the size of an array parameter is not known to the 1182called function until run-time. Such parameters have two stabs: a `x' 1183for the array itself, and a `C', which represents the size of the 1184array. The value of the `x' stab is the offset in the argument list 1185where the address of the array is stored (it this right? it is a 1186guess); the value of the `C' stab is the offset in the argument list 1187where the size of the array (in elements? in bytes?) is stored. 1188 1189 1190File: stabs.info, Node: Types, Next: Symbol Tables, Prev: Variables, Up: Top 1191 1192Defining Types 1193************** 1194 1195The examples so far have described types as references to previously 1196defined types, or defined in terms of subranges of or pointers to 1197previously defined types. This chapter describes the other type 1198descriptors that may follow the `=' in a type definition. 1199 1200* Menu: 1201 1202* Builtin Types:: Integers, floating point, void, etc. 1203* Miscellaneous Types:: Pointers, sets, files, etc. 1204* Cross-References:: Referring to a type not yet defined. 1205* Subranges:: A type with a specific range. 1206* Arrays:: An aggregate type of same-typed elements. 1207* Strings:: Like an array but also has a length. 1208* Enumerations:: Like an integer but the values have names. 1209* Structures:: An aggregate type of different-typed elements. 1210* Typedefs:: Giving a type a name. 1211* Unions:: Different types sharing storage. 1212* Function Types:: 1213 1214 1215File: stabs.info, Node: Builtin Types, Next: Miscellaneous Types, Up: Types 1216 1217Builtin Types 1218============= 1219 1220Certain types are built in (`int', `short', `void', `float', etc.); the 1221debugger recognizes these types and knows how to handle them. Thus, 1222don't be surprised if some of the following ways of specifying builtin 1223types do not specify everything that a debugger would need to know 1224about the type--in some cases they merely specify enough information to 1225distinguish the type from other types. 1226 1227 The traditional way to define builtin types is convoluted, so new 1228ways have been invented to describe them. Sun's `acc' uses special 1229builtin type descriptors (`b' and `R'), and IBM uses negative type 1230numbers. GDB accepts all three ways, as of version 4.8; dbx just 1231accepts the traditional builtin types and perhaps one of the other two 1232formats. The following sections describe each of these formats. 1233 1234* Menu: 1235 1236* Traditional Builtin Types:: Put on your seat belts and prepare for kludgery 1237* Builtin Type Descriptors:: Builtin types with special type descriptors 1238* Negative Type Numbers:: Builtin types using negative type numbers 1239 1240 1241File: stabs.info, Node: Traditional Builtin Types, Next: Builtin Type Descriptors, Up: Builtin Types 1242 1243Traditional Builtin Types 1244------------------------- 1245 1246This is the traditional, convoluted method for defining builtin types. 1247There are several classes of such type definitions: integer, floating 1248point, and `void'. 1249 1250* Menu: 1251 1252* Traditional Integer Types:: 1253* Traditional Other Types:: 1254 1255 1256File: stabs.info, Node: Traditional Integer Types, Next: Traditional Other Types, Up: Traditional Builtin Types 1257 1258Traditional Integer Types 1259......................... 1260 1261Often types are defined as subranges of themselves. If the bounding 1262values fit within an `int', then they are given normally. For example: 1263 1264 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0 # 128 is N_LSYM 1265 .stabs "char:t2=r2;0;127;",128,0,0,0 1266 1267 Builtin types can also be described as subranges of `int': 1268 1269 .stabs "unsigned short:t6=r1;0;65535;",128,0,0,0 1270 1271 If the lower bound of a subrange is 0 and the upper bound is -1, the 1272type is an unsigned integral type whose bounds are too big to describe 1273in an `int'. Traditionally this is only used for `unsigned int' and 1274`unsigned long': 1275 1276 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0 1277 1278 For larger types, GCC 2.4.5 puts out bounds in octal, with one or 1279more leading zeroes. In this case a negative bound consists of a number 1280which is a 1 bit (for the sign bit) followed by a 0 bit for each bit in 1281the number (except the sign bit), and a positive bound is one which is a 12821 bit for each bit in the number (except possibly the sign bit). All 1283known versions of dbx and GDB version 4 accept this (at least in the 1284sense of not refusing to process the file), but GDB 3.5 refuses to read 1285the whole file containing such symbols. So GCC 2.3.3 did not output the 1286proper size for these types. As an example of octal bounds, the string 1287fields of the stabs for 64 bit integer types look like: 1288 1289 long int:t3=r1;001000000000000000000000;000777777777777777777777; 1290 long unsigned int:t5=r1;000000000000000000000000;001777777777777777777777; 1291 1292 If the lower bound of a subrange is 0 and the upper bound is 1293negative, the type is an unsigned integral type whose size in bytes is 1294the absolute value of the upper bound. I believe this is a Convex 1295convention for `unsigned long long'. 1296 1297 If the lower bound of a subrange is negative and the upper bound is 12980, the type is a signed integral type whose size in bytes is the 1299absolute value of the lower bound. I believe this is a Convex 1300convention for `long long'. To distinguish this from a legitimate 1301subrange, the type should be a subrange of itself. I'm not sure whether 1302this is the case for Convex. 1303 1304 1305File: stabs.info, Node: Traditional Other Types, Prev: Traditional Integer Types, Up: Traditional Builtin Types 1306 1307Traditional Other Types 1308....................... 1309 1310If the upper bound of a subrange is 0 and the lower bound is positive, 1311the type is a floating point type, and the lower bound of the subrange 1312indicates the number of bytes in the type: 1313 1314 .stabs "float:t12=r1;4;0;",128,0,0,0 1315 .stabs "double:t13=r1;8;0;",128,0,0,0 1316 1317 However, GCC writes `long double' the same way it writes `double', 1318so there is no way to distinguish. 1319 1320 .stabs "long double:t14=r1;8;0;",128,0,0,0 1321 1322 Complex types are defined the same way as floating-point types; 1323there is no way to distinguish a single-precision complex from a 1324double-precision floating-point type. 1325 1326 The C `void' type is defined as itself: 1327 1328 .stabs "void:t15=15",128,0,0,0 1329 1330 I'm not sure how a boolean type is represented. 1331 1332 1333File: stabs.info, Node: Builtin Type Descriptors, Next: Negative Type Numbers, Prev: Traditional Builtin Types, Up: Builtin Types 1334 1335Defining Builtin Types Using Builtin Type Descriptors 1336----------------------------------------------------- 1337 1338This is the method used by Sun's `acc' for defining builtin types. 1339These are the type descriptors to define builtin types: 1340 1341`b SIGNED CHAR-FLAG WIDTH ; OFFSET ; NBITS ;' 1342 Define an integral type. SIGNED is `u' for unsigned or `s' for 1343 signed. CHAR-FLAG is `c' which indicates this is a character 1344 type, or is omitted. I assume this is to distinguish an integral 1345 type from a character type of the same size, for example it might 1346 make sense to set it for the C type `wchar_t' so the debugger can 1347 print such variables differently (Solaris does not do this). Sun 1348 sets it on the C types `signed char' and `unsigned char' which 1349 arguably is wrong. WIDTH and OFFSET appear to be for small 1350 objects stored in larger ones, for example a `short' in an `int' 1351 register. WIDTH is normally the number of bytes in the type. 1352 OFFSET seems to always be zero. NBITS is the number of bits in 1353 the type. 1354 1355 Note that type descriptor `b' used for builtin types conflicts with 1356 its use for Pascal space types (*note Miscellaneous Types::); they 1357 can be distinguished because the character following the type 1358 descriptor will be a digit, `(', or `-' for a Pascal space type, or 1359 `u' or `s' for a builtin type. 1360 1361`w' 1362 Documented by AIX to define a wide character type, but their 1363 compiler actually uses negative type numbers (*note Negative Type 1364 Numbers::). 1365 1366`R FP-TYPE ; BYTES ;' 1367 Define a floating point type. FP-TYPE has one of the following 1368 values: 1369 1370 `1 (NF_SINGLE)' 1371 IEEE 32-bit (single precision) floating point format. 1372 1373 `2 (NF_DOUBLE)' 1374 IEEE 64-bit (double precision) floating point format. 1375 1376 `3 (NF_COMPLEX)' 1377 1378 `4 (NF_COMPLEX16)' 1379 1380 `5 (NF_COMPLEX32)' 1381 These are for complex numbers. A comment in the GDB source 1382 describes them as Fortran `complex', `double complex', and 1383 `complex*16', respectively, but what does that mean? (i.e., 1384 Single precision? Double precision?). 1385 1386 `6 (NF_LDOUBLE)' 1387 Long double. This should probably only be used for Sun format 1388 `long double', and new codes should be used for other floating 1389 point formats (`NF_DOUBLE' can be used if a `long double' is 1390 really just an IEEE double, of course). 1391 1392 BYTES is the number of bytes occupied by the type. This allows a 1393 debugger to perform some operations with the type even if it 1394 doesn't understand FP-TYPE. 1395 1396`g TYPE-INFORMATION ; NBITS' 1397 Documented by AIX to define a floating type, but their compiler 1398 actually uses negative type numbers (*note Negative Type 1399 Numbers::). 1400 1401`c TYPE-INFORMATION ; NBITS' 1402 Documented by AIX to define a complex type, but their compiler 1403 actually uses negative type numbers (*note Negative Type 1404 Numbers::). 1405 1406 The C `void' type is defined as a signed integral type 0 bits long: 1407 .stabs "void:t19=bs0;0;0",128,0,0,0 1408 The Solaris compiler seems to omit the trailing semicolon in this 1409case. Getting sloppy in this way is not a swift move because if a type 1410is embedded in a more complex expression it is necessary to be able to 1411tell where it ends. 1412 1413 I'm not sure how a boolean type is represented. 1414 1415 1416File: stabs.info, Node: Negative Type Numbers, Prev: Builtin Type Descriptors, Up: Builtin Types 1417 1418Negative Type Numbers 1419--------------------- 1420 1421This is the method used in XCOFF for defining builtin types. Since the 1422debugger knows about the builtin types anyway, the idea of negative 1423type numbers is simply to give a special type number which indicates 1424the builtin type. There is no stab defining these types. 1425 1426 There are several subtle issues with negative type numbers. 1427 1428 One is the size of the type. A builtin type (for example the C types 1429`int' or `long') might have different sizes depending on compiler 1430options, the target architecture, the ABI, etc. This issue doesn't 1431come up for IBM tools since (so far) they just target the RS/6000; the 1432sizes indicated below for each size are what the IBM RS/6000 tools use. 1433To deal with differing sizes, either define separate negative type 1434numbers for each size (which works but requires changing the debugger, 1435and, unless you get both AIX dbx and GDB to accept the change, 1436introduces an incompatibility), or use a type attribute (*note String 1437Field::) to define a new type with the appropriate size (which merely 1438requires a debugger which understands type attributes, like AIX dbx or 1439GDB). For example, 1440 1441 .stabs "boolean:t10=@s8;-16",128,0,0,0 1442 1443 defines an 8-bit boolean type, and 1444 1445 .stabs "boolean:t10=@s64;-16",128,0,0,0 1446 1447 defines a 64-bit boolean type. 1448 1449 A similar issue is the format of the type. This comes up most often 1450for floating-point types, which could have various formats (particularly 1451extended doubles, which vary quite a bit even among IEEE systems). 1452Again, it is best to define a new negative type number for each 1453different format; changing the format based on the target system has 1454various problems. One such problem is that the Alpha has both VAX and 1455IEEE floating types. One can easily imagine one library using the VAX 1456types and another library in the same executable using the IEEE types. 1457Another example is that the interpretation of whether a boolean is true 1458or false can be based on the least significant bit, most significant 1459bit, whether it is zero, etc., and different compilers (or different 1460options to the same compiler) might provide different kinds of boolean. 1461 1462 The last major issue is the names of the types. The name of a given 1463type depends _only_ on the negative type number given; these do not 1464vary depending on the language, the target system, or anything else. 1465One can always define separate type numbers--in the following list you 1466will see for example separate `int' and `integer*4' types which are 1467identical except for the name. But compatibility can be maintained by 1468not inventing new negative type numbers and instead just defining a new 1469type with a new name. For example: 1470 1471 .stabs "CARDINAL:t10=-8",128,0,0,0 1472 1473 Here is the list of negative type numbers. The phrase "integral 1474type" is used to mean twos-complement (I strongly suspect that all 1475machines which use stabs use twos-complement; most machines use 1476twos-complement these days). 1477 1478`-1' 1479 `int', 32 bit signed integral type. 1480 1481`-2' 1482 `char', 8 bit type holding a character. Both GDB and dbx on AIX 1483 treat this as signed. GCC uses this type whether `char' is signed 1484 or not, which seems like a bad idea. The AIX compiler (`xlc') 1485 seems to avoid this type; it uses -5 instead for `char'. 1486 1487`-3' 1488 `short', 16 bit signed integral type. 1489 1490`-4' 1491 `long', 32 bit signed integral type. 1492 1493`-5' 1494 `unsigned char', 8 bit unsigned integral type. 1495 1496`-6' 1497 `signed char', 8 bit signed integral type. 1498 1499`-7' 1500 `unsigned short', 16 bit unsigned integral type. 1501 1502`-8' 1503 `unsigned int', 32 bit unsigned integral type. 1504 1505`-9' 1506 `unsigned', 32 bit unsigned integral type. 1507 1508`-10' 1509 `unsigned long', 32 bit unsigned integral type. 1510 1511`-11' 1512 `void', type indicating the lack of a value. 1513 1514`-12' 1515 `float', IEEE single precision. 1516 1517`-13' 1518 `double', IEEE double precision. 1519 1520`-14' 1521 `long double', IEEE double precision. The compiler claims the size 1522 will increase in a future release, and for binary compatibility 1523 you have to avoid using `long double'. I hope when they increase 1524 it they use a new negative type number. 1525 1526`-15' 1527 `integer'. 32 bit signed integral type. 1528 1529`-16' 1530 `boolean'. 32 bit type. GDB and GCC assume that zero is false, 1531 one is true, and other values have unspecified meaning. I hope 1532 this agrees with how the IBM tools use the type. 1533 1534`-17' 1535 `short real'. IEEE single precision. 1536 1537`-18' 1538 `real'. IEEE double precision. 1539 1540`-19' 1541 `stringptr'. *Note Strings::. 1542 1543`-20' 1544 `character', 8 bit unsigned character type. 1545 1546`-21' 1547 `logical*1', 8 bit type. This Fortran type has a split 1548 personality in that it is used for boolean variables, but can also 1549 be used for unsigned integers. 0 is false, 1 is true, and other 1550 values are non-boolean. 1551 1552`-22' 1553 `logical*2', 16 bit type. This Fortran type has a split 1554 personality in that it is used for boolean variables, but can also 1555 be used for unsigned integers. 0 is false, 1 is true, and other 1556 values are non-boolean. 1557 1558`-23' 1559 `logical*4', 32 bit type. This Fortran type has a split 1560 personality in that it is used for boolean variables, but can also 1561 be used for unsigned integers. 0 is false, 1 is true, and other 1562 values are non-boolean. 1563 1564`-24' 1565 `logical', 32 bit type. This Fortran type has a split personality 1566 in that it is used for boolean variables, but can also be used for 1567 unsigned integers. 0 is false, 1 is true, and other values are 1568 non-boolean. 1569 1570`-25' 1571 `complex'. A complex type consisting of two IEEE single-precision 1572 floating point values. 1573 1574`-26' 1575 `complex'. A complex type consisting of two IEEE double-precision 1576 floating point values. 1577 1578`-27' 1579 `integer*1', 8 bit signed integral type. 1580 1581`-28' 1582 `integer*2', 16 bit signed integral type. 1583 1584`-29' 1585 `integer*4', 32 bit signed integral type. 1586 1587`-30' 1588 `wchar'. Wide character, 16 bits wide, unsigned (what format? 1589 Unicode?). 1590 1591`-31' 1592 `long long', 64 bit signed integral type. 1593 1594`-32' 1595 `unsigned long long', 64 bit unsigned integral type. 1596 1597`-33' 1598 `logical*8', 64 bit unsigned integral type. 1599 1600`-34' 1601 `integer*8', 64 bit signed integral type. 1602 1603 1604File: stabs.info, Node: Miscellaneous Types, Next: Cross-References, Prev: Builtin Types, Up: Types 1605 1606Miscellaneous Types 1607=================== 1608 1609`b TYPE-INFORMATION ; BYTES' 1610 Pascal space type. This is documented by IBM; what does it mean? 1611 1612 This use of the `b' type descriptor can be distinguished from its 1613 use for builtin integral types (*note Builtin Type Descriptors::) 1614 because the character following the type descriptor is always a 1615 digit, `(', or `-'. 1616 1617`B TYPE-INFORMATION' 1618 A volatile-qualified version of TYPE-INFORMATION. This is a Sun 1619 extension. References and stores to a variable with a 1620 volatile-qualified type must not be optimized or cached; they must 1621 occur as the user specifies them. 1622 1623`d TYPE-INFORMATION' 1624 File of type TYPE-INFORMATION. As far as I know this is only used 1625 by Pascal. 1626 1627`k TYPE-INFORMATION' 1628 A const-qualified version of TYPE-INFORMATION. This is a Sun 1629 extension. A variable with a const-qualified type cannot be 1630 modified. 1631 1632`M TYPE-INFORMATION ; LENGTH' 1633 Multiple instance type. The type seems to composed of LENGTH 1634 repetitions of TYPE-INFORMATION, for example `character*3' is 1635 represented by `M-2;3', where `-2' is a reference to a character 1636 type (*note Negative Type Numbers::). I'm not sure how this 1637 differs from an array. This appears to be a Fortran feature. 1638 LENGTH is a bound, like those in range types; see *Note 1639 Subranges::. 1640 1641`S TYPE-INFORMATION' 1642 Pascal set type. TYPE-INFORMATION must be a small type such as an 1643 enumeration or a subrange, and the type is a bitmask whose length 1644 is specified by the number of elements in TYPE-INFORMATION. 1645 1646 In CHILL, if it is a bitstring instead of a set, also use the `S' 1647 type attribute (*note String Field::). 1648 1649`* TYPE-INFORMATION' 1650 Pointer to TYPE-INFORMATION. 1651 1652 1653File: stabs.info, Node: Cross-References, Next: Subranges, Prev: Miscellaneous Types, Up: Types 1654 1655Cross-References to Other Types 1656=============================== 1657 1658A type can be used before it is defined; one common way to deal with 1659that situation is just to use a type reference to a type which has not 1660yet been defined. 1661 1662 Another way is with the `x' type descriptor, which is followed by 1663`s' for a structure tag, `u' for a union tag, or `e' for a enumerator 1664tag, followed by the name of the tag, followed by `:'. If the name 1665contains `::' between a `<' and `>' pair (for C++ templates), such a 1666`::' does not end the name--only a single `:' ends the name; see *Note 1667Nested Symbols::. 1668 1669 For example, the following C declarations: 1670 1671 struct foo; 1672 struct foo *bar; 1673 1674produce: 1675 1676 .stabs "bar:G16=*17=xsfoo:",32,0,0,0 1677 1678 Not all debuggers support the `x' type descriptor, so on some 1679machines GCC does not use it. I believe that for the above example it 1680would just emit a reference to type 17 and never define it, but I 1681haven't verified that. 1682 1683 Modula-2 imported types, at least on AIX, use the `i' type 1684descriptor, which is followed by the name of the module from which the 1685type is imported, followed by `:', followed by the name of the type. 1686There is then optionally a comma followed by type information for the 1687type. This differs from merely naming the type (*note Typedefs::) in 1688that it identifies the module; I don't understand whether the name of 1689the type given here is always just the same as the name we are giving 1690it, or whether this type descriptor is used with a nameless stab (*note 1691String Field::), or what. The symbol ends with `;'. 1692 1693 1694File: stabs.info, Node: Subranges, Next: Arrays, Prev: Cross-References, Up: Types 1695 1696Subrange Types 1697============== 1698 1699The `r' type descriptor defines a type as a subrange of another type. 1700It is followed by type information for the type of which it is a 1701subrange, a semicolon, an integral lower bound, a semicolon, an 1702integral upper bound, and a semicolon. The AIX documentation does not 1703specify the trailing semicolon, in an effort to specify array indexes 1704more cleanly, but a subrange which is not an array index has always 1705included a trailing semicolon (*note Arrays::). 1706 1707 Instead of an integer, either bound can be one of the following: 1708 1709`A OFFSET' 1710 The bound is passed by reference on the stack at offset OFFSET 1711 from the argument list. *Note Parameters::, for more information 1712 on such offsets. 1713 1714`T OFFSET' 1715 The bound is passed by value on the stack at offset OFFSET from 1716 the argument list. 1717 1718`a REGISTER-NUMBER' 1719 The bound is passed by reference in register number 1720 REGISTER-NUMBER. 1721 1722`t REGISTER-NUMBER' 1723 The bound is passed by value in register number REGISTER-NUMBER. 1724 1725`J' 1726 There is no bound. 1727 1728 Subranges are also used for builtin types; see *Note Traditional 1729Builtin Types::. 1730 1731 1732File: stabs.info, Node: Arrays, Next: Strings, Prev: Subranges, Up: Types 1733 1734Array Types 1735=========== 1736 1737Arrays use the `a' type descriptor. Following the type descriptor is 1738the type of the index and the type of the array elements. If the index 1739type is a range type, it ends in a semicolon; otherwise (for example, 1740if it is a type reference), there does not appear to be any way to tell 1741where the types are separated. In an effort to clean up this mess, IBM 1742documents the two types as being separated by a semicolon, and a range 1743type as not ending in a semicolon (but this is not right for range 1744types which are not array indexes, *note Subranges::). I think 1745probably the best solution is to specify that a semicolon ends a range 1746type, and that the index type and element type of an array are 1747separated by a semicolon, but that if the index type is a range type, 1748the extra semicolon can be omitted. GDB (at least through version 4.9) 1749doesn't support any kind of index type other than a range anyway; I'm 1750not sure about dbx. 1751 1752 It is well established, and widely used, that the type of the index, 1753unlike most types found in the stabs, is merely a type definition, not 1754type information (*note String Field::) (that is, it need not start with 1755`TYPE-NUMBER=' if it is defining a new type). According to a comment 1756in GDB, this is also true of the type of the array elements; it gives 1757`ar1;1;10;ar1;1;10;4' as a legitimate way to express a two dimensional 1758array. According to AIX documentation, the element type must be type 1759information. GDB accepts either. 1760 1761 The type of the index is often a range type, expressed as the type 1762descriptor `r' and some parameters. It defines the size of the array. 1763In the example below, the range `r1;0;2;' defines an index type which 1764is a subrange of type 1 (integer), with a lower bound of 0 and an upper 1765bound of 2. This defines the valid range of subscripts of a 1766three-element C array. 1767 1768 For example, the definition: 1769 1770 char char_vec[3] = {'a','b','c'}; 1771 1772produces the output: 1773 1774 .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0 1775 .global _char_vec 1776 .align 4 1777 _char_vec: 1778 .byte 97 1779 .byte 98 1780 .byte 99 1781 1782 If an array is "packed", the elements are spaced more closely than 1783normal, saving memory at the expense of speed. For example, an array 1784of 3-byte objects might, if unpacked, have each element aligned on a 17854-byte boundary, but if packed, have no padding. One way to specify 1786that something is packed is with type attributes (*note String 1787Field::). In the case of arrays, another is to use the `P' type 1788descriptor instead of `a'. Other than specifying a packed array, `P' 1789is identical to `a'. 1790 1791 An open array is represented by the `A' type descriptor followed by 1792type information specifying the type of the array elements. 1793 1794 An N-dimensional dynamic array is represented by 1795 1796 D DIMENSIONS ; TYPE-INFORMATION 1797 1798 DIMENSIONS is the number of dimensions; TYPE-INFORMATION specifies 1799the type of the array elements. 1800 1801 A subarray of an N-dimensional array is represented by 1802 1803 E DIMENSIONS ; TYPE-INFORMATION 1804 1805 DIMENSIONS is the number of dimensions; TYPE-INFORMATION specifies 1806the type of the array elements. 1807 1808 1809File: stabs.info, Node: Strings, Next: Enumerations, Prev: Arrays, Up: Types 1810 1811Strings 1812======= 1813 1814Some languages, like C or the original Pascal, do not have string types, 1815they just have related things like arrays of characters. But most 1816Pascals and various other languages have string types, which are 1817indicated as follows: 1818 1819`n TYPE-INFORMATION ; BYTES' 1820 BYTES is the maximum length. I'm not sure what TYPE-INFORMATION 1821 is; I suspect that it means that this is a string of 1822 TYPE-INFORMATION (thus allowing a string of integers, a string of 1823 wide characters, etc., as well as a string of characters). Not 1824 sure what the format of this type is. This is an AIX feature. 1825 1826`z TYPE-INFORMATION ; BYTES' 1827 Just like `n' except that this is a gstring, not an ordinary 1828 string. I don't know the difference. 1829 1830`N' 1831 Pascal Stringptr. What is this? This is an AIX feature. 1832 1833 Languages, such as CHILL which have a string type which is basically 1834just an array of characters use the `S' type attribute (*note String 1835Field::). 1836 1837 1838File: stabs.info, Node: Enumerations, Next: Structures, Prev: Strings, Up: Types 1839 1840Enumerations 1841============ 1842 1843Enumerations are defined with the `e' type descriptor. 1844 1845 The source line below declares an enumeration type at file scope. 1846The type definition is located after the `N_RBRAC' that marks the end of 1847the previous procedure's block scope, and before the `N_FUN' that marks 1848the beginning of the next procedure's block scope. Therefore it does 1849not describe a block local symbol, but a file local one. 1850 1851 The source line: 1852 1853 enum e_places {first,second=3,last}; 1854 1855generates the following stab: 1856 1857 .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0 1858 1859 The symbol descriptor (`T') says that the stab describes a 1860structure, enumeration, or union tag. The type descriptor `e', 1861following the `22=' of the type definition narrows it down to an 1862enumeration type. Following the `e' is a list of the elements of the 1863enumeration. The format is `NAME:VALUE,'. The list of elements ends 1864with `;'. The fact that VALUE is specified as an integer can cause 1865problems if the value is large. GCC 2.5.2 tries to output it in octal 1866in that case with a leading zero, which is probably a good thing, 1867although GDB 4.11 supports octal only in cases where decimal is 1868perfectly good. Negative decimal values are supported by both GDB and 1869dbx. 1870 1871 There is no standard way to specify the size of an enumeration type; 1872it is determined by the architecture (normally all enumerations types 1873are 32 bits). Type attributes can be used to specify an enumeration 1874type of another size for debuggers which support them; see *Note String 1875Field::. 1876 1877 Enumeration types are unusual in that they define symbols for the 1878enumeration values (`first', `second', and `third' in the above 1879example), and even though these symbols are visible in the file as a 1880whole (rather than being in a more local namespace like structure 1881member names), they are defined in the type definition for the 1882enumeration type rather than each having their own symbol. In order to 1883be fast, GDB will only get symbols from such types (in its initial scan 1884of the stabs) if the type is the first thing defined after a `T' or `t' 1885symbol descriptor (the above example fulfills this requirement). If 1886the type does not have a name, the compiler should emit it in a 1887nameless stab (*note String Field::); GCC does this. 1888 1889 1890File: stabs.info, Node: Structures, Next: Typedefs, Prev: Enumerations, Up: Types 1891 1892Structures 1893========== 1894 1895The encoding of structures in stabs can be shown with an example. 1896 1897 The following source code declares a structure tag and defines an 1898instance of the structure in global scope. Then a `typedef' equates the 1899structure tag with a new type. Separate stabs are generated for the 1900structure tag, the structure `typedef', and the structure instance. The 1901stabs for the tag and the `typedef' are emitted when the definitions are 1902encountered. Since the structure elements are not initialized, the 1903stab and code for the structure variable itself is located at the end 1904of the program in the bss section. 1905 1906 struct s_tag { 1907 int s_int; 1908 float s_float; 1909 char s_char_vec[8]; 1910 struct s_tag* s_next; 1911 } g_an_s; 1912 1913 typedef struct s_tag s_typedef; 1914 1915 The structure tag has an `N_LSYM' stab type because, like the 1916enumeration, the symbol has file scope. Like the enumeration, the 1917symbol descriptor is `T', for enumeration, structure, or tag type. The 1918type descriptor `s' following the `16=' of the type definition narrows 1919the symbol type to structure. 1920 1921 Following the `s' type descriptor is the number of bytes the 1922structure occupies, followed by a description of each structure element. 1923The structure element descriptions are of the form `NAME:TYPE, BIT 1924OFFSET FROM THE START OF THE STRUCT, NUMBER OF BITS IN THE ELEMENT'. 1925 1926 # 128 is N_LSYM 1927 .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32; 1928 s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0 1929 1930 In this example, the first two structure elements are previously 1931defined types. For these, the type following the `NAME:' part of the 1932element description is a simple type reference. The other two structure 1933elements are new types. In this case there is a type definition 1934embedded after the `NAME:'. The type definition for the array element 1935looks just like a type definition for a stand-alone array. The 1936`s_next' field is a pointer to the same kind of structure that the 1937field is an element of. So the definition of structure type 16 1938contains a type definition for an element which is a pointer to type 16. 1939 1940 If a field is a static member (this is a C++ feature in which a 1941single variable appears to be a field of every structure of a given 1942type) it still starts out with the field name, a colon, and the type, 1943but then instead of a comma, bit position, comma, and bit size, there 1944is a colon followed by the name of the variable which each such field 1945refers to. 1946 1947 If the structure has methods (a C++ feature), they follow the 1948non-method fields; see *Note Cplusplus::. 1949 1950 1951File: stabs.info, Node: Typedefs, Next: Unions, Prev: Structures, Up: Types 1952 1953Giving a Type a Name 1954==================== 1955 1956To give a type a name, use the `t' symbol descriptor. The type is 1957specified by the type information (*note String Field::) for the stab. 1958For example, 1959 1960 .stabs "s_typedef:t16",128,0,0,0 # 128 is N_LSYM 1961 1962 specifies that `s_typedef' refers to type number 16. Such stabs 1963have symbol type `N_LSYM' (or `C_DECL' for XCOFF). (The Sun 1964documentation mentions using `N_GSYM' in some cases). 1965 1966 If you are specifying the tag name for a structure, union, or 1967enumeration, use the `T' symbol descriptor instead. I believe C is the 1968only language with this feature. 1969 1970 If the type is an opaque type (I believe this is a Modula-2 feature), 1971AIX provides a type descriptor to specify it. The type descriptor is 1972`o' and is followed by a name. I don't know what the name means--is it 1973always the same as the name of the type, or is this type descriptor 1974used with a nameless stab (*note String Field::)? There optionally 1975follows a comma followed by type information which defines the type of 1976this type. If omitted, a semicolon is used in place of the comma and 1977the type information, and the type is much like a generic pointer 1978type--it has a known size but little else about it is specified. 1979 1980 1981File: stabs.info, Node: Unions, Next: Function Types, Prev: Typedefs, Up: Types 1982 1983Unions 1984====== 1985 1986 union u_tag { 1987 int u_int; 1988 float u_float; 1989 char* u_char; 1990 } an_u; 1991 1992 This code generates a stab for a union tag and a stab for a union 1993variable. Both use the `N_LSYM' stab type. If a union variable is 1994scoped locally to the procedure in which it is defined, its stab is 1995located immediately preceding the `N_LBRAC' for the procedure's block 1996start. 1997 1998 The stab for the union tag, however, is located preceding the code 1999for the procedure in which it is defined. The stab type is `N_LSYM'. 2000This would seem to imply that the union type is file scope, like the 2001struct type `s_tag'. This is not true. The contents and position of 2002the stab for `u_type' do not convey any information about its procedure 2003local scope. 2004 2005 # 128 is N_LSYM 2006 .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;", 2007 128,0,0,0 2008 2009 The symbol descriptor `T', following the `name:' means that the stab 2010describes an enumeration, structure, or union tag. The type descriptor 2011`u', following the `23=' of the type definition, narrows it down to a 2012union type definition. Following the `u' is the number of bytes in the 2013union. After that is a list of union element descriptions. Their 2014format is `NAME:TYPE, BIT OFFSET INTO THE UNION, NUMBER OF BYTES FOR 2015THE ELEMENT;'. 2016 2017 The stab for the union variable is: 2018 2019 .stabs "an_u:23",128,0,0,-20 # 128 is N_LSYM 2020 2021 `-20' specifies where the variable is stored (*note Stack 2022Variables::). 2023 2024 2025File: stabs.info, Node: Function Types, Prev: Unions, Up: Types 2026 2027Function Types 2028============== 2029 2030Various types can be defined for function variables. These types are 2031not used in defining functions (*note Procedures::); they are used for 2032things like pointers to functions. 2033 2034 The simple, traditional, type is type descriptor `f' is followed by 2035type information for the return type of the function, followed by a 2036semicolon. 2037 2038 This does not deal with functions for which the number and types of 2039the parameters are part of the type, as in Modula-2 or ANSI C. AIX 2040provides extensions to specify these, using the `f', `F', `p', and `R' 2041type descriptors. 2042 2043 First comes the type descriptor. If it is `f' or `F', this type 2044involves a function rather than a procedure, and the type information 2045for the return type of the function follows, followed by a comma. Then 2046comes the number of parameters to the function and a semicolon. Then, 2047for each parameter, there is the name of the parameter followed by a 2048colon (this is only present for type descriptors `R' and `F' which 2049represent Pascal function or procedure parameters), type information 2050for the parameter, a comma, 0 if passed by reference or 1 if passed by 2051value, and a semicolon. The type definition ends with a semicolon. 2052 2053 For example, this variable definition: 2054 2055 int (*g_pf)(); 2056 2057generates the following code: 2058 2059 .stabs "g_pf:G24=*25=f1",32,0,0,0 2060 .common _g_pf,4,"bss" 2061 2062 The variable defines a new type, 24, which is a pointer to another 2063new type, 25, which is a function returning `int'. 2064 2065 2066File: stabs.info, Node: Symbol Tables, Next: Cplusplus, Prev: Types, Up: Top 2067 2068Symbol Information in Symbol Tables 2069*********************************** 2070 2071This chapter describes the format of symbol table entries and how stab 2072assembler directives map to them. It also describes the 2073transformations that the assembler and linker make on data from stabs. 2074 2075* Menu: 2076 2077* Symbol Table Format:: 2078* Transformations On Symbol Tables:: 2079 2080 2081File: stabs.info, Node: Symbol Table Format, Next: Transformations On Symbol Tables, Up: Symbol Tables 2082 2083Symbol Table Format 2084=================== 2085 2086Each time the assembler encounters a stab directive, it puts each field 2087of the stab into a corresponding field in a symbol table entry of its 2088output file. If the stab contains a string field, the symbol table 2089entry for that stab points to a string table entry containing the 2090string data from the stab. Assembler labels become relocatable 2091addresses. Symbol table entries in a.out have the format: 2092 2093 struct internal_nlist { 2094 unsigned long n_strx; /* index into string table of name */ 2095 unsigned char n_type; /* type of symbol */ 2096 unsigned char n_other; /* misc info (usually empty) */ 2097 unsigned short n_desc; /* description field */ 2098 bfd_vma n_value; /* value of symbol */ 2099 }; 2100 2101 If the stab has a string, the `n_strx' field holds the offset in 2102bytes of the string within the string table. The string is terminated 2103by a NUL character. If the stab lacks a string (for example, it was 2104produced by a `.stabn' or `.stabd' directive), the `n_strx' field is 2105zero. 2106 2107 Symbol table entries with `n_type' field values greater than 0x1f 2108originated as stabs generated by the compiler (with one random 2109exception). The other entries were placed in the symbol table of the 2110executable by the assembler or the linker. 2111 2112 2113File: stabs.info, Node: Transformations On Symbol Tables, Prev: Symbol Table Format, Up: Symbol Tables 2114 2115Transformations on Symbol Tables 2116================================ 2117 2118The linker concatenates object files and does fixups of externally 2119defined symbols. 2120 2121 You can see the transformations made on stab data by the assembler 2122and linker by examining the symbol table after each pass of the build. 2123To do this, use `nm -ap', which dumps the symbol table, including 2124debugging information, unsorted. For stab entries the columns are: 2125VALUE, OTHER, DESC, TYPE, STRING. For assembler and linker symbols, 2126the columns are: VALUE, TYPE, STRING. 2127 2128 The low 5 bits of the stab type tell the linker how to relocate the 2129value of the stab. Thus for stab types like `N_RSYM' and `N_LSYM', 2130where the value is an offset or a register number, the low 5 bits are 2131`N_ABS', which tells the linker not to relocate the value. 2132 2133 Where the value of a stab contains an assembly language label, it is 2134transformed by each build step. The assembler turns it into a 2135relocatable address and the linker turns it into an absolute address. 2136 2137* Menu: 2138 2139* Transformations On Static Variables:: 2140* Transformations On Global Variables:: 2141* Stab Section Transformations:: For some object file formats, 2142 things are a bit different. 2143 2144 2145File: stabs.info, Node: Transformations On Static Variables, Next: Transformations On Global Variables, Up: Transformations On Symbol Tables 2146 2147Transformations on Static Variables 2148----------------------------------- 2149 2150This source line defines a static variable at file scope: 2151 2152 static int s_g_repeat 2153 2154The following stab describes the symbol: 2155 2156 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat 2157 2158The assembler transforms the stab into this symbol table entry in the 2159`.o' file. The location is expressed as a data segment offset. 2160 2161 00000084 - 00 0000 STSYM s_g_repeat:S1 2162 2163In the symbol table entry from the executable, the linker has made the 2164relocatable address absolute. 2165 2166 0000e00c - 00 0000 STSYM s_g_repeat:S1 2167 2168 2169File: stabs.info, Node: Transformations On Global Variables, Next: Stab Section Transformations, Prev: Transformations On Static Variables, Up: Transformations On Symbol Tables 2170 2171Transformations on Global Variables 2172----------------------------------- 2173 2174Stabs for global variables do not contain location information. In this 2175case, the debugger finds location information in the assembler or 2176linker symbol table entry describing the variable. The source line: 2177 2178 char g_foo = 'c'; 2179 2180generates the stab: 2181 2182 .stabs "g_foo:G2",32,0,0,0 2183 2184 The variable is represented by two symbol table entries in the object 2185file (see below). The first one originated as a stab. The second one 2186is an external symbol. The upper case `D' signifies that the `n_type' 2187field of the symbol table contains 7, `N_DATA' with local linkage. The 2188stab's value is zero since the value is not used for `N_GSYM' stabs. 2189The value of the linker symbol is the relocatable address corresponding 2190to the variable. 2191 2192 00000000 - 00 0000 GSYM g_foo:G2 2193 00000080 D _g_foo 2194 2195These entries as transformed by the linker. The linker symbol table 2196entry now holds an absolute address: 2197 2198 00000000 - 00 0000 GSYM g_foo:G2 2199 ... 2200 0000e008 D _g_foo 2201 2202 2203File: stabs.info, Node: Stab Section Transformations, Prev: Transformations On Global Variables, Up: Transformations On Symbol Tables 2204 2205Transformations of Stabs in separate sections 2206--------------------------------------------- 2207 2208For object file formats using stabs in separate sections (*note Stab 2209Sections::), use `objdump --stabs' instead of `nm' to show the stabs in 2210an object or executable file. `objdump' is a GNU utility; Sun does not 2211provide any equivalent. 2212 2213 The following example is for a stab whose value is an address is 2214relative to the compilation unit (*note ELF Linker Relocation::). For 2215example, if the source line 2216 2217 static int ld = 5; 2218 2219 appears within a function, then the assembly language output from the 2220compiler contains: 2221 2222 .Ddata.data: 2223 ... 2224 .stabs "ld:V(0,3)",0x26,0,4,.L18-Ddata.data # 0x26 is N_STSYM 2225 ... 2226 .L18: 2227 .align 4 2228 .word 0x5 2229 2230 Because the value is formed by subtracting one symbol from another, 2231the value is absolute, not relocatable, and so the object file contains 2232 2233 Symnum n_type n_othr n_desc n_value n_strx String 2234 31 STSYM 0 4 00000004 680 ld:V(0,3) 2235 2236 without any relocations, and the executable file also contains 2237 2238 Symnum n_type n_othr n_desc n_value n_strx String 2239 31 STSYM 0 4 00000004 680 ld:V(0,3) 2240 2241 2242File: stabs.info, Node: Cplusplus, Next: Stab Types, Prev: Symbol Tables, Up: Top 2243 2244GNU C++ Stabs 2245************* 2246 2247* Menu: 2248 2249* Class Names:: C++ class names are both tags and typedefs. 2250* Nested Symbols:: C++ symbol names can be within other types. 2251* Basic Cplusplus Types:: 2252* Simple Classes:: 2253* Class Instance:: 2254* Methods:: Method definition 2255* Method Type Descriptor:: The `#' type descriptor 2256* Member Type Descriptor:: The `@' type descriptor 2257* Protections:: 2258* Method Modifiers:: 2259* Virtual Methods:: 2260* Inheritance:: 2261* Virtual Base Classes:: 2262* Static Members:: 2263 2264 2265File: stabs.info, Node: Class Names, Next: Nested Symbols, Up: Cplusplus 2266 2267C++ Class Names 2268=============== 2269 2270In C++, a class name which is declared with `class', `struct', or 2271`union', is not only a tag, as in C, but also a type name. Thus there 2272should be stabs with both `t' and `T' symbol descriptors (*note 2273Typedefs::). 2274 2275 To save space, there is a special abbreviation for this case. If the 2276`T' symbol descriptor is followed by `t', then the stab defines both a 2277type name and a tag. 2278 2279 For example, the C++ code 2280 2281 struct foo {int x;}; 2282 2283 can be represented as either 2284 2285 .stabs "foo:T19=s4x:1,0,32;;",128,0,0,0 # 128 is N_LSYM 2286 .stabs "foo:t19",128,0,0,0 2287 2288 or 2289 2290 .stabs "foo:Tt19=s4x:1,0,32;;",128,0,0,0 2291 2292 2293File: stabs.info, Node: Nested Symbols, Next: Basic Cplusplus Types, Prev: Class Names, Up: Cplusplus 2294 2295Defining a Symbol Within Another Type 2296===================================== 2297 2298In C++, a symbol (such as a type name) can be defined within another 2299type. 2300 2301 In stabs, this is sometimes represented by making the name of a 2302symbol which contains `::'. Such a pair of colons does not end the name 2303of the symbol, the way a single colon would (*note String Field::). I'm 2304not sure how consistently used or well thought out this mechanism is. 2305So that a pair of colons in this position always has this meaning, `:' 2306cannot be used as a symbol descriptor. 2307 2308 For example, if the string for a stab is `foo::bar::baz:t5=*6', then 2309`foo::bar::baz' is the name of the symbol, `t' is the symbol 2310descriptor, and `5=*6' is the type information. 2311 2312 2313File: stabs.info, Node: Basic Cplusplus Types, Next: Simple Classes, Prev: Nested Symbols, Up: Cplusplus 2314 2315Basic Types For C++ 2316=================== 2317 2318<< the examples that follow are based on a01.C >> 2319 2320 C++ adds two more builtin types to the set defined for C. These are 2321the unknown type and the vtable record type. The unknown type, type 232216, is defined in terms of itself like the void type. 2323 2324 The vtable record type, type 17, is defined as a structure type and 2325then as a structure tag. The structure has four fields: delta, index, 2326pfn, and delta2. pfn is the function pointer. 2327 2328 << In boilerplate $vtbl_ptr_type, what are the fields delta, index, 2329and delta2 used for? >> 2330 2331 This basic type is present in all C++ programs even if there are no 2332virtual methods defined. 2333 2334 .stabs "struct_name:sym_desc(type)type_def(17)=type_desc(struct)struct_bytes(8) 2335 elem_name(delta):type_ref(short int),bit_offset(0),field_bits(16); 2336 elem_name(index):type_ref(short int),bit_offset(16),field_bits(16); 2337 elem_name(pfn):type_def(18)=type_desc(ptr to)type_ref(void), 2338 bit_offset(32),field_bits(32); 2339 elem_name(delta2):type_def(short int);bit_offset(32),field_bits(16);;" 2340 N_LSYM, NIL, NIL 2341 2342 .stabs "$vtbl_ptr_type:t17=s8 2343 delta:6,0,16;index:6,16,16;pfn:18=*15,32,32;delta2:6,32,16;;" 2344 ,128,0,0,0 2345 2346 .stabs "name:sym_dec(struct tag)type_ref($vtbl_ptr_type)",N_LSYM,NIL,NIL,NIL 2347 2348 .stabs "$vtbl_ptr_type:T17",128,0,0,0 2349 2350 2351File: stabs.info, Node: Simple Classes, Next: Class Instance, Prev: Basic Cplusplus Types, Up: Cplusplus 2352 2353Simple Class Definition 2354======================= 2355 2356The stabs describing C++ language features are an extension of the 2357stabs describing C. Stabs representing C++ class types elaborate 2358extensively on the stab format used to describe structure types in C. 2359Stabs representing class type variables look just like stabs 2360representing C language variables. 2361 2362 Consider the following very simple class definition. 2363 2364 class baseA { 2365 public: 2366 int Adat; 2367 int Ameth(int in, char other); 2368 }; 2369 2370 The class `baseA' is represented by two stabs. The first stab 2371describes the class as a structure type. The second stab describes a 2372structure tag of the class type. Both stabs are of stab type `N_LSYM'. 2373Since the stab is not located between an `N_FUN' and an `N_LBRAC' stab 2374this indicates that the class is defined at file scope. If it were, 2375then the `N_LSYM' would signify a local variable. 2376 2377 A stab describing a C++ class type is similar in format to a stab 2378describing a C struct, with each class member shown as a field in the 2379structure. The part of the struct format describing fields is expanded 2380to include extra information relevant to C++ class members. In 2381addition, if the class has multiple base classes or virtual functions 2382the struct format outside of the field parts is also augmented. 2383 2384 In this simple example the field part of the C++ class stab 2385representing member data looks just like the field part of a C struct 2386stab. The section on protections describes how its format is sometimes 2387extended for member data. 2388 2389 The field part of a C++ class stab representing a member function 2390differs substantially from the field part of a C struct stab. It still 2391begins with `name:' but then goes on to define a new type number for 2392the member function, describe its return type, its argument types, its 2393protection level, any qualifiers applied to the method definition, and 2394whether the method is virtual or not. If the method is virtual then 2395the method description goes on to give the vtable index of the method, 2396and the type number of the first base class defining the method. 2397 2398 When the field name is a method name it is followed by two colons 2399rather than one. This is followed by a new type definition for the 2400method. This is a number followed by an equal sign and the type of the 2401method. Normally this will be a type declared using the `#' type 2402descriptor; see *Note Method Type Descriptor::; static member functions 2403are declared using the `f' type descriptor instead; see *Note Function 2404Types::. 2405 2406 The format of an overloaded operator method name differs from that of 2407other methods. It is `op$::OPERATOR-NAME.' where OPERATOR-NAME is the 2408operator name such as `+' or `+='. The name ends with a period, and 2409any characters except the period can occur in the OPERATOR-NAME string. 2410 2411 The next part of the method description represents the arguments to 2412the method, preceded by a colon and ending with a semi-colon. The 2413types of the arguments are expressed in the same way argument types are 2414expressed in C++ name mangling. In this example an `int' and a `char' 2415map to `ic'. 2416 2417 This is followed by a number, a letter, and an asterisk or period, 2418followed by another semicolon. The number indicates the protections 2419that apply to the member function. Here the 2 means public. The 2420letter encodes any qualifier applied to the method definition. In this 2421case, `A' means that it is a normal function definition. The dot shows 2422that the method is not virtual. The sections that follow elaborate 2423further on these fields and describe the additional information present 2424for virtual methods. 2425 2426 .stabs "class_name:sym_desc(type)type_def(20)=type_desc(struct)struct_bytes(4) 2427 field_name(Adat):type(int),bit_offset(0),field_bits(32); 2428 2429 method_name(Ameth)::type_def(21)=type_desc(method)return_type(int); 2430 :arg_types(int char); 2431 protection(public)qualifier(normal)virtual(no);;" 2432 N_LSYM,NIL,NIL,NIL 2433 2434 .stabs "baseA:t20=s4Adat:1,0,32;Ameth::21=##1;:ic;2A.;;",128,0,0,0 2435 2436 .stabs "class_name:sym_desc(struct tag)",N_LSYM,NIL,NIL,NIL 2437 2438 .stabs "baseA:T20",128,0,0,0 2439 2440 2441File: stabs.info, Node: Class Instance, Next: Methods, Prev: Simple Classes, Up: Cplusplus 2442 2443Class Instance 2444============== 2445 2446As shown above, describing even a simple C++ class definition is 2447accomplished by massively extending the stab format used in C to 2448describe structure types. However, once the class is defined, C stabs 2449with no modifications can be used to describe class instances. The 2450following source: 2451 2452 main () { 2453 baseA AbaseA; 2454 } 2455 2456yields the following stab describing the class instance. It looks no 2457different from a standard C stab describing a local variable. 2458 2459 .stabs "name:type_ref(baseA)", N_LSYM, NIL, NIL, frame_ptr_offset 2460 2461 .stabs "AbaseA:20",128,0,0,-20 2462 2463 2464File: stabs.info, Node: Methods, Next: Method Type Descriptor, Prev: Class Instance, Up: Cplusplus 2465 2466Method Definition 2467================= 2468 2469The class definition shown above declares Ameth. The C++ source below 2470defines Ameth: 2471 2472 int 2473 baseA::Ameth(int in, char other) 2474 { 2475 return in; 2476 }; 2477 2478 This method definition yields three stabs following the code of the 2479method. One stab describes the method itself and following two describe 2480its parameters. Although there is only one formal argument all methods 2481have an implicit argument which is the `this' pointer. The `this' 2482pointer is a pointer to the object on which the method was called. Note 2483that the method name is mangled to encode the class name and argument 2484types. Name mangling is described in the ARM (`The Annotated C++ 2485Reference Manual', by Ellis and Stroustrup, ISBN 0-201-51459-1); 2486`gpcompare.texi' in Cygnus GCC distributions describes the differences 2487between GNU mangling and ARM mangling. 2488 2489 .stabs "name:symbol_descriptor(global function)return_type(int)", 2490 N_FUN, NIL, NIL, code_addr_of_method_start 2491 2492 .stabs "Ameth__5baseAic:F1",36,0,0,_Ameth__5baseAic 2493 2494 Here is the stab for the `this' pointer implicit argument. The name 2495of the `this' pointer is always `this'. Type 19, the `this' pointer is 2496defined as a pointer to type 20, `baseA', but a stab defining `baseA' 2497has not yet been emitted. Since the compiler knows it will be emitted 2498shortly, here it just outputs a cross reference to the undefined 2499symbol, by prefixing the symbol name with `xs'. 2500 2501 .stabs "name:sym_desc(register param)type_def(19)= 2502 type_desc(ptr to)type_ref(baseA)= 2503 type_desc(cross-reference to)baseA:",N_RSYM,NIL,NIL,register_number 2504 2505 .stabs "this:P19=*20=xsbaseA:",64,0,0,8 2506 2507 The stab for the explicit integer argument looks just like a 2508parameter to a C function. The last field of the stab is the offset 2509from the argument pointer, which in most systems is the same as the 2510frame pointer. 2511 2512 .stabs "name:sym_desc(value parameter)type_ref(int)", 2513 N_PSYM,NIL,NIL,offset_from_arg_ptr 2514 2515 .stabs "in:p1",160,0,0,72 2516 2517 << The examples that follow are based on A1.C >> 2518 2519 2520File: stabs.info, Node: Method Type Descriptor, Next: Member Type Descriptor, Prev: Methods, Up: Cplusplus 2521 2522The `#' Type Descriptor 2523======================= 2524 2525This is used to describe a class method. This is a function which takes 2526an extra argument as its first argument, for the `this' pointer. 2527 2528 If the `#' is immediately followed by another `#', the second one 2529will be followed by the return type and a semicolon. The class and 2530argument types are not specified, and must be determined by demangling 2531the name of the method if it is available. 2532 2533 Otherwise, the single `#' is followed by the class type, a comma, 2534the return type, a comma, and zero or more parameter types separated by 2535commas. The list of arguments is terminated by a semicolon. In the 2536debugging output generated by gcc, a final argument type of `void' 2537indicates a method which does not take a variable number of arguments. 2538If the final argument type of `void' does not appear, the method was 2539declared with an ellipsis. 2540 2541 Note that although such a type will normally be used to describe 2542fields in structures, unions, or classes, for at least some versions of 2543the compiler it can also be used in other contexts. 2544 2545 2546File: stabs.info, Node: Member Type Descriptor, Next: Protections, Prev: Method Type Descriptor, Up: Cplusplus 2547 2548The `@' Type Descriptor 2549======================= 2550 2551The `@' type descriptor is used together with the `*' type descriptor 2552for a pointer-to-non-static-member-data type. It is followed by type 2553information for the class (or union), a comma, and type information for 2554the member data. 2555 2556 The following C++ source: 2557 2558 typedef int A::*int_in_a; 2559 2560 generates the following stab: 2561 2562 .stabs "int_in_a:t20=*21=@19,1",128,0,0,0 2563 2564 Note that there is a conflict between this and type attributes 2565(*note String Field::); both use type descriptor `@'. Fortunately, the 2566`@' type descriptor used in this C++ sense always will be followed by a 2567digit, `(', or `-', and type attributes never start with those things. 2568 2569 2570File: stabs.info, Node: Protections, Next: Method Modifiers, Prev: Member Type Descriptor, Up: Cplusplus 2571 2572Protections 2573=========== 2574 2575In the simple class definition shown above all member data and 2576functions were publicly accessible. The example that follows contrasts 2577public, protected and privately accessible fields and shows how these 2578protections are encoded in C++ stabs. 2579 2580 If the character following the `FIELD-NAME:' part of the string is 2581`/', then the next character is the visibility. `0' means private, `1' 2582means protected, and `2' means public. Debuggers should ignore 2583visibility characters they do not recognize, and assume a reasonable 2584default (such as public) (GDB 4.11 does not, but this should be fixed 2585in the next GDB release). If no visibility is specified the field is 2586public. The visibility `9' means that the field has been optimized out 2587and is public (there is no way to specify an optimized out field with a 2588private or protected visibility). Visibility `9' is not supported by 2589GDB 4.11; this should be fixed in the next GDB release. 2590 2591 The following C++ source: 2592 2593 class vis { 2594 private: 2595 int priv; 2596 protected: 2597 char prot; 2598 public: 2599 float pub; 2600 }; 2601 2602generates the following stab: 2603 2604 # 128 is N_LSYM 2605 .stabs "vis:T19=s12priv:/01,0,32;prot:/12,32,8;pub:12,64,32;;",128,0,0,0 2606 2607 `vis:T19=s12' indicates that type number 19 is a 12 byte structure 2608named `vis' The `priv' field has public visibility (`/0'), type int 2609(`1'), and offset and size `,0,32;'. The `prot' field has protected 2610visibility (`/1'), type char (`2') and offset and size `,32,8;'. The 2611`pub' field has type float (`12'), and offset and size `,64,32;'. 2612 2613 Protections for member functions are signified by one digit embedded 2614in the field part of the stab describing the method. The digit is 0 if 2615private, 1 if protected and 2 if public. Consider the C++ class 2616definition below: 2617 2618 class all_methods { 2619 private: 2620 int priv_meth(int in){return in;}; 2621 protected: 2622 char protMeth(char in){return in;}; 2623 public: 2624 float pubMeth(float in){return in;}; 2625 }; 2626 2627 It generates the following stab. The digit in question is to the 2628left of an `A' in each case. Notice also that in this case two symbol 2629descriptors apply to the class name struct tag and struct type. 2630 2631 .stabs "class_name:sym_desc(struct tag&type)type_def(21)= 2632 sym_desc(struct)struct_bytes(1) 2633 meth_name::type_def(22)=sym_desc(method)returning(int); 2634 :args(int);protection(private)modifier(normal)virtual(no); 2635 meth_name::type_def(23)=sym_desc(method)returning(char); 2636 :args(char);protection(protected)modifier(normal)virtual(no); 2637 meth_name::type_def(24)=sym_desc(method)returning(float); 2638 :args(float);protection(public)modifier(normal)virtual(no);;", 2639 N_LSYM,NIL,NIL,NIL 2640 2641 .stabs "all_methods:Tt21=s1priv_meth::22=##1;:i;0A.;protMeth::23=##2;:c;1A.; 2642 pubMeth::24=##12;:f;2A.;;",128,0,0,0 2643 2644 2645File: stabs.info, Node: Method Modifiers, Next: Virtual Methods, Prev: Protections, Up: Cplusplus 2646 2647Method Modifiers (`const', `volatile', `const volatile') 2648======================================================== 2649 2650<< based on a6.C >> 2651 2652 In the class example described above all the methods have the normal 2653modifier. This method modifier information is located just after the 2654protection information for the method. This field has four possible 2655character values. Normal methods use `A', const methods use `B', 2656volatile methods use `C', and const volatile methods use `D'. Consider 2657the class definition below: 2658 2659 class A { 2660 public: 2661 int ConstMeth (int arg) const { return arg; }; 2662 char VolatileMeth (char arg) volatile { return arg; }; 2663 float ConstVolMeth (float arg) const volatile {return arg; }; 2664 }; 2665 2666 This class is described by the following stab: 2667 2668 .stabs "class(A):sym_desc(struct)type_def(20)=type_desc(struct)struct_bytes(1) 2669 meth_name(ConstMeth)::type_def(21)sym_desc(method) 2670 returning(int);:arg(int);protection(public)modifier(const)virtual(no); 2671 meth_name(VolatileMeth)::type_def(22)=sym_desc(method) 2672 returning(char);:arg(char);protection(public)modifier(volatile)virt(no) 2673 meth_name(ConstVolMeth)::type_def(23)=sym_desc(method) 2674 returning(float);:arg(float);protection(public)modifier(const volatile) 2675 virtual(no);;", ... 2676 2677 .stabs "A:T20=s1ConstMeth::21=##1;:i;2B.;VolatileMeth::22=##2;:c;2C.; 2678 ConstVolMeth::23=##12;:f;2D.;;",128,0,0,0 2679 2680 2681File: stabs.info, Node: Virtual Methods, Next: Inheritance, Prev: Method Modifiers, Up: Cplusplus 2682 2683Virtual Methods 2684=============== 2685 2686<< The following examples are based on a4.C >> 2687 2688 The presence of virtual methods in a class definition adds additional 2689data to the class description. The extra data is appended to the 2690description of the virtual method and to the end of the class 2691description. Consider the class definition below: 2692 2693 class A { 2694 public: 2695 int Adat; 2696 virtual int A_virt (int arg) { return arg; }; 2697 }; 2698 2699 This results in the stab below describing class A. It defines a new 2700type (20) which is an 8 byte structure. The first field of the class 2701struct is `Adat', an integer, starting at structure offset 0 and 2702occupying 32 bits. 2703 2704 The second field in the class struct is not explicitly defined by the 2705C++ class definition but is implied by the fact that the class contains 2706a virtual method. This field is the vtable pointer. The name of the 2707vtable pointer field starts with `$vf' and continues with a type 2708reference to the class it is part of. In this example the type 2709reference for class A is 20 so the name of its vtable pointer field is 2710`$vf20', followed by the usual colon. 2711 2712 Next there is a type definition for the vtable pointer type (21). 2713This is in turn defined as a pointer to another new type (22). 2714 2715 Type 22 is the vtable itself, which is defined as an array, indexed 2716by a range of integers between 0 and 1, and whose elements are of type 271717. Type 17 was the vtable record type defined by the boilerplate C++ 2718type definitions, as shown earlier. 2719 2720 The bit offset of the vtable pointer field is 32. The number of bits 2721in the field are not specified when the field is a vtable pointer. 2722 2723 Next is the method definition for the virtual member function 2724`A_virt'. Its description starts out using the same format as the 2725non-virtual member functions described above, except instead of a dot 2726after the `A' there is an asterisk, indicating that the function is 2727virtual. Since is is virtual some addition information is appended to 2728the end of the method description. 2729 2730 The first number represents the vtable index of the method. This is 2731a 32 bit unsigned number with the high bit set, followed by a 2732semi-colon. 2733 2734 The second number is a type reference to the first base class in the 2735inheritance hierarchy defining the virtual member function. In this 2736case the class stab describes a base class so the virtual function is 2737not overriding any other definition of the method. Therefore the 2738reference is to the type number of the class that the stab is 2739describing (20). 2740 2741 This is followed by three semi-colons. One marks the end of the 2742current sub-section, one marks the end of the method field, and the 2743third marks the end of the struct definition. 2744 2745 For classes containing virtual functions the very last section of the 2746string part of the stab holds a type reference to the first base class. 2747This is preceded by `~%' and followed by a final semi-colon. 2748 2749 .stabs "class_name(A):type_def(20)=sym_desc(struct)struct_bytes(8) 2750 field_name(Adat):type_ref(int),bit_offset(0),field_bits(32); 2751 field_name(A virt func ptr):type_def(21)=type_desc(ptr to)type_def(22)= 2752 sym_desc(array)index_type_ref(range of int from 0 to 1); 2753 elem_type_ref(vtbl elem type), 2754 bit_offset(32); 2755 meth_name(A_virt)::typedef(23)=sym_desc(method)returning(int); 2756 :arg_type(int),protection(public)normal(yes)virtual(yes) 2757 vtable_index(1);class_first_defining(A);;;~%first_base(A);", 2758 N_LSYM,NIL,NIL,NIL 2759 2760 .stabs "A:t20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32; 2761 A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0 2762 2763 2764File: stabs.info, Node: Inheritance, Next: Virtual Base Classes, Prev: Virtual Methods, Up: Cplusplus 2765 2766Inheritance 2767=========== 2768 2769Stabs describing C++ derived classes include additional sections that 2770describe the inheritance hierarchy of the class. A derived class stab 2771also encodes the number of base classes. For each base class it tells 2772if the base class is virtual or not, and if the inheritance is private 2773or public. It also gives the offset into the object of the portion of 2774the object corresponding to each base class. 2775 2776 This additional information is embedded in the class stab following 2777the number of bytes in the struct. First the number of base classes 2778appears bracketed by an exclamation point and a comma. 2779 2780 Then for each base type there repeats a series: a virtual character, 2781a visibility character, a number, a comma, another number, and a 2782semi-colon. 2783 2784 The virtual character is `1' if the base class is virtual and `0' if 2785not. The visibility character is `2' if the derivation is public, `1' 2786if it is protected, and `0' if it is private. Debuggers should ignore 2787virtual or visibility characters they do not recognize, and assume a 2788reasonable default (such as public and non-virtual) (GDB 4.11 does not, 2789but this should be fixed in the next GDB release). 2790 2791 The number following the virtual and visibility characters is the 2792offset from the start of the object to the part of the object 2793pertaining to the base class. 2794 2795 After the comma, the second number is a type_descriptor for the base 2796type. Finally a semi-colon ends the series, which repeats for each 2797base class. 2798 2799 The source below defines three base classes `A', `B', and `C' and 2800the derived class `D'. 2801 2802 class A { 2803 public: 2804 int Adat; 2805 virtual int A_virt (int arg) { return arg; }; 2806 }; 2807 2808 class B { 2809 public: 2810 int B_dat; 2811 virtual int B_virt (int arg) {return arg; }; 2812 }; 2813 2814 class C { 2815 public: 2816 int Cdat; 2817 virtual int C_virt (int arg) {return arg; }; 2818 }; 2819 2820 class D : A, virtual B, public C { 2821 public: 2822 int Ddat; 2823 virtual int A_virt (int arg ) { return arg+1; }; 2824 virtual int B_virt (int arg) { return arg+2; }; 2825 virtual int C_virt (int arg) { return arg+3; }; 2826 virtual int D_virt (int arg) { return arg; }; 2827 }; 2828 2829 Class stabs similar to the ones described earlier are generated for 2830each base class. 2831 2832 .stabs "A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32; 2833 A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0 2834 2835 .stabs "B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1; 2836 :i;2A*-2147483647;25;;;~%25;",128,0,0,0 2837 2838 .stabs "C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1; 2839 :i;2A*-2147483647;28;;;~%28;",128,0,0,0 2840 2841 In the stab describing derived class `D' below, the information about 2842the derivation of this class is encoded as follows. 2843 2844 .stabs "derived_class_name:symbol_descriptors(struct tag&type)= 2845 type_descriptor(struct)struct_bytes(32)!num_bases(3), 2846 base_virtual(no)inheritance_public(no)base_offset(0), 2847 base_class_type_ref(A); 2848 base_virtual(yes)inheritance_public(no)base_offset(NIL), 2849 base_class_type_ref(B); 2850 base_virtual(no)inheritance_public(yes)base_offset(64), 2851 base_class_type_ref(C); ... 2852 2853 .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat: 2854 1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt: 2855 :32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647; 2856 28;;D_virt::32:i;2A*-2147483646;31;;;~%20;",128,0,0,0 2857 2858 2859File: stabs.info, Node: Virtual Base Classes, Next: Static Members, Prev: Inheritance, Up: Cplusplus 2860 2861Virtual Base Classes 2862==================== 2863 2864A derived class object consists of a concatenation in memory of the data 2865areas defined by each base class, starting with the leftmost and ending 2866with the rightmost in the list of base classes. The exception to this 2867rule is for virtual inheritance. In the example above, class `D' 2868inherits virtually from base class `B'. This means that an instance of 2869a `D' object will not contain its own `B' part but merely a pointer to 2870a `B' part, known as a virtual base pointer. 2871 2872 In a derived class stab, the base offset part of the derivation 2873information, described above, shows how the base class parts are 2874ordered. The base offset for a virtual base class is always given as 0. 2875Notice that the base offset for `B' is given as 0 even though `B' is 2876not the first base class. The first base class `A' starts at offset 0. 2877 2878 The field information part of the stab for class `D' describes the 2879field which is the pointer to the virtual base class `B'. The vbase 2880pointer name is `$vb' followed by a type reference to the virtual base 2881class. Since the type id for `B' in this example is 25, the vbase 2882pointer name is `$vb25'. 2883 2884 .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1, 2885 160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i; 2886 2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt: 2887 :32:i;2A*-2147483646;31;;;~%20;",128,0,0,0 2888 2889 Following the name and a semicolon is a type reference describing the 2890type of the virtual base class pointer, in this case 24. Type 24 was 2891defined earlier as the type of the `B' class `this' pointer. The 2892`this' pointer for a class is a pointer to the class type. 2893 2894 .stabs "this:P24=*25=xsB:",64,0,0,8 2895 2896 Finally the field offset part of the vbase pointer field description 2897shows that the vbase pointer is the first field in the `D' object, 2898before any data fields defined by the class. The layout of a `D' class 2899object is a follows, `Adat' at 0, the vtable pointer for `A' at 32, 2900`Cdat' at 64, the vtable pointer for C at 96, the virtual base pointer 2901for `B' at 128, and `Ddat' at 160. 2902 2903 2904File: stabs.info, Node: Static Members, Prev: Virtual Base Classes, Up: Cplusplus 2905 2906Static Members 2907============== 2908 2909The data area for a class is a concatenation of the space used by the 2910data members of the class. If the class has virtual methods, a vtable 2911pointer follows the class data. The field offset part of each field 2912description in the class stab shows this ordering. 2913 2914 << How is this reflected in stabs? See Cygnus bug #677 for some 2915info. >> 2916 2917 2918File: stabs.info, Node: Stab Types, Next: Symbol Descriptors, Prev: Cplusplus, Up: Top 2919 2920Table of Stab Types 2921******************* 2922 2923The following are all the possible values for the stab type field, for 2924a.out files, in numeric order. This does not apply to XCOFF, but it 2925does apply to stabs in sections (*note Stab Sections::). Stabs in 2926ECOFF use these values but add 0x8f300 to distinguish them from non-stab 2927symbols. 2928 2929 The symbolic names are defined in the file `include/aout/stabs.def'. 2930 2931* Menu: 2932 2933* Non-Stab Symbol Types:: Types from 0 to 0x1f 2934* Stab Symbol Types:: Types from 0x20 to 0xff 2935 2936 2937File: stabs.info, Node: Non-Stab Symbol Types, Next: Stab Symbol Types, Up: Stab Types 2938 2939Non-Stab Symbol Types 2940===================== 2941 2942The following types are used by the linker and assembler, not by stab 2943directives. Since this document does not attempt to describe aspects of 2944object file format other than the debugging format, no details are 2945given. 2946 2947`0x0 N_UNDF' 2948 Undefined symbol 2949 2950`0x2 N_ABS' 2951 File scope absolute symbol 2952 2953`0x3 N_ABS | N_EXT' 2954 External absolute symbol 2955 2956`0x4 N_TEXT' 2957 File scope text symbol 2958 2959`0x5 N_TEXT | N_EXT' 2960 External text symbol 2961 2962`0x6 N_DATA' 2963 File scope data symbol 2964 2965`0x7 N_DATA | N_EXT' 2966 External data symbol 2967 2968`0x8 N_BSS' 2969 File scope BSS symbol 2970 2971`0x9 N_BSS | N_EXT' 2972 External BSS symbol 2973 2974`0x0c N_FN_SEQ' 2975 Same as `N_FN', for Sequent compilers 2976 2977`0x0a N_INDR' 2978 Symbol is indirected to another symbol 2979 2980`0x12 N_COMM' 2981 Common--visible after shared library dynamic link 2982 2983`0x14 N_SETA' 2984`0x15 N_SETA | N_EXT' 2985 Absolute set element 2986 2987`0x16 N_SETT' 2988`0x17 N_SETT | N_EXT' 2989 Text segment set element 2990 2991`0x18 N_SETD' 2992`0x19 N_SETD | N_EXT' 2993 Data segment set element 2994 2995`0x1a N_SETB' 2996`0x1b N_SETB | N_EXT' 2997 BSS segment set element 2998 2999`0x1c N_SETV' 3000`0x1d N_SETV | N_EXT' 3001 Pointer to set vector 3002 3003`0x1e N_WARNING' 3004 Print a warning message during linking 3005 3006`0x1f N_FN' 3007 File name of a `.o' file 3008 3009 3010File: stabs.info, Node: Stab Symbol Types, Prev: Non-Stab Symbol Types, Up: Stab Types 3011 3012Stab Symbol Types 3013================= 3014 3015The following symbol types indicate that this is a stab. This is the 3016full list of stab numbers, including stab types that are used in 3017languages other than C. 3018 3019`0x20 N_GSYM' 3020 Global symbol; see *Note Global Variables::. 3021 3022`0x22 N_FNAME' 3023 Function name (for BSD Fortran); see *Note Procedures::. 3024 3025`0x24 N_FUN' 3026 Function name (*note Procedures::) or text segment variable (*note 3027 Statics::). 3028 3029`0x26 N_STSYM' 3030 Data segment file-scope variable; see *Note Statics::. 3031 3032`0x28 N_LCSYM' 3033 BSS segment file-scope variable; see *Note Statics::. 3034 3035`0x2a N_MAIN' 3036 Name of main routine; see *Note Main Program::. 3037 3038`0x2c N_ROSYM' 3039 Variable in `.rodata' section; see *Note Statics::. 3040 3041`0x30 N_PC' 3042 Global symbol (for Pascal); see *Note N_PC::. 3043 3044`0x32 N_NSYMS' 3045 Number of symbols (according to Ultrix V4.0); see *Note N_NSYMS::. 3046 3047`0x34 N_NOMAP' 3048 No DST map; see *Note N_NOMAP::. 3049 3050`0x38 N_OBJ' 3051 Object file (Solaris2). 3052 3053`0x3c N_OPT' 3054 Debugger options (Solaris2). 3055 3056`0x40 N_RSYM' 3057 Register variable; see *Note Register Variables::. 3058 3059`0x42 N_M2C' 3060 Modula-2 compilation unit; see *Note N_M2C::. 3061 3062`0x44 N_SLINE' 3063 Line number in text segment; see *Note Line Numbers::. 3064 3065`0x46 N_DSLINE' 3066 Line number in data segment; see *Note Line Numbers::. 3067 3068`0x48 N_BSLINE' 3069 Line number in bss segment; see *Note Line Numbers::. 3070 3071`0x48 N_BROWS' 3072 Sun source code browser, path to `.cb' file; see *Note N_BROWS::. 3073 3074`0x4a N_DEFD' 3075 GNU Modula2 definition module dependency; see *Note N_DEFD::. 3076 3077`0x4c N_FLINE' 3078 Function start/body/end line numbers (Solaris2). 3079 3080`0x50 N_EHDECL' 3081 GNU C++ exception variable; see *Note N_EHDECL::. 3082 3083`0x50 N_MOD2' 3084 Modula2 info "for imc" (according to Ultrix V4.0); see *Note 3085 N_MOD2::. 3086 3087`0x54 N_CATCH' 3088 GNU C++ `catch' clause; see *Note N_CATCH::. 3089 3090`0x60 N_SSYM' 3091 Structure of union element; see *Note N_SSYM::. 3092 3093`0x62 N_ENDM' 3094 Last stab for module (Solaris2). 3095 3096`0x64 N_SO' 3097 Path and name of source file; see *Note Source Files::. 3098 3099`0x80 N_LSYM' 3100 Stack variable (*note Stack Variables::) or type (*note 3101 Typedefs::). 3102 3103`0x82 N_BINCL' 3104 Beginning of an include file (Sun only); see *Note Include Files::. 3105 3106`0x84 N_SOL' 3107 Name of include file; see *Note Include Files::. 3108 3109`0xa0 N_PSYM' 3110 Parameter variable; see *Note Parameters::. 3111 3112`0xa2 N_EINCL' 3113 End of an include file; see *Note Include Files::. 3114 3115`0xa4 N_ENTRY' 3116 Alternate entry point; see *Note Alternate Entry Points::. 3117 3118`0xc0 N_LBRAC' 3119 Beginning of a lexical block; see *Note Block Structure::. 3120 3121`0xc2 N_EXCL' 3122 Place holder for a deleted include file; see *Note Include Files::. 3123 3124`0xc4 N_SCOPE' 3125 Modula2 scope information (Sun linker); see *Note N_SCOPE::. 3126 3127`0xe0 N_RBRAC' 3128 End of a lexical block; see *Note Block Structure::. 3129 3130`0xe2 N_BCOMM' 3131 Begin named common block; see *Note Common Blocks::. 3132 3133`0xe4 N_ECOMM' 3134 End named common block; see *Note Common Blocks::. 3135 3136`0xe8 N_ECOML' 3137 Member of a common block; see *Note Common Blocks::. 3138 3139`0xea N_WITH' 3140 Pascal `with' statement: type,,0,0,offset (Solaris2). 3141 3142`0xf0 N_NBTEXT' 3143 Gould non-base registers; see *Note Gould::. 3144 3145`0xf2 N_NBDATA' 3146 Gould non-base registers; see *Note Gould::. 3147 3148`0xf4 N_NBBSS' 3149 Gould non-base registers; see *Note Gould::. 3150 3151`0xf6 N_NBSTS' 3152 Gould non-base registers; see *Note Gould::. 3153 3154`0xf8 N_NBLCS' 3155 Gould non-base registers; see *Note Gould::. 3156 3157 3158File: stabs.info, Node: Symbol Descriptors, Next: Type Descriptors, Prev: Stab Types, Up: Top 3159 3160Table of Symbol Descriptors 3161*************************** 3162 3163The symbol descriptor is the character which follows the colon in many 3164stabs, and which tells what kind of stab it is. *Note String Field::, 3165for more information about their use. 3166 3167`DIGIT' 3168`(' 3169`-' 3170 Variable on the stack; see *Note Stack Variables::. 3171 3172`:' 3173 C++ nested symbol; see *Note Nested Symbols::. 3174 3175`a' 3176 Parameter passed by reference in register; see *Note Reference 3177 Parameters::. 3178 3179`b' 3180 Based variable; see *Note Based Variables::. 3181 3182`c' 3183 Constant; see *Note Constants::. 3184 3185`C' 3186 Conformant array bound (Pascal, maybe other languages); *Note 3187 Conformant Arrays::. Name of a caught exception (GNU C++). These 3188 can be distinguished because the latter uses `N_CATCH' and the 3189 former uses another symbol type. 3190 3191`d' 3192 Floating point register variable; see *Note Register Variables::. 3193 3194`D' 3195 Parameter in floating point register; see *Note Register 3196 Parameters::. 3197 3198`f' 3199 File scope function; see *Note Procedures::. 3200 3201`F' 3202 Global function; see *Note Procedures::. 3203 3204`G' 3205 Global variable; see *Note Global Variables::. 3206 3207`i' 3208 *Note Register Parameters::. 3209 3210`I' 3211 Internal (nested) procedure; see *Note Nested Procedures::. 3212 3213`J' 3214 Internal (nested) function; see *Note Nested Procedures::. 3215 3216`L' 3217 Label name (documented by AIX, no further information known). 3218 3219`m' 3220 Module; see *Note Procedures::. 3221 3222`p' 3223 Argument list parameter; see *Note Parameters::. 3224 3225`pP' 3226 *Note Parameters::. 3227 3228`pF' 3229 Fortran Function parameter; see *Note Parameters::. 3230 3231`P' 3232 Unfortunately, three separate meanings have been independently 3233 invented for this symbol descriptor. At least the GNU and Sun 3234 uses can be distinguished by the symbol type. Global Procedure 3235 (AIX) (symbol type used unknown); see *Note Procedures::. 3236 Register parameter (GNU) (symbol type `N_PSYM'); see *Note 3237 Parameters::. Prototype of function referenced by this file (Sun 3238 `acc') (symbol type `N_FUN'). 3239 3240`Q' 3241 Static Procedure; see *Note Procedures::. 3242 3243`R' 3244 Register parameter; see *Note Register Parameters::. 3245 3246`r' 3247 Register variable; see *Note Register Variables::. 3248 3249`S' 3250 File scope variable; see *Note Statics::. 3251 3252`s' 3253 Local variable (OS9000). 3254 3255`t' 3256 Type name; see *Note Typedefs::. 3257 3258`T' 3259 Enumeration, structure, or union tag; see *Note Typedefs::. 3260 3261`v' 3262 Parameter passed by reference; see *Note Reference Parameters::. 3263 3264`V' 3265 Procedure scope static variable; see *Note Statics::. 3266 3267`x' 3268 Conformant array; see *Note Conformant Arrays::. 3269 3270`X' 3271 Function return variable; see *Note Parameters::. 3272 3273 3274File: stabs.info, Node: Type Descriptors, Next: Expanded Reference, Prev: Symbol Descriptors, Up: Top 3275 3276Table of Type Descriptors 3277************************* 3278 3279The type descriptor is the character which follows the type number and 3280an equals sign. It specifies what kind of type is being defined. 3281*Note String Field::, for more information about their use. 3282 3283`DIGIT' 3284`(' 3285 Type reference; see *Note String Field::. 3286 3287`-' 3288 Reference to builtin type; see *Note Negative Type Numbers::. 3289 3290`#' 3291 Method (C++); see *Note Method Type Descriptor::. 3292 3293`*' 3294 Pointer; see *Note Miscellaneous Types::. 3295 3296`&' 3297 Reference (C++). 3298 3299`@' 3300 Type Attributes (AIX); see *Note String Field::. Member (class 3301 and variable) type (GNU C++); see *Note Member Type Descriptor::. 3302 3303`a' 3304 Array; see *Note Arrays::. 3305 3306`A' 3307 Open array; see *Note Arrays::. 3308 3309`b' 3310 Pascal space type (AIX); see *Note Miscellaneous Types::. Builtin 3311 integer type (Sun); see *Note Builtin Type Descriptors::. Const 3312 and volatile qualified type (OS9000). 3313 3314`B' 3315 Volatile-qualified type; see *Note Miscellaneous Types::. 3316 3317`c' 3318 Complex builtin type (AIX); see *Note Builtin Type Descriptors::. 3319 Const-qualified type (OS9000). 3320 3321`C' 3322 COBOL Picture type. See AIX documentation for details. 3323 3324`d' 3325 File type; see *Note Miscellaneous Types::. 3326 3327`D' 3328 N-dimensional dynamic array; see *Note Arrays::. 3329 3330`e' 3331 Enumeration type; see *Note Enumerations::. 3332 3333`E' 3334 N-dimensional subarray; see *Note Arrays::. 3335 3336`f' 3337 Function type; see *Note Function Types::. 3338 3339`F' 3340 Pascal function parameter; see *Note Function Types:: 3341 3342`g' 3343 Builtin floating point type; see *Note Builtin Type Descriptors::. 3344 3345`G' 3346 COBOL Group. See AIX documentation for details. 3347 3348`i' 3349 Imported type (AIX); see *Note Cross-References::. 3350 Volatile-qualified type (OS9000). 3351 3352`k' 3353 Const-qualified type; see *Note Miscellaneous Types::. 3354 3355`K' 3356 COBOL File Descriptor. See AIX documentation for details. 3357 3358`M' 3359 Multiple instance type; see *Note Miscellaneous Types::. 3360 3361`n' 3362 String type; see *Note Strings::. 3363 3364`N' 3365 Stringptr; see *Note Strings::. 3366 3367`o' 3368 Opaque type; see *Note Typedefs::. 3369 3370`p' 3371 Procedure; see *Note Function Types::. 3372 3373`P' 3374 Packed array; see *Note Arrays::. 3375 3376`r' 3377 Range type; see *Note Subranges::. 3378 3379`R' 3380 Builtin floating type; see *Note Builtin Type Descriptors:: (Sun). 3381 Pascal subroutine parameter; see *Note Function Types:: (AIX). 3382 Detecting this conflict is possible with careful parsing (hint: a 3383 Pascal subroutine parameter type will always contain a comma, and 3384 a builtin type descriptor never will). 3385 3386`s' 3387 Structure type; see *Note Structures::. 3388 3389`S' 3390 Set type; see *Note Miscellaneous Types::. 3391 3392`u' 3393 Union; see *Note Unions::. 3394 3395`v' 3396 Variant record. This is a Pascal and Modula-2 feature which is 3397 like a union within a struct in C. See AIX documentation for 3398 details. 3399 3400`w' 3401 Wide character; see *Note Builtin Type Descriptors::. 3402 3403`x' 3404 Cross-reference; see *Note Cross-References::. 3405 3406`Y' 3407 Used by IBM's xlC C++ compiler (for structures, I think). 3408 3409`z' 3410 gstring; see *Note Strings::. 3411 3412 3413File: stabs.info, Node: Expanded Reference, Next: Questions, Prev: Type Descriptors, Up: Top 3414 3415Expanded Reference by Stab Type 3416******************************* 3417 3418For a full list of stab types, and cross-references to where they are 3419described, see *Note Stab Types::. This appendix just covers certain 3420stabs which are not yet described in the main body of this document; 3421eventually the information will all be in one place. 3422 3423 Format of an entry: 3424 3425 The first line is the symbol type (see `include/aout/stab.def'). 3426 3427 The second line describes the language constructs the symbol type 3428represents. 3429 3430 The third line is the stab format with the significant stab fields 3431named and the rest NIL. 3432 3433 Subsequent lines expand upon the meaning and possible values for each 3434significant stab field. 3435 3436 Finally, any further information. 3437 3438* Menu: 3439 3440* N_PC:: Pascal global symbol 3441* N_NSYMS:: Number of symbols 3442* N_NOMAP:: No DST map 3443* N_M2C:: Modula-2 compilation unit 3444* N_BROWS:: Path to .cb file for Sun source code browser 3445* N_DEFD:: GNU Modula2 definition module dependency 3446* N_EHDECL:: GNU C++ exception variable 3447* N_MOD2:: Modula2 information "for imc" 3448* N_CATCH:: GNU C++ "catch" clause 3449* N_SSYM:: Structure or union element 3450* N_SCOPE:: Modula2 scope information (Sun only) 3451* Gould:: non-base register symbols used on Gould systems 3452* N_LENG:: Length of preceding entry 3453 3454 3455File: stabs.info, Node: N_PC, Next: N_NSYMS, Up: Expanded Reference 3456 3457N_PC 3458==== 3459 3460 - `.stabs': N_PC 3461 Global symbol (for Pascal). 3462 3463 "name" -> "symbol_name" <<?>> 3464 value -> supposedly the line number (stab.def is skeptical) 3465 3466 `stabdump.c' says: 3467 3468 global pascal symbol: name,,0,subtype,line 3469 << subtype? >> 3470 3471 3472File: stabs.info, Node: N_NSYMS, Next: N_NOMAP, Prev: N_PC, Up: Expanded Reference 3473 3474N_NSYMS 3475======= 3476 3477 - `.stabn': N_NSYMS 3478 Number of symbols (according to Ultrix V4.0). 3479 3480 0, files,,funcs,lines (stab.def) 3481 3482 3483File: stabs.info, Node: N_NOMAP, Next: N_M2C, Prev: N_NSYMS, Up: Expanded Reference 3484 3485N_NOMAP 3486======= 3487 3488 - `.stabs': N_NOMAP 3489 No DST map for symbol (according to Ultrix V4.0). I think this 3490 means a variable has been optimized out. 3491 3492 name, ,0,type,ignored (stab.def) 3493 3494 3495File: stabs.info, Node: N_M2C, Next: N_BROWS, Prev: N_NOMAP, Up: Expanded Reference 3496 3497N_M2C 3498===== 3499 3500 - `.stabs': N_M2C 3501 Modula-2 compilation unit. 3502 3503 "string" -> "unit_name,unit_time_stamp[,code_time_stamp]" 3504 desc -> unit_number 3505 value -> 0 (main unit) 3506 1 (any other unit) 3507 3508 See `Dbx and Dbxtool Interfaces', 2nd edition, by Sun, 1988, for 3509 more information. 3510 3511 3512 3513File: stabs.info, Node: N_BROWS, Next: N_DEFD, Prev: N_M2C, Up: Expanded Reference 3514 3515N_BROWS 3516======= 3517 3518 - `.stabs': N_BROWS 3519 Sun source code browser, path to `.cb' file 3520 3521 <<?>> "path to associated `.cb' file" 3522 3523 Note: N_BROWS has the same value as N_BSLINE. 3524 3525 3526File: stabs.info, Node: N_DEFD, Next: N_EHDECL, Prev: N_BROWS, Up: Expanded Reference 3527 3528N_DEFD 3529====== 3530 3531 - `.stabn': N_DEFD 3532 GNU Modula2 definition module dependency. 3533 3534 GNU Modula-2 definition module dependency. The value is the 3535 modification time of the definition file. The other field is 3536 non-zero if it is imported with the GNU M2 keyword `%INITIALIZE'. 3537 Perhaps `N_M2C' can be used if there are enough empty fields? 3538 3539 3540File: stabs.info, Node: N_EHDECL, Next: N_MOD2, Prev: N_DEFD, Up: Expanded Reference 3541 3542N_EHDECL 3543======== 3544 3545 - `.stabs': N_EHDECL 3546 GNU C++ exception variable <<?>>. 3547 3548 "STRING is variable name" 3549 3550 Note: conflicts with `N_MOD2'. 3551 3552 3553File: stabs.info, Node: N_MOD2, Next: N_CATCH, Prev: N_EHDECL, Up: Expanded Reference 3554 3555N_MOD2 3556====== 3557 3558 - `.stab?': N_MOD2 3559 Modula2 info "for imc" (according to Ultrix V4.0) 3560 3561 Note: conflicts with `N_EHDECL' <<?>> 3562 3563 3564File: stabs.info, Node: N_CATCH, Next: N_SSYM, Prev: N_MOD2, Up: Expanded Reference 3565 3566N_CATCH 3567======= 3568 3569 - `.stabn': N_CATCH 3570 GNU C++ `catch' clause 3571 3572 GNU C++ `catch' clause. The value is its address. The desc field 3573 is nonzero if this entry is immediately followed by a `CAUGHT' stab 3574 saying what exception was caught. Multiple `CAUGHT' stabs means 3575 that multiple exceptions can be caught here. If desc is 0, it 3576 means all exceptions are caught here. 3577 3578 3579File: stabs.info, Node: N_SSYM, Next: N_SCOPE, Prev: N_CATCH, Up: Expanded Reference 3580 3581N_SSYM 3582====== 3583 3584 - `.stabn': N_SSYM 3585 Structure or union element. 3586 3587 The value is the offset in the structure. 3588 3589 <<?looking at structs and unions in C I didn't see these>> 3590 3591 3592File: stabs.info, Node: N_SCOPE, Next: Gould, Prev: N_SSYM, Up: Expanded Reference 3593 3594N_SCOPE 3595======= 3596 3597 - `.stab?': N_SCOPE 3598 Modula2 scope information (Sun linker) <<?>> 3599 3600 3601File: stabs.info, Node: Gould, Next: N_LENG, Prev: N_SCOPE, Up: Expanded Reference 3602 3603Non-base registers on Gould systems 3604=================================== 3605 3606 - `.stab?': N_NBTEXT 3607 - `.stab?': N_NBDATA 3608 - `.stab?': N_NBBSS 3609 - `.stab?': N_NBSTS 3610 - `.stab?': N_NBLCS 3611 These are used on Gould systems for non-base registers syms. 3612 3613 However, the following values are not the values used by Gould; 3614 they are the values which GNU has been documenting for these 3615 values for a long time, without actually checking what Gould uses. 3616 I include these values only because perhaps some someone actually 3617 did something with the GNU information (I hope not, why GNU 3618 knowingly assigned wrong values to these in the header file is a 3619 complete mystery to me). 3620 3621 240 0xf0 N_NBTEXT ?? 3622 242 0xf2 N_NBDATA ?? 3623 244 0xf4 N_NBBSS ?? 3624 246 0xf6 N_NBSTS ?? 3625 248 0xf8 N_NBLCS ?? 3626 3627 3628File: stabs.info, Node: N_LENG, Prev: Gould, Up: Expanded Reference 3629 3630N_LENG 3631====== 3632 3633 - `.stabn': N_LENG 3634 Second symbol entry containing a length-value for the preceding 3635 entry. The value is the length. 3636 3637 3638File: stabs.info, Node: Questions, Next: Stab Sections, Prev: Expanded Reference, Up: Top 3639 3640Questions and Anomalies 3641*********************** 3642 3643 * For GNU C stabs defining local and global variables (`N_LSYM' and 3644 `N_GSYM'), the desc field is supposed to contain the source line 3645 number on which the variable is defined. In reality the desc 3646 field is always 0. (This behavior is defined in `dbxout.c' and 3647 putting a line number in desc is controlled by `#ifdef 3648 WINNING_GDB', which defaults to false). GDB supposedly uses this 3649 information if you say `list VAR'. In reality, VAR can be a 3650 variable defined in the program and GDB says `function VAR not 3651 defined'. 3652 3653 * In GNU C stabs, there seems to be no way to differentiate tag 3654 types: structures, unions, and enums (symbol descriptor `T') and 3655 typedefs (symbol descriptor `t') defined at file scope from types 3656 defined locally to a procedure or other more local scope. They 3657 all use the `N_LSYM' stab type. Types defined at procedure scope 3658 are emitted after the `N_RBRAC' of the preceding function and 3659 before the code of the procedure in which they are defined. This 3660 is exactly the same as types defined in the source file between 3661 the two procedure bodies. GDB over-compensates by placing all 3662 types in block #1, the block for symbols of file scope. This is 3663 true for default, `-ansi' and `-traditional' compiler options. 3664 (Bugs gcc/1063, gdb/1066.) 3665 3666 * What ends the procedure scope? Is it the proc block's `N_RBRAC' 3667 or the next `N_FUN'? (I believe its the first.) 3668 3669 3670File: stabs.info, Node: Stab Sections, Next: Symbol Types Index, Prev: Questions, Up: Top 3671 3672Using Stabs in Their Own Sections 3673********************************* 3674 3675Many object file formats allow tools to create object files with custom 3676sections containing any arbitrary data. For any such object file 3677format, stabs can be embedded in special sections. This is how stabs 3678are used with ELF and SOM, and aside from ECOFF and XCOFF, is how stabs 3679are used with COFF. 3680 3681* Menu: 3682 3683* Stab Section Basics:: How to embed stabs in sections 3684* ELF Linker Relocation:: Sun ELF hacks 3685 3686 3687File: stabs.info, Node: Stab Section Basics, Next: ELF Linker Relocation, Up: Stab Sections 3688 3689How to Embed Stabs in Sections 3690============================== 3691 3692The assembler creates two custom sections, a section named `.stab' 3693which contains an array of fixed length structures, one struct per stab, 3694and a section named `.stabstr' containing all the variable length 3695strings that are referenced by stabs in the `.stab' section. The byte 3696order of the stabs binary data depends on the object file format. For 3697ELF, it matches the byte order of the ELF file itself, as determined 3698from the `EI_DATA' field in the `e_ident' member of the ELF header. 3699For SOM, it is always big-endian (is this true??? FIXME). For COFF, it 3700matches the byte order of the COFF headers. The meaning of the fields 3701is the same as for a.out (*note Symbol Table Format::), except that the 3702`n_strx' field is relative to the strings for the current compilation 3703unit (which can be found using the synthetic N_UNDF stab described 3704below), rather than the entire string table. 3705 3706 The first stab in the `.stab' section for each compilation unit is 3707synthetic, generated entirely by the assembler, with no corresponding 3708`.stab' directive as input to the assembler. This stab contains the 3709following fields: 3710 3711`n_strx' 3712 Offset in the `.stabstr' section to the source filename. 3713 3714`n_type' 3715 `N_UNDF'. 3716 3717`n_other' 3718 Unused field, always zero. This may eventually be used to hold 3719 overflows from the count in the `n_desc' field. 3720 3721`n_desc' 3722 Count of upcoming symbols, i.e., the number of remaining stabs for 3723 this source file. 3724 3725`n_value' 3726 Size of the string table fragment associated with this source 3727 file, in bytes. 3728 3729 The `.stabstr' section always starts with a null byte (so that string 3730offsets of zero reference a null string), followed by random length 3731strings, each of which is null byte terminated. 3732 3733 The ELF section header for the `.stab' section has its `sh_link' 3734member set to the section number of the `.stabstr' section, and the 3735`.stabstr' section has its ELF section header `sh_type' member set to 3736`SHT_STRTAB' to mark it as a string table. SOM and COFF have no way of 3737linking the sections together or marking them as string tables. 3738 3739 For COFF, the `.stab' and `.stabstr' sections may be simply 3740concatenated by the linker. GDB then uses the `n_desc' fields to 3741figure out the extent of the original sections. Similarly, the 3742`n_value' fields of the header symbols are added together in order to 3743get the actual position of the strings in a desired `.stabstr' section. 3744Although this design obviates any need for the linker to relocate or 3745otherwise manipulate `.stab' and `.stabstr' sections, it also requires 3746some care to ensure that the offsets are calculated correctly. For 3747instance, if the linker were to pad in between the `.stabstr' sections 3748before concatenating, then the offsets to strings in the middle of the 3749executable's `.stabstr' section would be wrong. 3750 3751 The GNU linker is able to optimize stabs information by merging 3752duplicate strings and removing duplicate header file information (*note 3753Include Files::). When some versions of the GNU linker optimize stabs 3754in sections, they remove the leading `N_UNDF' symbol and arranges for 3755all the `n_strx' fields to be relative to the start of the `.stabstr' 3756section. 3757 3758 3759File: stabs.info, Node: ELF Linker Relocation, Prev: Stab Section Basics, Up: Stab Sections 3760 3761Having the Linker Relocate Stabs in ELF 3762======================================= 3763 3764This section describes some Sun hacks for Stabs in ELF; it does not 3765apply to COFF or SOM. 3766 3767 To keep linking fast, you don't want the linker to have to relocate 3768very many stabs. Making sure this is done for `N_SLINE', `N_RBRAC', 3769and `N_LBRAC' stabs is the most important thing (see the descriptions 3770of those stabs for more information). But Sun's stabs in ELF has taken 3771this further, to make all addresses in the `n_value' field (functions 3772and static variables) relative to the source file. For the `N_SO' 3773symbol itself, Sun simply omits the address. To find the address of 3774each section corresponding to a given source file, the compiler puts 3775out symbols giving the address of each section for a given source file. 3776Since these are ELF (not stab) symbols, the linker relocates them 3777correctly without having to touch the stabs section. They are named 3778`Bbss.bss' for the bss section, `Ddata.data' for the data section, and 3779`Drodata.rodata' for the rodata section. For the text section, there 3780is no such symbol (but there should be, see below). For an example of 3781how these symbols work, *Note Stab Section Transformations::. GCC does 3782not provide these symbols; it instead relies on the stabs getting 3783relocated. Thus addresses which would normally be relative to 3784`Bbss.bss', etc., are already relocated. The Sun linker provided with 3785Solaris 2.2 and earlier relocates stabs using normal ELF relocation 3786information, as it would do for any section. Sun has been threatening 3787to kludge their linker to not do this (to speed up linking), even 3788though the correct way to avoid having the linker do these relocations 3789is to have the compiler no longer output relocatable values. Last I 3790heard they had been talked out of the linker kludge. See Sun point 3791patch 101052-01 and Sun bug 1142109. With the Sun compiler this 3792affects `S' symbol descriptor stabs (*note Statics::) and functions 3793(*note Procedures::). In the latter case, to adopt the clean solution 3794(making the value of the stab relative to the start of the compilation 3795unit), it would be necessary to invent a `Ttext.text' symbol, analogous 3796to the `Bbss.bss', etc., symbols. I recommend this rather than using a 3797zero value and getting the address from the ELF symbols. 3798 3799 Finding the correct `Bbss.bss', etc., symbol is difficult, because 3800the linker simply concatenates the `.stab' sections from each `.o' file 3801without including any information about which part of a `.stab' section 3802comes from which `.o' file. The way GDB does this is to look for an 3803ELF `STT_FILE' symbol which has the same name as the last component of 3804the file name from the `N_SO' symbol in the stabs (for example, if the 3805file name is `../../gdb/main.c', it looks for an ELF `STT_FILE' symbol 3806named `main.c'). This loses if different files have the same name 3807(they could be in different directories, a library could have been 3808copied from one system to another, etc.). It would be much cleaner to 3809have the `Bbss.bss' symbols in the stabs themselves. Having the linker 3810relocate them there is no more work than having the linker relocate ELF 3811symbols, and it solves the problem of having to associate the ELF and 3812stab symbols. However, no one has yet designed or implemented such a 3813scheme. 3814 3815 3816File: stabs.info, Node: GNU Free Documentation License, Prev: Symbol Types Index, Up: Top 3817 3818GNU Free Documentation License 3819****************************** 3820 3821 Version 1.2, November 2002 3822 Copyright (C) 2000,2001,2002 Free Software Foundation, Inc. 3823 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA 3824 3825 Everyone is permitted to copy and distribute verbatim copies 3826 of this license document, but changing it is not allowed. 3827 3828 0. PREAMBLE 3829 3830 The purpose of this License is to make a manual, textbook, or other 3831 functional and useful document "free" in the sense of freedom: to 3832 assure everyone the effective freedom to copy and redistribute it, 3833 with or without modifying it, either commercially or 3834 noncommercially. Secondarily, this License preserves for the 3835 author and publisher a way to get credit for their work, while not 3836 being considered responsible for modifications made by others. 3837 3838 This License is a kind of "copyleft", which means that derivative 3839 works of the document must themselves be free in the same sense. 3840 It complements the GNU General Public License, which is a copyleft 3841 license designed for free software. 3842 3843 We have designed this License in order to use it for manuals for 3844 free software, because free software needs free documentation: a 3845 free program should come with manuals providing the same freedoms 3846 that the software does. But this License is not limited to 3847 software manuals; it can be used for any textual work, regardless 3848 of subject matter or whether it is published as a printed book. 3849 We recommend this License principally for works whose purpose is 3850 instruction or reference. 3851 3852 1. APPLICABILITY AND DEFINITIONS 3853 3854 This License applies to any manual or other work, in any medium, 3855 that contains a notice placed by the copyright holder saying it 3856 can be distributed under the terms of this License. Such a notice 3857 grants a world-wide, royalty-free license, unlimited in duration, 3858 to use that work under the conditions stated herein. The 3859 "Document", below, refers to any such manual or work. Any member 3860 of the public is a licensee, and is addressed as "you". You 3861 accept the license if you copy, modify or distribute the work in a 3862 way requiring permission under copyright law. 3863 3864 A "Modified Version" of the Document means any work containing the 3865 Document or a portion of it, either copied verbatim, or with 3866 modifications and/or translated into another language. 3867 3868 A "Secondary Section" is a named appendix or a front-matter section 3869 of the Document that deals exclusively with the relationship of the 3870 publishers or authors of the Document to the Document's overall 3871 subject (or to related matters) and contains nothing that could 3872 fall directly within that overall subject. (Thus, if the Document 3873 is in part a textbook of mathematics, a Secondary Section may not 3874 explain any mathematics.) The relationship could be a matter of 3875 historical connection with the subject or with related matters, or 3876 of legal, commercial, philosophical, ethical or political position 3877 regarding them. 3878 3879 The "Invariant Sections" are certain Secondary Sections whose 3880 titles are designated, as being those of Invariant Sections, in 3881 the notice that says that the Document is released under this 3882 License. If a section does not fit the above definition of 3883 Secondary then it is not allowed to be designated as Invariant. 3884 The Document may contain zero Invariant Sections. If the Document 3885 does not identify any Invariant Sections then there are none. 3886 3887 The "Cover Texts" are certain short passages of text that are 3888 listed, as Front-Cover Texts or Back-Cover Texts, in the notice 3889 that says that the Document is released under this License. A 3890 Front-Cover Text may be at most 5 words, and a Back-Cover Text may 3891 be at most 25 words. 3892 3893 A "Transparent" copy of the Document means a machine-readable copy, 3894 represented in a format whose specification is available to the 3895 general public, that is suitable for revising the document 3896 straightforwardly with generic text editors or (for images 3897 composed of pixels) generic paint programs or (for drawings) some 3898 widely available drawing editor, and that is suitable for input to 3899 text formatters or for automatic translation to a variety of 3900 formats suitable for input to text formatters. A copy made in an 3901 otherwise Transparent file format whose markup, or absence of 3902 markup, has been arranged to thwart or discourage subsequent 3903 modification by readers is not Transparent. An image format is 3904 not Transparent if used for any substantial amount of text. A 3905 copy that is not "Transparent" is called "Opaque". 3906 3907 Examples of suitable formats for Transparent copies include plain 3908 ASCII without markup, Texinfo input format, LaTeX input format, 3909 SGML or XML using a publicly available DTD, and 3910 standard-conforming simple HTML, PostScript or PDF designed for 3911 human modification. Examples of transparent image formats include 3912 PNG, XCF and JPG. Opaque formats include proprietary formats that 3913 can be read and edited only by proprietary word processors, SGML or 3914 XML for which the DTD and/or processing tools are not generally 3915 available, and the machine-generated HTML, PostScript or PDF 3916 produced by some word processors for output purposes only. 3917 3918 The "Title Page" means, for a printed book, the title page itself, 3919 plus such following pages as are needed to hold, legibly, the 3920 material this License requires to appear in the title page. For 3921 works in formats which do not have any title page as such, "Title 3922 Page" means the text near the most prominent appearance of the 3923 work's title, preceding the beginning of the body of the text. 3924 3925 A section "Entitled XYZ" means a named subunit of the Document 3926 whose title either is precisely XYZ or contains XYZ in parentheses 3927 following text that translates XYZ in another language. (Here XYZ 3928 stands for a specific section name mentioned below, such as 3929 "Acknowledgements", "Dedications", "Endorsements", or "History".) 3930 To "Preserve the Title" of such a section when you modify the 3931 Document means that it remains a section "Entitled XYZ" according 3932 to this definition. 3933 3934 The Document may include Warranty Disclaimers next to the notice 3935 which states that this License applies to the Document. These 3936 Warranty Disclaimers are considered to be included by reference in 3937 this License, but only as regards disclaiming warranties: any other 3938 implication that these Warranty Disclaimers may have is void and 3939 has no effect on the meaning of this License. 3940 3941 2. VERBATIM COPYING 3942 3943 You may copy and distribute the Document in any medium, either 3944 commercially or noncommercially, provided that this License, the 3945 copyright notices, and the license notice saying this License 3946 applies to the Document are reproduced in all copies, and that you 3947 add no other conditions whatsoever to those of this License. You 3948 may not use technical measures to obstruct or control the reading 3949 or further copying of the copies you make or distribute. However, 3950 you may accept compensation in exchange for copies. If you 3951 distribute a large enough number of copies you must also follow 3952 the conditions in section 3. 3953 3954 You may also lend copies, under the same conditions stated above, 3955 and you may publicly display copies. 3956 3957 3. COPYING IN QUANTITY 3958 3959 If you publish printed copies (or copies in media that commonly 3960 have printed covers) of the Document, numbering more than 100, and 3961 the Document's license notice requires Cover Texts, you must 3962 enclose the copies in covers that carry, clearly and legibly, all 3963 these Cover Texts: Front-Cover Texts on the front cover, and 3964 Back-Cover Texts on the back cover. Both covers must also clearly 3965 and legibly identify you as the publisher of these copies. The 3966 front cover must present the full title with all words of the 3967 title equally prominent and visible. You may add other material 3968 on the covers in addition. Copying with changes limited to the 3969 covers, as long as they preserve the title of the Document and 3970 satisfy these conditions, can be treated as verbatim copying in 3971 other respects. 3972 3973 If the required texts for either cover are too voluminous to fit 3974 legibly, you should put the first ones listed (as many as fit 3975 reasonably) on the actual cover, and continue the rest onto 3976 adjacent pages. 3977 3978 If you publish or distribute Opaque copies of the Document 3979 numbering more than 100, you must either include a 3980 machine-readable Transparent copy along with each Opaque copy, or 3981 state in or with each Opaque copy a computer-network location from 3982 which the general network-using public has access to download 3983 using public-standard network protocols a complete Transparent 3984 copy of the Document, free of added material. If you use the 3985 latter option, you must take reasonably prudent steps, when you 3986 begin distribution of Opaque copies in quantity, to ensure that 3987 this Transparent copy will remain thus accessible at the stated 3988 location until at least one year after the last time you 3989 distribute an Opaque copy (directly or through your agents or 3990 retailers) of that edition to the public. 3991 3992 It is requested, but not required, that you contact the authors of 3993 the Document well before redistributing any large number of 3994 copies, to give them a chance to provide you with an updated 3995 version of the Document. 3996 3997 4. MODIFICATIONS 3998 3999 You may copy and distribute a Modified Version of the Document 4000 under the conditions of sections 2 and 3 above, provided that you 4001 release the Modified Version under precisely this License, with 4002 the Modified Version filling the role of the Document, thus 4003 licensing distribution and modification of the Modified Version to 4004 whoever possesses a copy of it. In addition, you must do these 4005 things in the Modified Version: 4006 4007 A. Use in the Title Page (and on the covers, if any) a title 4008 distinct from that of the Document, and from those of 4009 previous versions (which should, if there were any, be listed 4010 in the History section of the Document). You may use the 4011 same title as a previous version if the original publisher of 4012 that version gives permission. 4013 4014 B. List on the Title Page, as authors, one or more persons or 4015 entities responsible for authorship of the modifications in 4016 the Modified Version, together with at least five of the 4017 principal authors of the Document (all of its principal 4018 authors, if it has fewer than five), unless they release you 4019 from this requirement. 4020 4021 C. State on the Title page the name of the publisher of the 4022 Modified Version, as the publisher. 4023 4024 D. Preserve all the copyright notices of the Document. 4025 4026 E. Add an appropriate copyright notice for your modifications 4027 adjacent to the other copyright notices. 4028 4029 F. Include, immediately after the copyright notices, a license 4030 notice giving the public permission to use the Modified 4031 Version under the terms of this License, in the form shown in 4032 the Addendum below. 4033 4034 G. Preserve in that license notice the full lists of Invariant 4035 Sections and required Cover Texts given in the Document's 4036 license notice. 4037 4038 H. Include an unaltered copy of this License. 4039 4040 I. Preserve the section Entitled "History", Preserve its Title, 4041 and add to it an item stating at least the title, year, new 4042 authors, and publisher of the Modified Version as given on 4043 the Title Page. If there is no section Entitled "History" in 4044 the Document, create one stating the title, year, authors, 4045 and publisher of the Document as given on its Title Page, 4046 then add an item describing the Modified Version as stated in 4047 the previous sentence. 4048 4049 J. Preserve the network location, if any, given in the Document 4050 for public access to a Transparent copy of the Document, and 4051 likewise the network locations given in the Document for 4052 previous versions it was based on. These may be placed in 4053 the "History" section. You may omit a network location for a 4054 work that was published at least four years before the 4055 Document itself, or if the original publisher of the version 4056 it refers to gives permission. 4057 4058 K. For any section Entitled "Acknowledgements" or "Dedications", 4059 Preserve the Title of the section, and preserve in the 4060 section all the substance and tone of each of the contributor 4061 acknowledgements and/or dedications given therein. 4062 4063 L. Preserve all the Invariant Sections of the Document, 4064 unaltered in their text and in their titles. Section numbers 4065 or the equivalent are not considered part of the section 4066 titles. 4067 4068 M. Delete any section Entitled "Endorsements". Such a section 4069 may not be included in the Modified Version. 4070 4071 N. Do not retitle any existing section to be Entitled 4072 "Endorsements" or to conflict in title with any Invariant 4073 Section. 4074 4075 O. Preserve any Warranty Disclaimers. 4076 4077 If the Modified Version includes new front-matter sections or 4078 appendices that qualify as Secondary Sections and contain no 4079 material copied from the Document, you may at your option 4080 designate some or all of these sections as invariant. To do this, 4081 add their titles to the list of Invariant Sections in the Modified 4082 Version's license notice. These titles must be distinct from any 4083 other section titles. 4084 4085 You may add a section Entitled "Endorsements", provided it contains 4086 nothing but endorsements of your Modified Version by various 4087 parties--for example, statements of peer review or that the text 4088 has been approved by an organization as the authoritative 4089 definition of a standard. 4090 4091 You may add a passage of up to five words as a Front-Cover Text, 4092 and a passage of up to 25 words as a Back-Cover Text, to the end 4093 of the list of Cover Texts in the Modified Version. Only one 4094 passage of Front-Cover Text and one of Back-Cover Text may be 4095 added by (or through arrangements made by) any one entity. If the 4096 Document already includes a cover text for the same cover, 4097 previously added by you or by arrangement made by the same entity 4098 you are acting on behalf of, you may not add another; but you may 4099 replace the old one, on explicit permission from the previous 4100 publisher that added the old one. 4101 4102 The author(s) and publisher(s) of the Document do not by this 4103 License give permission to use their names for publicity for or to 4104 assert or imply endorsement of any Modified Version. 4105 4106 5. COMBINING DOCUMENTS 4107 4108 You may combine the Document with other documents released under 4109 this License, under the terms defined in section 4 above for 4110 modified versions, provided that you include in the combination 4111 all of the Invariant Sections of all of the original documents, 4112 unmodified, and list them all as Invariant Sections of your 4113 combined work in its license notice, and that you preserve all 4114 their Warranty Disclaimers. 4115 4116 The combined work need only contain one copy of this License, and 4117 multiple identical Invariant Sections may be replaced with a single 4118 copy. If there are multiple Invariant Sections with the same name 4119 but different contents, make the title of each such section unique 4120 by adding at the end of it, in parentheses, the name of the 4121 original author or publisher of that section if known, or else a 4122 unique number. Make the same adjustment to the section titles in 4123 the list of Invariant Sections in the license notice of the 4124 combined work. 4125 4126 In the combination, you must combine any sections Entitled 4127 "History" in the various original documents, forming one section 4128 Entitled "History"; likewise combine any sections Entitled 4129 "Acknowledgements", and any sections Entitled "Dedications". You 4130 must delete all sections Entitled "Endorsements." 4131 4132 6. COLLECTIONS OF DOCUMENTS 4133 4134 You may make a collection consisting of the Document and other 4135 documents released under this License, and replace the individual 4136 copies of this License in the various documents with a single copy 4137 that is included in the collection, provided that you follow the 4138 rules of this License for verbatim copying of each of the 4139 documents in all other respects. 4140 4141 You may extract a single document from such a collection, and 4142 distribute it individually under this License, provided you insert 4143 a copy of this License into the extracted document, and follow 4144 this License in all other respects regarding verbatim copying of 4145 that document. 4146 4147 7. AGGREGATION WITH INDEPENDENT WORKS 4148 4149 A compilation of the Document or its derivatives with other 4150 separate and independent documents or works, in or on a volume of 4151 a storage or distribution medium, is called an "aggregate" if the 4152 copyright resulting from the compilation is not used to limit the 4153 legal rights of the compilation's users beyond what the individual 4154 works permit. When the Document is included in an aggregate, this 4155 License does not apply to the other works in the aggregate which 4156 are not themselves derivative works of the Document. 4157 4158 If the Cover Text requirement of section 3 is applicable to these 4159 copies of the Document, then if the Document is less than one half 4160 of the entire aggregate, the Document's Cover Texts may be placed 4161 on covers that bracket the Document within the aggregate, or the 4162 electronic equivalent of covers if the Document is in electronic 4163 form. Otherwise they must appear on printed covers that bracket 4164 the whole aggregate. 4165 4166 8. TRANSLATION 4167 4168 Translation is considered a kind of modification, so you may 4169 distribute translations of the Document under the terms of section 4170 4. Replacing Invariant Sections with translations requires special 4171 permission from their copyright holders, but you may include 4172 translations of some or all Invariant Sections in addition to the 4173 original versions of these Invariant Sections. You may include a 4174 translation of this License, and all the license notices in the 4175 Document, and any Warranty Disclaimers, provided that you also 4176 include the original English version of this License and the 4177 original versions of those notices and disclaimers. In case of a 4178 disagreement between the translation and the original version of 4179 this License or a notice or disclaimer, the original version will 4180 prevail. 4181 4182 If a section in the Document is Entitled "Acknowledgements", 4183 "Dedications", or "History", the requirement (section 4) to 4184 Preserve its Title (section 1) will typically require changing the 4185 actual title. 4186 4187 9. TERMINATION 4188 4189 You may not copy, modify, sublicense, or distribute the Document 4190 except as expressly provided for under this License. Any other 4191 attempt to copy, modify, sublicense or distribute the Document is 4192 void, and will automatically terminate your rights under this 4193 License. However, parties who have received copies, or rights, 4194 from you under this License will not have their licenses 4195 terminated so long as such parties remain in full compliance. 4196 4197 10. FUTURE REVISIONS OF THIS LICENSE 4198 4199 The Free Software Foundation may publish new, revised versions of 4200 the GNU Free Documentation License from time to time. Such new 4201 versions will be similar in spirit to the present version, but may 4202 differ in detail to address new problems or concerns. See 4203 `http://www.gnu.org/copyleft/'. 4204 4205 Each version of the License is given a distinguishing version 4206 number. If the Document specifies that a particular numbered 4207 version of this License "or any later version" applies to it, you 4208 have the option of following the terms and conditions either of 4209 that specified version or of any later version that has been 4210 published (not as a draft) by the Free Software Foundation. If 4211 the Document does not specify a version number of this License, 4212 you may choose any version ever published (not as a draft) by the 4213 Free Software Foundation. 4214 4215ADDENDUM: How to use this License for your documents 4216==================================================== 4217 4218To use this License in a document you have written, include a copy of 4219the License in the document and put the following copyright and license 4220notices just after the title page: 4221 4222 Copyright (C) YEAR YOUR NAME. 4223 Permission is granted to copy, distribute and/or modify this document 4224 under the terms of the GNU Free Documentation License, Version 1.2 4225 or any later version published by the Free Software Foundation; 4226 with no Invariant Sections, no Front-Cover Texts, and no Back-Cover 4227 Texts. A copy of the license is included in the section entitled ``GNU 4228 Free Documentation License''. 4229 4230 If you have Invariant Sections, Front-Cover Texts and Back-Cover 4231Texts, replace the "with...Texts." line with this: 4232 4233 with the Invariant Sections being LIST THEIR TITLES, with 4234 the Front-Cover Texts being LIST, and with the Back-Cover Texts 4235 being LIST. 4236 4237 If you have Invariant Sections without Cover Texts, or some other 4238combination of the three, merge those two alternatives to suit the 4239situation. 4240 4241 If your document contains nontrivial examples of program code, we 4242recommend releasing these examples in parallel under your choice of 4243free software license, such as the GNU General Public License, to 4244permit their use in free software. 4245 4246 4247File: stabs.info, Node: Symbol Types Index, Next: GNU Free Documentation License, Prev: Stab Sections, Up: Top 4248 4249Symbol Types Index 4250****************** 4251 4252* Menu: 4253 4254* .bb: Block Structure. 4255* .be: Block Structure. 4256* C_BCOMM: Common Blocks. 4257* C_BINCL: Include Files. 4258* C_BLOCK: Block Structure. 4259* C_BSTAT: Statics. 4260* C_DECL, for types: Typedefs. 4261* C_ECOML: Common Blocks. 4262* C_ECOMM: Common Blocks. 4263* C_EINCL: Include Files. 4264* C_ENTRY: Alternate Entry Points. 4265* C_ESTAT: Statics. 4266* C_FILE: Source Files. 4267* C_FUN: Procedures. 4268* C_GSYM: Global Variables. 4269* C_LSYM: Stack Variables. 4270* C_PSYM: Parameters. 4271* C_RPSYM: Register Parameters. 4272* C_RSYM: Register Variables. 4273* C_STSYM: Statics. 4274* N_BCOMM: Common Blocks. 4275* N_BINCL: Include Files. 4276* N_BROWS: N_BROWS. 4277* N_BSLINE: Line Numbers. 4278* N_CATCH: N_CATCH. 4279* N_DEFD: N_DEFD. 4280* N_DSLINE: Line Numbers. 4281* N_ECOML: Common Blocks. 4282* N_ECOMM: Common Blocks. 4283* N_EHDECL: N_EHDECL. 4284* N_EINCL: Include Files. 4285* N_ENTRY: Alternate Entry Points. 4286* N_EXCL: Include Files. 4287* N_FNAME: Procedures. 4288* N_FUN, for functions: Procedures. 4289* N_FUN, for variables: Statics. 4290* N_GSYM: Global Variables. 4291* N_GSYM, for functions (Sun acc): Procedures. 4292* N_LBRAC: Block Structure. 4293* N_LCSYM: Statics. 4294* N_LENG: N_LENG. 4295* N_LSYM, for parameter: Local Variable Parameters. 4296* N_LSYM, for stack variables: Stack Variables. 4297* N_LSYM, for types: Typedefs. 4298* N_M2C: N_M2C. 4299* N_MAIN: Main Program. 4300* N_MOD2: N_MOD2. 4301* N_NBBSS: Gould. 4302* N_NBDATA: Gould. 4303* N_NBLCS: Gould. 4304* N_NBSTS: Gould. 4305* N_NBTEXT: Gould. 4306* N_NOMAP: N_NOMAP. 4307* N_NSYMS: N_NSYMS. 4308* N_PC: N_PC. 4309* N_PSYM: Parameters. 4310* N_RBRAC: Block Structure. 4311* N_ROSYM: Statics. 4312* N_RSYM: Register Variables. 4313* N_RSYM, for parameters: Register Parameters. 4314* N_SCOPE: N_SCOPE. 4315* N_SLINE: Line Numbers. 4316* N_SO: Source Files. 4317* N_SOL: Include Files. 4318* N_SSYM: N_SSYM. 4319* N_STSYM: Statics. 4320* N_STSYM, for functions (Sun acc): Procedures. 4321 4322 4323 4324Tag Table: 4325Node: Top859 4326Node: Overview1839 4327Node: Flow3250 4328Node: Stabs Format4768 4329Node: String Field6322 4330Node: C Example11745 4331Node: Assembly Code12282 4332Node: Program Structure14245 4333Node: Main Program14967 4334Node: Source Files15520 4335Node: Include Files17342 4336Node: Line Numbers19999 4337Node: Procedures21525 4338Node: Nested Procedures27407 4339Node: Block Structure28575 4340Node: Alternate Entry Points29973 4341Node: Constants30698 4342Node: Variables33806 4343Node: Stack Variables34490 4344Node: Global Variables36183 4345Node: Register Variables37331 4346Node: Common Blocks38145 4347Node: Statics39391 4348Node: Based Variables41964 4349Node: Parameters43341 4350Node: Register Parameters44945 4351Node: Local Variable Parameters47194 4352Node: Reference Parameters50097 4353Node: Conformant Arrays50705 4354Node: Types51410 4355Node: Builtin Types52341 4356Node: Traditional Builtin Types53479 4357Node: Traditional Integer Types53868 4358Node: Traditional Other Types56160 4359Node: Builtin Type Descriptors57058 4360Node: Negative Type Numbers60546 4361Node: Miscellaneous Types66889 4362Node: Cross-References68767 4363Node: Subranges70434 4364Node: Arrays71665 4365Node: Strings74882 4366Node: Enumerations75936 4367Node: Structures78313 4368Node: Typedefs81017 4369Node: Unions82333 4370Node: Function Types83904 4371Node: Symbol Tables85476 4372Node: Symbol Table Format85904 4373Node: Transformations On Symbol Tables87344 4374Node: Transformations On Static Variables88690 4375Node: Transformations On Global Variables89414 4376Node: Stab Section Transformations90645 4377Node: Cplusplus92016 4378Node: Class Names92595 4379Node: Nested Symbols93332 4380Node: Basic Cplusplus Types94170 4381Node: Simple Classes95722 4382Node: Class Instance100023 4383Node: Methods100732 4384Node: Method Type Descriptor102958 4385Node: Member Type Descriptor104150 4386Node: Protections104973 4387Node: Method Modifiers108055 4388Node: Virtual Methods109673 4389Node: Inheritance113464 4390Node: Virtual Base Classes117175 4391Node: Static Members119409 4392Node: Stab Types119869 4393Node: Non-Stab Symbol Types120471 4394Node: Stab Symbol Types121894 4395Node: Symbol Descriptors125609 4396Node: Type Descriptors128366 4397Node: Expanded Reference131556 4398Node: N_PC132952 4399Node: N_NSYMS133321 4400Node: N_NOMAP133553 4401Node: N_M2C133850 4402Node: N_BROWS134275 4403Node: N_DEFD134549 4404Node: N_EHDECL134997 4405Node: N_MOD2135239 4406Node: N_CATCH135468 4407Node: N_SSYM135953 4408Node: N_SCOPE136227 4409Node: Gould136406 4410Node: N_LENG137383 4411Node: Questions137600 4412Node: Stab Sections139222 4413Node: Stab Section Basics139798 4414Node: ELF Linker Relocation143131 4415Node: GNU Free Documentation License146533 4416Node: Symbol Types Index168936 4417 4418End Tag Table 4419