First pass at converting Julia's stabs document into texinfo.
[binutils-gdb.git] / gdb / doc / stabs.texinfo
1 \input texinfo
2 @setfilename stabs.info
3
4 @ifinfo
5 @format
6 START-INFO-DIR-ENTRY
7 * Stabs. The "stabs" representation of debugging infromation.
8 END-INFO-DIR-ENTRY
9 @end format
10 @end ifinfo
11
12 @ifinfo
13 This document describes GNU stabs in a.out
14
15 Copyright (C) 1992 by ???.
16 Contributed by Cygnus Support. Written by Julia Menapace.
17
18 Permission is granted to make and distribute verbatim copies of
19 this manual provided the copyright notice and this permission notice
20 are preserved on all copies.
21
22 @ignore
23 Permission is granted to process this file through Tex and print the
24 results, provided the printed document carries copying permission
25 notice identical to this one except for the removal of this paragraph
26 (this paragraph not being relevant to the printed manual).
27
28 @end ignore
29 Permission is granted to copy or distribute modified versions of this
30 manual under the terms of the GPL (for which purpose this text may be
31 regarded as a program in the language TeX).
32 @end ifinfo
33
34 @setchapternewpage off
35 @settitle STABS
36 @titlepage
37 @title{The "stabs" representation of debugging infromation.}
38 @author Julia Menapace
39 @author Cygnus Support
40 @page
41 @tex
42 \def\$#1${{#1}} % Kluge: collect RCS revision info without $...$
43 \xdef\manvers{\$Revision$} % For use in headers, footers too
44 {\parskip=0pt
45 \hfill Cygnus Support\par
46 \hfill \manvers\par
47 \hfill \TeX{}info \texinfoversion\par
48 }
49 @end tex
50
51 @vskip 0pt plus 1filll
52 Copyright @copyright{} 1990, 1991 Free Software Foundation, Inc.
53
54 Permission is granted to make and distribute verbatim copies of
55 this manual provided the copyright notice and this permission notice
56 are preserved on all copies.
57
58 @end titlepage
59
60 @node Top, Overview, (dir), (dir)
61
62 This document describes GNU stabs in a.out
63
64 @menu
65 * Overview:: Overview of stabs
66 * Program structure:: Encoding of the structure of the program
67 * Simple types::
68 * Example:: A comprehensive example in C
69 * Variables::
70 * Aggregate types::
71 * Symbol tables:: Symbol information in symbol tables
72 * GNU C++ stabs::
73
74 Appendixes:
75 * Example2.c:: source code for extended example
76 * Example2.s:: assembly code for extended example
77 * Quick reference:: Various refernce tables
78 * Expanded reference:: by stab type
79 * Questions:: Questions and anomolies
80 * xcoff-differences:: Differences between GNU stabs in a.out and GNU stabs in xcoff
81 * Sun-differences:: Differences between GNU stabs and Sun native stabs
82 @end menu
83
84
85 @node Overview, Program structure, Top, Top
86 @chapter Overview of stabs
87
88 @menu
89 * Flow:: Overview of debugging information flow
90 * Stabs format:: Overview of stab format
91 * C example:: A simple example in C source
92 * Assembly code:: The simple example at the assembly level
93 @end menu
94
95 @node Flow, Stabs format, , Overview
96 @section Overview of debugging information flow
97
98 GCC compiles C source in a .c file into assembly language in a .s
99 file, which is translated by the assembler into a .o file, and then
100 linked with other .o files and libraries to produce an executable
101 file.
102
103 When using the -g option, GCC puts additional debugging information in
104 the .s file, which is slightly transformed by the assembler and
105 linker, and carried through into the final executable. This debugging
106 information describes features of the source file like line numbers,
107 the types and scopes of variables, and functions, their parameters and
108 their scopes.
109
110 For some object file formats, the debugging information is
111 encapsulated in pseudo-ops to the assembler known as `stab' (symbol
112 table) directives, interspersed with the generated code. Stabs are
113 the native format for debugging information in the a.out and xcoff
114 object file formats. The GNU tools can also emit stabs in the coff
115 and ecoff object file formats.
116
117 The assembler adds the information from stabs to the symbol
118 information it places by default in the symbol table and the string
119 table of the .o file it is building. The linker consolidates the .o
120 files into one executable file, with one symbol and one string table.
121 Debuggers use the symbol and string tables in the executable as a
122 source of debugging information about the program.
123
124 @node Stabs format, C example, Flow, Overview
125 @section Overview of stab format
126
127 There are three overall formats for stab assembler directives
128 differentiated by the first word of the stab. The first word
129 describes what combination of four possible data fields will follow.
130 It is either .stabs (string), .stabn (number), or .stabd (dot).
131
132 The overall format of each class of stab is:
133
134 @example
135 .stabs "string",type,0,desc,value
136 .stabn type,0,desc,value
137 .stabd type,0,desc
138 @end example
139
140 In general, in .stabs the string field contains name and type
141 information. For .stabd the value field is implicit and has the value
142 of the current file location. Otherwise the value field often
143 contains a relocatable address, frame pointer offset, or register
144 number, that maps to the source code element described by the stab.
145
146 The real key to decoding the meaning of a stab is the number in its
147 type field. Each possible type number defines a different stab type.
148 The stab type further defines the exact interpretation of, and
149 possible values for, any remaining "string", desc, or value fields
150 present in the stab. Table A lists in numeric order the possible type
151 field values for stab directives. The reference section that follows
152 Table A describes the meaning of the fields for each stab type in
153 detail. The examples that follow this overview introduce the stab
154 types in terms of the source code elements they describe.
155
156 For .stabs the "string" field holds the meat of the debugging
157 information. The generally unstructured nature of this field is what
158 makes stabs extensible. For some stab types the string field contains
159 only a name. For other stab types the contents can be a great deal
160 more complex.
161
162 The overall format is of the "string" field is:
163
164 @example
165 "name[:symbol_descriptor][type_number[=type_descriptor...]]"
166 @end example
167
168 name is the name of the symbol represented by the stab.
169
170 The symbol_descriptor following the : is an alphabetic character that
171 tells more specifically what kind of symbol the stab represents. If
172 the symbol_descriptor is omitted, but type information follows, then
173 the stab represents a local variable. See Table C for a list of
174 symbol_descriptors.
175
176 Type information it is either a type_number, or a type_number=. The
177 type_number alone is a type reference, referring directly to a type
178 that has already been defined.
179
180 The type_number= is a type definition, where the number represents a
181 new type which is about to be defined. The type definition may refer
182 to other types by number, and those type numbers may be followed by =
183 and nested definitions.
184
185 In a type definition, if the character that follows the equals sign is
186 non-numeric then it is a type_descriptor, and tells what kind of type
187 is about to be defined. Any other values following the
188 type_descriptor vary, depending on the type_descriptor. If a number
189 follows the = then the number is a type_reference. This is described
190 more thoroughly in the section on types. See Table D for a list of
191 type_descriptors.
192
193 All this can make the "string" field quite long. When the "string"
194 part of a stab is more than 80 characters, we split the .stabs
195 pseudo-op into two .stabs pseudo-ops, both stabs duplicate exactly all
196 but the "string" field. The "string" field of the first stab contains
197 the first part of the overlong string, marked as continued with a
198 double-backslash at the end. The "string" field of the second stab
199 holds the second half of the overlong string.
200
201 @node C example, Assembly code, Stabs format, Overview
202 @section A simple example in C source
203
204 To get the flavor of how stabs describe source information for a C
205 program, let's look at the simple program:
206
207 @example
208 main()
209 @{
210 printf("Hello world");
211 @}
212 @end example
213
214 When compiled with -g, the program above yields the following .s file.
215 Line numbers have been added so it will be easier to refer to parts of
216 the .s file in the description of the stabs that follows.
217
218 @node Assembly code, , C example, Overview
219 @section The simple example at the assembly level
220
221 @example
222 1 gcc2_compiled.:
223 2 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
224 3 .stabs "hello.c",100,0,0,Ltext0
225 4 .text
226 5 Ltext0:
227 6 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
228 7 .stabs "char:t2=r2;0;127;",128,0,0,0
229 8 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
230 9 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
231 10 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
232 11 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0
233 12 .stabs "long long int:t7=r1;0;-1;",128,0,0,0
234 13 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
235 14 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
236 15 .stabs "signed char:t10=r1;-128;127;",128,0,0,0
237 16 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0
238 17 .stabs "float:t12=r1;4;0;",128,0,0,0
239 18 .stabs "double:t13=r1;8;0;",128,0,0,0
240 19 .stabs "long double:t14=r1;8;0;",128,0,0,0
241 20 .stabs "void:t15=15",128,0,0,0
242 21 .align 4
243 22 LC0:
244 23 .ascii "Hello, world!\12\0"
245 24 .align 4
246 25 .global _main
247 26 .proc 1
248 27 _main:
249 28 .stabn 68,0,4,LM1
250 29 LM1:
251 30 !#PROLOGUE# 0
252 31 save %sp,-136,%sp
253 32 !#PROLOGUE# 1
254 33 call ___main,0
255 34 nop
256 35 .stabn 68,0,5,LM2
257 36 LM2:
258 37 LBB2:
259 38 sethi %hi(LC0),%o1
260 39 or %o1,%lo(LC0),%o0
261 40 call _printf,0
262 41 nop
263 42 .stabn 68,0,6,LM3
264 43 LM3:
265 44 LBE2:
266 45 .stabn 68,0,6,LM4
267 46 LM4:
268 47 L1:
269 48 ret
270 49 restore
271 50 .stabs "main:F1",36,0,0,_main
272 51 .stabn 192,0,0,LBB2
273 52 .stabn 224,0,0,LBE2
274 @end example
275
276 This simple hello world example, demonstrates several of the stab
277 types used to describe C language source files.
278
279 @node Program structure, Simple types, Overview, Top
280 @chapter Encoding of the structure of the program
281
282 @menu
283 * Source file:: The path and name of the source file
284 * Line numbers::
285 * Procedures::
286 * Block structure::
287 @end menu
288
289 @node Source file, Line numbers, , Program structure
290 @section The path and name of the source file
291
292 @example
293 .stabs, stab type N_SO
294 @end example
295
296 The first stabs in the .s file contain the name and path of the source
297 file that was compiled to produce the .s file. This information is
298 contained in two records of stab type N_SO (100).
299
300 @example
301 .stabs "path_name", N_SO, NIL, NIL, Code_address_of_program_start
302 .stabs "file_name:", N_SO, NIL, NIL, Code_address_of_program_start
303 @end example
304
305 @example
306 2 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
307 3 .stabs "hello.c",100,0,0,Ltext0
308 4 .text
309 5 Ltext0:
310 @end example
311
312 @node Line numbers, Procedures, Source file, Program structure
313 @section Line Numbers
314
315 @example
316 .stabn, stab type N_SLINE
317 @end example
318
319 The start of source lines is represented by the N_SLINE (68) stab
320 type.
321
322 @example
323 .stabn N_SLINE, NIL, source_line_number,
324 code_address_for_start_of_source_line
325 @end example
326
327 @example
328 27 _main:
329 28 .stabn 68,0,4,LM1
330 29 LM1:
331 30 !#PROLOGUE# 0
332 @end example
333
334 @node Procedures, Block structure, Line numbers, Program structure
335 @section Procedures
336
337 @example
338 .stabs, stab type N_FUN,
339 symbol descriptors f (local), F (global)
340 @end example
341
342 Procedures are described by the N_FUN stab type. The symbol
343 descriptor for a procedure is F if the proc is globally scoped and f
344 if the procedure is static (locally scoped).
345
346 The N_FUN stab representing a procedure is located immediatly
347 following the code of the procedure. The N_FUN stab is in turn
348 directly followed by a group of other stabs describing elements of the
349 procedure. These other stabs describe the procedure's parameters, its
350 block local variables and its block structure.
351
352 @example
353 48 ret
354 49 restore
355 @end example
356
357 @example
358 .stabs "procedure_name:symbol_desc(global proc)return_type_ref(int)",
359 N_FUN, NIL, NIL, Code_address_of_procedure_start
360 @end example
361
362 @example
363 50 .stabs "main:F1",36,0,0,_main
364 @end example
365
366 @node Block Structure, , Procedures, Program structure
367 @section Block Structure
368
369 @example
370 .stabn, stab types N_LBRAC, N_RRAC
371 @end example
372
373 The program's block structure is represented by the N_LBRAC (left
374 brace) and the N_RBRAC (right brace) stab types. The following code
375 range, which is the body of main, is labeled with LBB2: at the
376 beginning and LBE2: at the end.
377
378 @example
379 37 LBB2:
380 38 sethi %hi(LC0),%o1
381 39 or %o1,%lo(LC0),%o0
382 40 call _printf,0
383 41 nop
384 42 .stabn 68,0,6,LM3
385 43 LM3:
386 44 LBE2:
387 @end example
388
389 The N_LBRAC and N_RBRAC stabs that describe the block scope of the
390 procedure are located after the N_FUNC stab that represents the
391 procedure itself. The N_LBRAC uses the LBB2 label as the code address
392 in its value field and the N_RBRAC uses the LBE2.
393
394 @example
395 50 .stabs "main:F1",36,0,0,_main
396 @end example
397
398 @example
399 .stabn N_LBRAC, NIL, NIL, Code_Address_for_left_brace
400 .stabn N_RBRAC, NIL, NIL, Code_Address_for_right_brace
401 @end example
402
403 @example
404 51 .stabn 192,0,0,LBB2
405 52 .stabn 224,0,0,LBE2
406 @end example
407
408 @node Simple types, Example, Program structure, Top
409 @chapter Simple types
410
411 @menu
412 * Basic types::
413 * Range types:: Range types defined by min and max value
414 * Bit-ranges:: Range type defined by number of bits
415 @end menu
416
417 @node Basic types, Range types, , Simple types
418 @section Basic type definitions
419
420 @example
421 .stabs, stab type N_LSYM,
422 symbol descriptor t
423 @end example
424
425 The basic types for the language are described using the N_LSYM stab
426 type. They are boilerplate and are emited by the compiler for each
427 compilation unit. Basic type definitions are not always a complete
428 description of the type and are sometimes circular. The debugger
429 recognizes the type anyway, and knows how to read bits as that type.
430
431 Each language and compiler defines a slightly different set of basic
432 types. In this example we are looking at the basic types for C emited
433 by the GNU compiler targeting the Sun4. Here the basic types are
434 mostly defined as range types.
435
436
437 @node Range types, Bit-ranges, Basic types, Simple types
438 @section Range types defined by min and max value
439
440 type descriptor r
441
442 When defining a range type, if the number after the first semicolon is
443 smaller than the number after the second one, then the two numbers
444 represent the smallest and the largest values in the range.
445
446 @example
447 4 .text
448 5 Ltext0:
449
450 .stabs "name:sym_descriptor(type)type_def(1)=type_desc(range)type_ref(1);\
451 "low_bound;high_bound;",N_LSYM, NIL, NIL, NIL
452
453 6 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
454 7 .stabs "char:t2=r2;0;127;",128,0,0,0
455 @end example
456
457 Here the integer type (1) is defined as a range of the integer type
458 (1). Likewise char is a range of char. This part of the definition
459 is circular, but at least the high and low bound values of the range
460 hold more information about the type.
461
462 Here short unsigned int is defined as type number 8 and described as a
463 range of type int, with a minimum value of 0 and a maximum of 65535.
464
465 @example
466 13 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
467 @end example
468
469 @node Bit-ranges, , Range types, Simple types
470 @section Range type defined by number of bits
471
472 type descriptor r
473
474 In a range definition, if the number after the second semicolon is 0,
475 then the number after the first semicolon is the number of bits needed
476 to represent the type.
477
478 @example
479 .stabs "name:sym_desc(type)type_def(12)=type_desc(range)type_ref(int)\
480 ";number_of_bytes;0;", N_LSYM, NIL, NIL, NIL
481
482 17 .stabs "float:t12=r1;4;0;",128,0,0,0
483 18 .stabs "double:t13=r1;8;0;",128,0,0,0
484 19 .stabs "long double:t14=r1;8;0;",128,0,0,0
485 @end example
486
487 Cosmically enough, the void type is defined directly in terms of
488 itself.
489
490 @example
491 .stabs "name:symbol_desc(type)type_def(15)=type_ref(15)",N_LSYM,NIL,NIL,NIL
492 @end example
493
494 @example
495 20 .stabs "void:t15=15",128,0,0,0
496 @end example
497
498
499 @node Example, Variables, Simple types, Top
500 @chapter A Comprehensive Example in C
501
502 Now we'll examine a second program, example2, which builds on the
503 first example to introduce the rest of the stab types, symbol
504 descriptors, and type descriptors used in C.
505 @xref{Example2.c} for the complete .c source,
506 and @pxref{example2.s} for the .s assembly code.
507 This description includes parts of those files.
508
509 @section Flow of control and nested scopes
510
511 .stabn, stab types N_SLINE, N_LBRAC, N_RBRAC (cont.)
512
513 Consider the body of main, from example2.c. It shows more about how
514 N_SLINE, N_RBRAC, and N_LBRAC stabs are used.
515
516 @example
517 20 @{
518 21 static float s_flap;
519 22 int times;
520 23 for (times=0; times < s_g_repeat; times++)@{
521 24 int inner;
522 25 printf ("Hello world\n");
523 26 @}
524 27 @};
525 @end example
526
527 Here we have a single source line, the `for' line, that generates
528 non-linear flow of control, and non-contiguous code. In this case, an
529 N_SLINE stab with the same line number proceeds each block of
530 non-contiguous code generated from the same source line.
531
532 The example also shows nested scopes. The N_LBRAC and N_LBRAC stabs
533 that describe block structure are nested in the same order as the
534 corresponding code blocks, those of the for loop inside those for the
535 body of main.
536
537 Label for the N_LBRAC (left brace) stab marking the start of `main'.
538
539 57 LBB2:
540
541 First code range for source line 23,`for' loop initialize and test
542 <68> N_SLINE - source line number associated with this code
543 .stabn N_SLINE, NIL, line_number, code_address_of_line_start
544
545 @example
546 58 .stabn 68,0,23,LM2
547 59 LM2:
548 60 st %g0,[%fp-20]
549 61 L2:
550 62 sethi %hi(_s_g_repeat),%o0
551 63 ld [%fp-20],%o1
552 64 ld [%o0+%lo(_s_g_repeat)],%o0
553 65 cmp %o1,%o0
554 66 bge L3
555 67 nop
556 @end example
557
558 label for the N_LBRAC (start block) marking the start of `for' loop
559
560 @example
561 68 LBB3:
562 69 .stabn 68,0,25,LM3
563 70 LM3:
564 71 sethi %hi(LC0),%o1
565 72 or %o1,%lo(LC0),%o0
566 73 call _printf,0
567 74 nop
568 75 .stabn 68,0,26,LM4
569 76 LM4:
570 @end example
571
572 label for the N_RBRAC (end block) stab marking the end of the for loop
573
574 @example
575 77 LBE3:
576 @end example
577
578 Second code range for source line 23, 'for' loop increment and return
579 <68> N_SLINE - source line number associated with this code
580 .stabn, SLINE, NIL, line_number, code_address_of_line_continuation.
581
582 @example
583 78 .stabn 68,0,23,LM5
584 79 LM5:
585 80 L4:
586 81 ld [%fp-20],%o0
587 82 add %o0,1,%o1
588 83 st %o1,[%fp-20]
589 84 b,a L2
590 85 L3:
591 86 .stabn 68,0,27,LM6
592 87 LM6:
593 @end example
594
595 label for the N_RBRAC (end block) stab marking the end of the for loop
596
597 @example
598 88 LBE2:
599 89 .stabn 68,0,27,LM7
600 90 LM7:
601 91 L1:
602 92 ret
603 93 restore
604 94 .stabs "main:F1",36,0,0,_main
605 95 .stabs "argc:p1",160,0,0,68
606 96 .stabs "argv:p20=*21=*2",160,0,0,72
607 97 .stabs "s_flap:V12",40,0,0,_s_flap.0
608 98 .stabs "times:1",128,0,0,-20
609
610 stabs describing nested scopes, the stabs are nested like the scopes are.
611 <192> N_LBRAC - left brace, begin lexical block (scope)
612 .stabn N_LBRAC,NIL,NIL,code_addr_of_block_start
613
614 99 .stabn 192,0,0,LBB2 ## begin proc label
615 100 .stabs "inner:1",128,0,0,-24
616 101 .stabn 192,0,0,LBB3 ## begin for label
617
618 <224> N_RBRAC - right brace, end lexical block (scope)
619 .stabn N_RBRAC,NIL,NIL,code_addr_of_block_end
620
621 102 .stabn 224,0,0,LBE3 ## end for label
622 103 .stabn 224,0,0,LBE2 ## end proc label
623 @end example
624
625
626 @node Variables, Aggregate types, Example, Top
627 @chapter Variables
628
629 @menu
630 * Automatic variables:: locally scoped
631 * Global variables::
632 * Register variables::
633 * Initialized statics::
634 * Un-initialized statics::
635 * Parameters::
636 @end menu
637
638 @node Automatic variables, Global variables, , Variables
639 @section Locally scoped automatic variables
640
641 @example
642 .stabs, stab type N_LSYM,
643 symbol descriptor none
644 @end example
645
646
647 In addition to describing types, the N_LSYM stab type also describes
648 locally scoped automatic variables. Refer again to the body of main
649 in example2.c. It allocates two automatic variables, 'times' is
650 scoped to the body of main and 'inner' is scoped to the body of the
651 for loop. 's_flap' is locally scoped by not automatic and will be
652 discussed later.
653
654 @example
655 20 @{
656 21 static float s_flap;
657 22 int times;
658 23 for (times=0; times < s_g_repeat; times++)@{
659 24 int inner;
660 25 printf ("Hello world\n");
661 26 @}
662 27 @};
663 @end example
664
665 The N_LSYM stab for an automatic variable is located just before the
666 N_LBRAC stab describing the open brace of the block to which it is
667 scoped.
668
669 @example
670 <128> N_LSYM - automatic variable, scoped locally to main
671 .stabs "name:type_ref(int)", N_LSYM, NIL, NIL, frame_pointer_offset
672
673 98 .stabs "times:1",128,0,0,-20
674 99 .stabn 192,0,0,LBB2 ## begin `main' N_LBRAC
675
676 <128> N_LSYM - automatic variable, scoped locally to the for loop
677 .stabs "name:type_ref(int)", N_LSYM, NIL, NIL, frame_pointer_offset
678
679 100 .stabs "inner:1",128,0,0,-24
680 101 .stabn 192,0,0,LBB3 ## begin `for' loop N_LBRAC
681 @end example
682
683 Since the character in the string field following the colon is not a
684 letter, there is no symbol descriptor. This means that the stab
685 describes a local variable, and that the number after the colon is a
686 type reference. In this case it a a reference to the basic type int.
687 Notice also that the frame pointer offset is negative number for
688 automatic variables.
689
690
691 @node Global Variables, Register variables, Automatic variables, Variables
692 @section Global Variables
693
694 @example
695 .stabs, stab type N_GSYM,
696 symbol descriptor G
697 @end example
698
699 Global variables are represented by the N_GSYM stab type. The symbol
700 descriptor, following the colon in the string field, is G. Following
701 the G is a type reference or type definition. In this example it is a
702 type reference to the basic C type, char. The first source line in
703 example2.c
704
705 @example
706 1 char g_foo = 'c';
707 @end example
708
709 yields the following stab. The stab immediatly preceeds the code that
710 allocates storage for the variable it describes.
711
712 @example
713 <32> N_GSYM - global symbol
714 "name:sym_descriptor(Global)type_ref(char)", N_GSYM, NIL, NIL, NIL
715 @end example
716
717 @example
718 21 .stabs "g_foo:G2",32,0,0,0
719 22 .global _g_foo
720 23 .data
721 24 _g_foo:
722 25 .byte 99
723 @end example
724
725 The address of the variable represented by the N_GSYM is not contained
726 in the N_GSYM stab. The debugger gets this information from the
727 external symbol for the global variable.
728
729 @node Register variables, Initialized statics, Global variables, Variables
730 @section Register variables
731
732 @example
733 .stabs, stab type N_RSYM,
734 symbol descriptor r
735 @end example
736
737 The following source line defines a global variable, g_bar, which is
738 allocated in global register %g5.
739
740 @example
741 2 register int g_bar asm ("%g5");
742 @end example
743
744 Register variables have their own stab type, N_RSYM, and their own
745 symbol descriptor, r. The stab's value field contains the number of
746 the register where the variable data will be stored. Since the
747 variable was not initialized in this compilation unit, the stab is
748 emited at the end of the object file, with the stabs for other
749 uninitialized globals (bcc).
750
751 @example
752 <64> N_RSYM - register variable
753 .stabs "name:sym_desc(reg_var)type_ref(int), N_RSYM, NIL, NIL, reg_num
754
755 133 .stabs "g_bar:r1",64,0,0,5
756 @end example
757
758
759 @node Initialized statics, Un-initialized statics, Register variables, Variables
760 @section Initialized static variables
761
762 @example
763 .stabs, stab type N_STSYM,
764 symbol descriptors S (file scope), V (procedure scope)
765 @end example
766
767 Initialized static variables are represented by the N_STSYM stab type.
768 The symbol descriptor part of the string field shows if the variable
769 is file scope static (S) or procedure scope static (V). The source
770 line:
771
772 @example
773 3 static int s_g_repeat = 2;
774 @end example
775
776 yields the following code. The stab is located immediatly preceeding
777 the storage for the variable it represents. Since the variable in
778 this example is file scope static the symbol descriptor is S.
779
780 @example
781 <38> N_STSYM - initialized static variable (data seg w/internal linkage)
782 .stabs "name:sym_desc(static_global)type_ref(int)",N_STSYM,NIL,NIL,var_addr
783 @end example
784
785 @example
786 26 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
787 27 .align 4
788 28 _s_g_repeat:
789 29 .word 2
790 @end example
791
792
793 @node Un-initialized statics, Parameters, Initialized statics, Variables
794 @section Un-initialized static variables
795
796 @example
797 .stabs, stab type N_LCSYM,
798 symbol descriptors S (file scope), V (procedure scope)
799 @end example
800
801 Un-initilized static variables are represeted by the N_LCSYM stab
802 type. The symbol descriptor part of the string shows if the variable
803 is file scope static (S) or procedure scope static (V). In this
804 example it is procedure scope static. The source line allocating
805 s_flap immediatly follows the open brace for the procedure main.
806
807 @example
808 20 @{
809 21 static float s_flap;
810 @end example
811
812
813 The code that reserves storage for the variable s_flap preceeds the
814 body of body of main.
815
816 @example
817 39 .reserve _s_flap.0,4,"bss",4
818 @end example
819
820 But since s_flap is scoped locally to main, its stab is located with
821 the other stabs representing symbols local to main. The stab for
822 s_flap is located just before the N_LBRAC for main.
823
824 @example
825 <40> N_LCSYM - un-initialized static var (BSS seg w/internal linkage)
826 .stabs "name:sym_desc(static_local)type_ref(float)", N_LCSYM,
827 NIL, NIL, data_addr
828 @end example
829
830 @example
831 97 .stabs "s_flap:V12",40,0,0,_s_flap.0
832 98 .stabs "times:1",128,0,0,-20
833 99 .stabn 192,0,0,LBB2 # N_LBRAC for main.
834 @end example
835
836 @node Parameters, , Un-initialized statics, Variables
837 @section Parameters
838
839 @example
840 .stabs, stab type N_PSYM,
841 symbol descriptor p
842 @end example
843
844 Procedure parameters are represented by the N_PSYM stab type. The
845 following source lines show the parameters of the main routine.
846
847 @example
848 17 main (argc, argv)
849 18 int argc;
850 19 char* argv[];
851 20 @{
852 @end example
853
854 The N_PSYM stabs describing parameters to a function directly follow
855 the N_FUN stab that represents the procedure itself. The N_FUN stab
856 immediatly follows the code of the procedure it describes. Following
857 the N_PSYM parameter stabs are any N_LSYM stabs representing local
858 variables.
859
860 <36> N_FUN - describing the procedure main
861
862 @example
863 94 .stabs "main:F1",36,0,0,_main
864
865 <160> N_PSYM - parameters
866 .stabs "name:sym_desc(value_param)type_ref(int)", N_PSYM,
867 NIL, NIL, frame_ptr_offset
868 95 .stabs "argc:p1",160,0,0,68
869
870 <160> N_PSYM - parameter
871 .stabs "name:sym_desc(value_param)type_def(20)=ptr_to type_def(21)=
872 ptr_to type_ref(char)
873 96 .stabs "argv:p20=*21=*2",160,0,0,72
874 @end example
875
876 The type definition of argv is interesting because it defines two new
877 types in terms of an existing one. The array argv contains character
878 pointers. The type of the array name is a pointer to the type the
879 array holds. Thus the type of argv is ptr to ptr to char. The stab
880 for argv contains nested type_definitions. Type 21 is ptr to type 2
881 (char) and argv (type 20) is ptr to type 21.
882
883 @node Aggregate Types, Symbol tables, Variables, Top
884 @chapter Aggregate Types
885
886 Now lets look at some variable definitions involving complex types.
887 This involves understanding better how types are described. In the
888 examples so far types have been described as references to previously
889 defined types or defined in terms of subranges of or pointers to
890 previously defined types. The section that follows will talk about
891 the various other type descriptors that may follow the = sign in a
892 type definition.
893
894 @menu
895 * Arrays::
896 * Enumerations::
897 * Structure tags::
898 * Typedefs::
899 * Unions::
900 * Function types::
901 @end menu
902
903 @node Arrays, Enumerations, , Aggregate Types
904 @subsection Array types
905
906 .stabs, stab types N_GSYM, N_LSYM,
907 symbol descriptor T, type descriptor ar
908
909 As an example of an array type consider the global variable below.
910
911 @example
912 15 char char_vec[3] = @{'a','b','c'@};
913 @end example
914
915 Since the array is a global variable, it is described by the N_GSYM
916 stab type. The symbol descriptor G, following the colon in stab's
917 string field, also says the array is a global variable. Following the
918 G is a definition for type (19) as shown by the equals sign after the
919 type number.
920
921 After the equals sign is a type descriptor, ar, which says that the
922 type being defined is an array. Following the type descriptor for an
923 array is the type of the index, a null field, the upper bound of the
924 array indexing, and the type of the array elements.
925
926 The array definition above generates the assembly language that
927 follows.
928
929 @example
930 <32> N_GSYM - global variable
931 .stabs "name:sym_desc(global)type_def(19)=type_desc(array)
932 index_type_ref(int);NIL;high_bound(2);element_type_ref(char)";
933 N_GSYM, NIL, NIL, NIL
934
935 32 .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
936 33 .global _char_vec
937 34 .align 4
938 35 _char_vec:
939 36 .byte 97
940 37 .byte 98
941 38 .byte 99
942 @end example
943
944 @node Enumerations, Structure Tags, Arrays, Aggregate Types
945 @section Enumerations
946
947 .stabs, stab type N_LSYM,
948 symbol descriptor T, type descriptor e
949
950 The source line below declares an enumeration type. It is defined at
951 file scope between the bodies of main and s_proc in example2.c.
952 Because the N_LSYM is located after the N_RBRAC that marks the end of
953 the previous procedure's block scope, and before the N_FUN that marks
954 the beginning of the next procedure's block scope, the N_LSYM does not
955 describe a block local symbol, but a file local one. The source line:
956
957 @example
958 29 enum e_places @{first,second=3,last@};
959 @end example
960
961 generates the following stab, located just after the N_RBRAC (close
962 brace stab) for main. The type definition is in an N_LSYM stab
963 because type definitions are file scope not global scope.
964
965 @example
966 <128> N_LSYM - local symbol
967 .stab "name:sym_dec(type)type_def(22)=sym_desc(enum)
968 enum_name:value(0),enum_name:value(3),enum_name:value(4),;",
969 N_LSYM, NIL, NIL, NIL
970 @end example
971
972 104 .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0
973
974 The symbol descriptor (T) says that the stab describes a structure,
975 enumeration, or type tag. The type descriptor e, following the 22= of
976 the type definition narrows it down to an enumeration type. Following
977 the e is a list of the elements of the enumeration. The format is
978 name:value,. The list of elements ends with a ;.
979
980 @node Structure tags, Typedefs, Enumerations, Aggregate Types
981 @section Structure Tags
982
983 .stabs, stab type N_LSYM,
984 symbol descriptor T, type descriptor s
985
986 The following source code declares a structure tag and defines an
987 instance of the structure in global scope. Then a typedef equates the
988 structure tag with a new type. A seperate stab is generated for the
989 structure tag, the structure typedef, and the structure instance. The
990 stabs for the tag and the typedef are emited when the definitions are
991 encountered. Since the structure elements are not initialized, the
992 stab and code for the structure variable itself is located at the end
993 of the program in .common.
994
995 @example
996 6 struct s_tag @{
997 7 int s_int;
998 8 float s_float;
999 9 char s_char_vec[8];
1000 10 struct s_tag* s_next;
1001 11 @} g_an_s;
1002 12
1003 13 typedef struct s_tag s_typedef;
1004 @end example
1005
1006 The structure tag is an N_LSYM stab type because, like the enum, the
1007 symbol is file scope. Like the enum, the symbol descriptor is T, for
1008 enumeration, struct or tag type. The symbol descriptor s following
1009 the 16= of the type definition narrows the symbol type to struct.
1010
1011 Following the struct symbol descriptor is the number of bytes the
1012 struct occupies, followed by a description of each structure element.
1013 The structure element descriptions are of the form name:type, bit
1014 offset from the start of the struct, and number of bits in the
1015 element.
1016
1017
1018 <128> N_LSYM - type definition
1019 .stabs "name:sym_desc(struct tag) Type_def(16)=type_desc(struct type)
1020 struct_bytes
1021 elem_name:type_ref(int),bit_offset,field_bits;
1022 elem_name:type_ref(float),bit_offset,field_bits;
1023 elem_name:type_def(17)=type_desc(dynamic array) index_type(int);NIL;
1024 high_bound(7);element_type(char),bit_offset,field_bits;;",
1025 N_LSYM,NIL,NIL,NIL
1026
1027 30 .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;
1028 s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
1029
1030 In this example, two of the structure elements are previously defined
1031 types. For these, the type following the name: part of the element
1032 description is a simple type reference. The other two structure
1033 elements are new types. In this case there is a type definition
1034 embedded after the name:. The type definition for the array element
1035 looks just like a type definition for a standalone array. The s_next
1036 field is a pointer to the same kind of structure that the field is an
1037 element of. So the definition of structure type 16 contains an type
1038 definition for an element which is a pointer to type 16.
1039
1040 @node Typedefs, Unions, Structure tags, Aggregate Types
1041 @section Typedefs
1042
1043 .stabs, stab type N_LSYM,
1044 symbol descriptor t
1045
1046 Here is the stab for the typedef equating the structure tag with a
1047 type.
1048
1049 <128> N_LSYM - type definition
1050 .stabs "name:sym_desc(type name)type_ref(struct_tag)",N_LSYM,NIL,NIL,NIL
1051
1052 31 .stabs "s_typedef:t16",128,0,0,0
1053
1054 And here is the code generated for the structure variable.
1055
1056 <32> N_GSYM - global symbol
1057 .stabs "name:sym_desc(global)type_ref(struct_tag)",N_GSYM,NIL,NIL,NIL
1058
1059 @example
1060 136 .stabs "g_an_s:G16",32,0,0,0
1061 137 .common _g_an_s,20,"bss"
1062 @end example
1063
1064 Notice that the structure tag has the same type number as the typedef
1065 for the structure tag. It is impossible to distinguish between a
1066 variable of the struct type and one of its typedef by looking at the
1067 debugging information.
1068
1069
1070 @node Unions, Function types, Typedefs, Aggregate Types
1071 @section Unions
1072
1073 .stabs, stab type N_LSYM,
1074 symbol descriptor T, type descriptor u
1075
1076 Next lets look at unions. In example2 this union type is declared
1077 locally to a procedure and an instance of the union is defined.
1078
1079 @example
1080 36 union u_tag @{
1081 37 int u_int;
1082 38 float u_float;
1083 39 char* u_char;
1084 40 @} an_u;
1085 @end example
1086
1087 This code generates a stab for the union tag and a stab for the union
1088 variable. Both use the N_LSYM stab type. Since the union variable is
1089 scoped locally to the procedure in which it is defined, its stab is
1090 located immediatly preceeding the N_LBRAC for the procedure's block
1091 start.
1092
1093 The stab for the union tag, however is located preceeding the code for
1094 the procedure in which it is defined. The stab type is N_LSYM. This
1095 would seem to imply that the union type is file scope, like the struct
1096 type s_tag. This is not true. The contents and position of the stab
1097 for u_type do not convey any infomation about its procedure local
1098 scope.
1099
1100 <128> N_LSYM - type
1101 .stabs "name:sym_desc(union tag)type_def(22)=type_desc(union)
1102 byte_size(4)
1103 elem_name:type_ref(int),bit_offset(0),bit_size(32);
1104 elem_name:type_ref(float),bit_offset(0),bit_size(32);
1105 elem_name:type_ref(ptr to char),bit_offset(0),bit_size(32);;"
1106 N_LSYM, NIL, NIL, NIL
1107
1108 105 .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;",128,0,0,0
1109
1110 The symbol descriptor, T, following the name: means that the stab
1111 describes an enumeration struct or type tag. The type descriptor u,
1112 following the 23= of the type definition, narrows it down to a union
1113 type definition. Following the u is the number of bytes in the union.
1114 After that is a list of union element descriptions. Their format is
1115 name:type, bit offset into the union, and number of bytes for the
1116 element;.
1117
1118 The stab for the union variable follows. Notice that the frame
1119 pointer offset for local variables is negative.
1120
1121 <128> N_LSYM - local variable (with no symbol descriptor)
1122 .stabs "name:type_ref(u_tag)", N_LSYM, NIL, NIL, frame_ptr_offset
1123
1124 130 .stabs "an_u:23",128,0,0,-20
1125
1126 @node Function types, , Unions, Aggregate Types
1127 @section Function types
1128
1129 type descriptor f
1130
1131 The last type descriptor in C which remains to be described is used
1132 for function types. Consider the following source line defining a
1133 global function pointer.
1134
1135 @example
1136 4 int (*g_pf)();
1137 @end example
1138
1139 It generates the following code. Since the variable is not
1140 initialized, the code is located in the common area at the end of the
1141 file.
1142
1143 <32> N_GSYM - global variable
1144 .stabs "name:sym_desc(global)type_def(24)=ptr_to(25)=
1145 type_def(func)type_ref(int)
1146
1147 134 .stabs "g_pf:G24=*25=f1",32,0,0,0
1148 135 .common _g_pf,4,"bss"
1149
1150 Since the variable is global, the stab type is N_GSYM and the symbol
1151 descriptor is G. The variable defines a new type, 24, which is a
1152 pointer to another new type, 25, which is defined as a function
1153 returning int.
1154
1155 @node Symbol tables, GNU C++ stabs, Aggregate types, Top
1156 @chapter Symbol information in symbol tables
1157
1158 This section examines more closely the format of symbol table entries
1159 and how stab assembler directives map to them. It also describes what
1160 transformations the assembler and linker make on data from stabs.
1161
1162 Each time the assembler encounters a stab in its input file it puts
1163 each field of the stab into corresponding fields in a symbol table
1164 entry of its output file. If the stab contains a string field, the
1165 symbol table entry for that stab points to a string table entry
1166 containing the string data from the stab. Assembler labels become
1167 relocatable addresses. Symbol table entries in a.out have the format:
1168
1169 @example
1170 struct internal_nlist @{
1171 unsigned long n_strx; /* index into string table of name */
1172 unsigned char n_type; /* type of symbol */
1173 unsigned char n_other; /* misc info (usually empty) */
1174 unsigned short n_desc; /* description field */
1175 bfd_vma n_value; /* value of symbol */
1176 @};
1177 @end example
1178
1179 For .stabs directives, the n_strx field holds the character offset
1180 from the start of the string table to the string table entry
1181 containing the "string" field. For other classes of stabs (.stabn and
1182 .stabd) this field is null.
1183
1184 Symbol table entries with n_type fields containing a value greater or
1185 equal to 0x20 originated as stabs generated by the compiler (with one
1186 random exception). Those with n_type values less than 0x20 were
1187 placed in the symbol table of the executable by the assembler or the
1188 linker.
1189
1190 The linker concatenates object files and does fixups of externally
1191 defined symbols. You can see the transformations made on stab data by
1192 the assembler and linker by examining the symbol table after each pass
1193 of the build, first the assemble and then the link.
1194
1195 To do this use nm with the -ap options. This dumps the symbol table,
1196 including debugging information, unsorted. For stab entries the
1197 columns are: value, other, desc, type, string. For assembler and
1198 linker symbols, the columns are: value, type, string.
1199
1200 There are a few important things to notice about symbol tables. Where
1201 the value field of a stab contains a frame pointer offset, or a
1202 register number, that value is unchanged by the rest of the build.
1203
1204 Where the value field of a stab contains an assembly language label,
1205 it is transformed by each build step. The assembler turns it into a
1206 relocatable address and the linker turns it into an absolute address.
1207 This source line defines a static variable at file scope:
1208
1209 3 static int s_g_repeat
1210
1211 The following stab describes the symbol.
1212
1213 26 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
1214
1215 The assembler transforms the stab into this symbol table entry in the
1216 .o file. The location is expressed as a data segment offset.
1217
1218 21 00000084 - 00 0000 STSYM s_g_repeat:S1
1219
1220 in the symbol table entry from the executable, the linker has made the
1221 relocatable address absolute.
1222
1223 22 0000e00c - 00 0000 STSYM s_g_repeat:S1
1224
1225 Stabs for global variables do not contain location information. In
1226 this case the debugger finds location information in the assembler or
1227 linker symbol table entry describing the variable. The source line:
1228
1229 1 char g_foo = 'c';
1230
1231 generates the stab:
1232
1233 21 .stabs "g_foo:G2",32,0,0,0
1234
1235 The variable is represented by the following two symbol table entries
1236 in the object file. The first one originated as a stab. The second
1237 one is an external symbol. The upper case D signifies that the n_type
1238 field of the symbol table contains 7, N_DATA with local linkage (see
1239 Table B). The value field following the file's line number is empty
1240 for the stab entry. For the linker symbol it contains the
1241 rellocatable address corresponding to the variable.
1242
1243 19 00000000 - 00 0000 GSYM g_foo:G2
1244 20 00000080 D _g_foo
1245
1246 These entries as transformed by the linker. The linker symbol table
1247 entry now holds an absolute address.
1248
1249 21 00000000 - 00 0000 GSYM g_foo:G2
1250 ...
1251 215 0000e008 D _g_foo
1252
1253
1254 @node Gnu C++ stabs, , Symbol tables, Top
1255 @chapter Gnu C++ stabs
1256
1257 @menu
1258 * Basic C++ types::
1259 * Simple classes::
1260 * Class instance::
1261 * Methods:: Method definition
1262 * Protections::
1263 * Method Modifiers:: (const, volatile, const volatile)
1264 * Virtual Methods::
1265 * Inheritence::
1266 * Virtual Base Classes::
1267 * Static Members::
1268 @end menu
1269
1270
1271 @subsection Symbol descriptors added for C++ descriptions:
1272
1273 P - register parameter.
1274
1275 @subsection type descriptors added for C++ descriptions
1276
1277 @table @code
1278 @item #
1279 method type (two ## if minimal debug)
1280
1281 @item xs
1282 cross-reference
1283 @end table
1284
1285
1286 @node Basic C++ types, , , Gnu C++ stabs
1287 @section Basic types for C++
1288
1289 << the examples that follow are based on a01.C >>
1290
1291
1292 C++ adds two more builtin types to the set defined for C. These are
1293 the unknown type and the vtable record type. The unknown type, type
1294 16, is defined in terms of itself like the void type.
1295
1296 The vtable record type, type 17, is defined as a structure type and
1297 then as a structure tag. The structure has four fields, delta, index,
1298 pfn, and delta2. pfn is the function pointer.
1299
1300 << In boilerplate $vtbl_ptr_type, what are the fields delta,
1301 index, and delta2 used for? >>
1302
1303 This basic type is present in all C++ programs even if there are no
1304 virtual methods defined.
1305
1306 .stabs "struct_name:sym_desc(type)type_def(17)=type_desc(struct)struct_bytes(8)
1307 elem_name(delta):type_ref(short int),bit_offset(0),field_bits(16);
1308 elem_name(index):type_ref(short int),bit_offset(16),field_bits(16);
1309 elem_name(pfn):type_def(18)=type_desc(ptr to)type_ref(void),
1310 bit_offset(32),field_bits(32);
1311 elem_name(delta2):type_def(short int);bit_offset(32),field_bits(16);;"
1312 N_LSYM, NIL, NIL
1313
1314 .stabs "$vtbl_ptr_type:t17=s8
1315 delta:6,0,16;index:6,16,16;pfn:18=*15,32,32;delta2:6,32,16;;"
1316 ,128,0,0,0
1317
1318 .stabs "name:sym_dec(struct tag)type_ref($vtbl_ptr_type)",N_LSYM,NIL,NIL,NIL
1319
1320 .stabs "$vtbl_ptr_type:T17",128,0,0,0
1321
1322 @node Simple classes, , , Gnu C++ stabs
1323 @section Simple class definition
1324
1325 The stabs describing C++ language features are an extension of the
1326 stabs describing C. Stabs representing C++ class types elaborate
1327 extensively on the stab format used to describe structure types in C.
1328 Stabs representing class type variables look just like stabs
1329 representing C language variables.
1330
1331 Consider the following very simple class definition.
1332
1333 @example
1334 class baseA @{
1335 public:
1336 int Adat;
1337 int Ameth(int in, char other);
1338 @};
1339 @end example
1340
1341 The class baseA is represented by two stabs. The first stab describes
1342 the class as a structure type. The second stab describes a structure
1343 tag of the class type. Both stabs are of stab type N_LSYM. Since the
1344 stab is not located between an N_FUN and a N_LBRAC stab this indicates
1345 that the class is defined at file scope. If it were, then the N_LSYM
1346 would signify a local variable.
1347
1348 A stab describing a C++ class type is similar in format to a stab
1349 describing a C struct, with each class member shown as a field in the
1350 structure. The part of the struct format describing fields is
1351 expanded to include extra information relevent to C++ class members.
1352 In addition, if the class has multiple base classes or virtual
1353 functions the struct format outside of the field parts is also
1354 augmented.
1355
1356 In this simple example the field part of the C++ class stab
1357 representing member data looks just like the field part of a C struct
1358 stab. The section on protections describes how its format is
1359 sometimes extended for member data.
1360
1361 The field part of a C++ class stab representing a member function
1362 differs substantially from the field part of a C struct stab. It
1363 still begins with `name:' but then goes on to define a new type number
1364 for the member function, describe its return type, its argument types,
1365 its protection level, any qualifiers applied to the method definition,
1366 and whether the method is virtual or not. If the method is virtual
1367 then the method description goes on to give the vtable index of the
1368 method, and the type number of the first base class defining the
1369 method.
1370
1371 When the field name is a method name it is followed by two colons
1372 rather than one. This is followed by a new type definition for the
1373 method. This is a number followed by an equal sign and then the
1374 symbol descriptor `##', indicating a method type. This is followed by
1375 a type reference showing the return type of the method and a
1376 semi-colon.
1377
1378 The format of an overloaded operator method name differs from that
1379 of other methods. It is "op$::XXXX." where XXXX is the operator name
1380 such as + or +=
1381
1382 The next part of the method description represents the arguments to
1383 the method, preceeded by a colon and ending with a semi-colon. The
1384 types of the arguments are expressed in the same way argument types
1385 are expressed in C++ name mangling. In this example an int and a char
1386 map to `ic'.
1387
1388 This is followed by a number, a letter, and an asterisk or period,
1389 followed by another semicolon. The number indicates the protections
1390 that apply to the member function. Here the 2 means public. The
1391 letter encodes any qualifier applied to the method definition. In
1392 this case A means that it is a normal function definition. The dot
1393 shows that the method is not virtual. The sections that follow
1394 elaborate further on these fields and describe the additional
1395 information present for virtual methods.
1396
1397
1398 .stabs "class_name:sym_desc(type)type_def(20)=type_desc(struct)struct_bytes(4)
1399 field_name(Adat):type(int),bit_offset(0),field_bits(32);
1400
1401 method_name(Ameth)::type_def(21)=type_desc(method)return_type(int);
1402 :arg_types(int char);
1403 protection(public)qualifier(normal)virtual(no);;"
1404 N_LSYM,NIL,NIL,NIL
1405
1406 .stabs "baseA:t20=s4Adat:1,0,32;Ameth::21=##1;:ic;2A.;;",128,0,0,0
1407
1408 .stabs "class_name:sym_desc(struct tag)",N_LSYM,NIL,NIL,NIL
1409
1410 .stabs "baseA:T20",128,0,0,0
1411
1412 @node Class instance, , , Gnu C++ stabs
1413 @section Class instance
1414
1415 As shown above, describing even a simple C++ class definition is
1416 accomplished by massively extending the stab format used in C to
1417 describe structure types. However, once the class is defined, C stabs
1418 with no modifications can be used to describe class instances. The
1419 following source:
1420
1421 @example
1422 main () @{
1423 baseA AbaseA;
1424 @}
1425 @end example
1426
1427 yeilds the following stab describing the class instance. It looks no
1428 different from a standard C stab describing a local variable.
1429
1430 .stabs "name:type_ref(baseA)", N_LSYM, NIL, NIL, frame_ptr_offset
1431
1432 .stabs "AbaseA:20",128,0,0,-20
1433
1434 @node Methods, , , Gnu C++ stabs
1435 @section Method defintion
1436
1437 The class definition shown above declares Ameth. The C++ source below
1438 defines Ameth:
1439
1440 @example
1441 int
1442 baseA::Ameth(int in, char other)
1443 @{
1444 return in;
1445 @};
1446 @end example
1447
1448
1449 This method definition yields three stabs following the code of the
1450 method. One stab describes the method itself and following two
1451 describe its parameters. Although there is only one formal argument
1452 all methods have an implicit argument which is the `this' pointer.
1453 The `this' pointer is a pointer to the object on which the method was
1454 called. Note that the method name is mangled to encode the class name
1455 and argument types. << Name mangling is not described by this
1456 document - Is there already such a doc? >>
1457
1458 .stabs "name:symbol_desriptor(global function)return_type(int)",
1459 N_FUN, NIL, NIL, code_addr_of_method_start
1460
1461 .stabs "Ameth__5baseAic:F1",36,0,0,_Ameth__5baseAic
1462
1463 Here is the stab for the `this' pointer implicit argument. The name
1464 of the `this' pointer is always $t. Type 19, the `this' pointer is
1465 defined as a pointer to type 20, baseA, but a stab defining baseA has
1466 not yet been emited. Since the compiler knows it will be emited
1467 shortly, here it just outputs a cross reference to the undefined
1468 symbol, by prefixing the symbol name with xs.
1469
1470 .stabs "name:sym_desc(register param)type_def(19)=
1471 type_desc(ptr to)type_ref(baseA)=
1472 type_desc(cross-reference to)baseA:",N_RSYM,NIL,NIL,register_number
1473
1474 .stabs "$t:P19=*20=xsbaseA:",64,0,0,8
1475
1476 The stab for the explicit integer argument looks just like a parameter
1477 to a C function. The last field of the stab is the offset from the
1478 argument pointer, which in most systems is the same as the frame
1479 pointer.
1480
1481 .stabs "name:sym_desc(value parameter)type_ref(int)",
1482 N_PSYM,NIL,NIL,offset_from_arg_ptr
1483
1484 .stabs "in:p1",160,0,0,72
1485
1486 << The examples that follow are based on A1.C >>
1487
1488 @node Protections, , , Gnu C++ stabs
1489 @section Protections
1490
1491
1492 In the simple class definition shown above all member data and
1493 functions were publicly accessable. The example that follows
1494 contrasts public, protected and privately accessable fields and shows
1495 how these protections are encoded in C++ stabs.
1496
1497 Protections for class member data are signified by two characters
1498 embeded in the stab defining the class type. These characters are
1499 located after the name: part of the string. /0 means private, /1
1500 means protected, and /2 means public. If these characters are omited
1501 this means that the member is public. The following C++ source:
1502
1503 @example
1504 class all_data @{
1505 private:
1506 int priv_dat;
1507 protected:
1508 char prot_dat;
1509 public:
1510 float pub_dat;
1511 @};
1512 @end example
1513
1514 generates the following stab to describe the class type all_data.
1515
1516 .stabs "class_name:sym_desc(type)type_def(19)=type_desc(struct)struct_bytes
1517 data_name:/protection(private)type_ref(int),bit_offset,num_bits;
1518 data_name:/protection(protected)type_ref(char),bit_offset,num_bits;
1519 data_name:(/num omited, private)type_ref(float),bit_offset,num_bits;;"
1520 N_LSYM,NIL,NIL,NIL
1521
1522 .stabs "all_data:t19=s12
1523 priv_dat:/01,0,32;prot_dat:/12,32,8;pub_dat:12,64,32;;",128,0,0,0
1524
1525 Protections for member functions are signified by one digit embeded in
1526 the field part of the stab describing the method. The digit is 0 if
1527 private, 1 if protected and 2 if public. Consider the C++ class
1528 definition below:
1529
1530 @example
1531 class all_methods @{
1532 private:
1533 int priv_meth(int in)@{return in;@};
1534 protected:
1535 char protMeth(char in)@{return in;@};
1536 public:
1537 float pubMeth(float in)@{return in;@};
1538 @};
1539 @end example
1540
1541 It generates the following stab. The digit in question is to the left
1542 of an `A' in each case. Notice also that in this case two symbol
1543 descriptors apply to the class name struct tag and struct type.
1544
1545 .stabs "class_name:sym_desc(struct tag&type)type_def(21)=
1546 sym_desc(struct)struct_bytes(1)
1547 meth_name::type_def(22)=sym_desc(method)returning(int);
1548 :args(int);protection(private)modifier(normal)virtual(no);
1549 meth_name::type_def(23)=sym_desc(method)returning(char);
1550 :args(char);protection(protected)modifier(normal)virual(no);
1551 meth_name::type_def(24)=sym_desc(method)returning(float);
1552 :args(float);protection(public)modifier(normal)virtual(no);;",
1553 N_LSYM,NIL,NIL,NIL
1554
1555 .stabs "all_methods:Tt21=s1priv_meth::22=##1;:i;0A.;protMeth::23=##2;:c;1A.;
1556 pubMeth::24=##12;:f;2A.;;",128,0,0,0
1557
1558
1559 @node Method Modifiers, , , Gnu C++ stabs
1560 Method Modifiers (const, volatile, const volatile)
1561
1562 << based on a6.C >>
1563
1564 In the class example described above all the methods have the normal
1565 modifier. This method modifier information is located just after the
1566 protection information for the method. This field has four possible
1567 character values. Normal methods use A, const methods use B, volatile
1568 methods use C, and const volatile methods use D. Consider the class
1569 definition below:
1570
1571 @example
1572 class A @{
1573 public:
1574 int ConstMeth (int arg) const @{ return arg; @};
1575 char VolatileMeth (char arg) volatile @{ return arg; @};
1576 float ConstVolMeth (float arg) const volatile @{return arg; @};
1577 @};
1578 @end example
1579
1580 This class is described by the following stab:
1581
1582 .stabs "class(A):sym_desc(struct)type_def(20)=type_desc(struct)struct_bytes(1)
1583 meth_name(ConstMeth)::type_def(21)sym_desc(method)
1584 returning(int);:arg(int);protection(public)modifier(const)virtual(no);
1585 meth_name(VolatileMeth)::type_def(22)=sym_desc(method)
1586 returning(char);:arg(char);protection(public)modifier(volatile)virt(no)
1587 meth_name(ConstVolMeth)::type_def(23)=sym_desc(method)
1588 returning(float);:arg(float);protection(public)modifer(const volatile)
1589 virutal(no);;", etc...
1590
1591
1592 .stabs "A:T20=s1ConstMeth::21=##1;:i;2B.;VolatileMeth::22=##2;:c;2C.;
1593 ConstVolMeth::23=##12;:f;2D.;;",128,0,0,0
1594
1595
1596 @node Virtual Methods, , , Gnu C++ stabs
1597 @section Virtual Methods
1598
1599 << The following examples are based on a4.C >>
1600
1601 The presence of virtual methods in a class definition adds additional
1602 data to the class description. The extra data is appended to the
1603 description of the virtual method and to the end of the class
1604 description. Consider the class definition below:
1605
1606 @example
1607 class A @{
1608 public:
1609 int Adat;
1610 virtual int A_virt (int arg) @{ return arg; @};
1611 @};
1612 @end example
1613
1614 This results in the stab below describing class A. It defines a new
1615 type (20) which is an 8 byte structure. The first field of the class
1616 struct is Adat, an integer, starting at structure offset 0 and
1617 occupying 32 bits.
1618
1619 The second field in the class struct is not explicitly defined by the
1620 C++ class definition but is implied by the fact that the class
1621 contains a virtual method. This field is the vtable pointer. The
1622 name of the vtable pointer field starts with $vf and continues with a
1623 type reference to the class it is part of. In this example the type
1624 reference for class A is 20 so the name of its vtable pointer field is
1625 $vf20, followed by the usual colon.
1626
1627 Next there is a type definition for the vtable pointer type (21).
1628 This is in turn defined as a pointer to another new type (22).
1629
1630 Type 22 is the vtable itself, which is defined as an array, indexed by
1631 integers, with a high bound of 1, and elements of type 17. Type 17
1632 was the vtable record type defined by the boilerplate C++ type
1633 definitions, as shown earlier.
1634
1635 The bit offset of the vtable pointer field is 32. The number of bits
1636 in the field are not specified when the field is a vtable pointer.
1637
1638 Next is the method definition for the virtual member function A_virt.
1639 Its description starts out using the same format as the non-virtual
1640 member functions described above, except instead of a dot after the
1641 `A' there is an asterisk, indicating that the function is virtual.
1642 Since is is virtual some addition information is appended to the end
1643 of the method description.
1644
1645 The first number represents the vtable index of the method. This is a
1646 32 bit unsigned number with the high bit set, followed by a
1647 semi-colon.
1648
1649 The second number is a type reference to the first base class in the
1650 inheritence hierarchy defining the virtual member function. In this
1651 case the class stab describes a base class so the virtual function is
1652 not overriding any other definition of the method. Therefore the
1653 reference is to the type number of the class that the stab is
1654 describing (20).
1655
1656 This is followed by three semi-colons. One marks the end of the
1657 current sub-section, one marks the end of the method field, and the
1658 third marks the end of the struct definition.
1659
1660 For classes containing virtual functions the very last section of the
1661 string part of the stab holds a type reference to the first base
1662 class. This is preceeded by `~%' and followed by a final semi-colon.
1663
1664 .stabs "class_name(A):type_def(20)=sym_desc(struct)struct_bytes(8)
1665 field_name(Adat):type_ref(int),bit_offset(0),field_bits(32);
1666 field_name(A virt func ptr):type_def(21)=type_desc(ptr to)type_def(22)=
1667 sym_desc(array)index_type_ref(int);NIL;elem_type_ref(vtbl elem type);
1668 bit_offset(32);
1669 meth_name(A_virt)::typedef(23)=sym_desc(method)returning(int);
1670 :arg_type(int),protection(public)normal(yes)virtual(yes)
1671 vtable_index(1);class_first_defining(A);;;~%first_base(A);",
1672 N_LSYM,NIL,NIL,NIL
1673
1674 .stabs "A:t20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
1675
1676
1677 @node Inheritence, , , Gnu C++ stabs
1678 @section Inheritence
1679
1680 Stabs describing C++ derived classes include additional sections that
1681 describe the inheritence hierarchy of the class. A derived class stab
1682 also encodes the number of base classes. For each base class it tells
1683 if the base class is virtual or not, and if the inheritence is private
1684 or public. It also gives the offset into the object of the portion of
1685 the object corresponding to each base class.
1686
1687 This additional information is embeded in the class stab following the
1688 number of bytes in the struct. First the number of base classes
1689 appears bracketed by an exclamation point and a comma.
1690
1691 Then for each base type there repeats a series: two digits, a number,
1692 a comma, another number, and a semi-colon.
1693
1694 The first of the two digits is 1 if the base class is virtual and 0 if
1695 not. The second digit is 2 if the derivation is public and 0 if not.
1696
1697 The number following the first two digits is the offset from the start
1698 of the object to the part of the object pertaining to the base class.
1699
1700 After the comma, the second number is a type_descriptor for the base
1701 type. Finally a semi-colon ends the series, which repeats for each
1702 base class.
1703
1704 The source below defines three base classes A, B, and C and the
1705 derived class D.
1706
1707
1708 @example
1709 class A @{
1710 public:
1711 int Adat;
1712 virtual int A_virt (int arg) @{ return arg; @};
1713 @};
1714
1715 class B @{
1716 public:
1717 int B_dat;
1718 virtual int B_virt (int arg) @{return arg; @};
1719 @};
1720
1721 class C @{
1722 public:
1723 int Cdat;
1724 virtual int C_virt (int arg) @{return arg; @};
1725 @};
1726
1727 class D : A, virtual B, public C @{
1728 public:
1729 int Ddat;
1730 virtual int A_virt (int arg ) @{ return arg+1; @};
1731 virtual int B_virt (int arg) @{ return arg+2; @};
1732 virtual int C_virt (int arg) @{ return arg+3; @};
1733 virtual int D_virt (int arg) @{ return arg; @};
1734 @};
1735 @end example
1736
1737 Class stabs similar to the ones described earlier are generated for
1738 each base class.
1739
1740 .stabs "A:T20=s8Adat:1,0,32;$vf20:21=*22=ar1;0;1;17,32;A_virt::23=##1;:i;2A*-2147483647;20;;;~%20;",128,0,0,0
1741
1742 .stabs "B:Tt25=s8Bdat:1,0,32;$vf25:21,32;B_virt::26=##1;:i;2A*-2147483647;25;;;~%25;",128,0,0,0
1743
1744 .stabs "C:Tt28=s8Cdat:1,0,32;$vf28:21,32;C_virt::29=##1;:i;2A*-2147483647;28;;;~%28;",128,0,0,0
1745
1746 In the stab describing derived class D below, the information about
1747 the derivation of this class is encoded as follows.
1748
1749 .stabs "derived_class_name:symbol_descriptors(struct tag&type)=
1750 type_descriptor(struct)struct_bytes(32)!num_bases(3),
1751 base_virtual(no)inheritence_public(no)base_offset(0),
1752 base_class_type_ref(A);
1753 base_virtual(yes)inheritence_public(no)base_offset(NIL),
1754 base_class_type_ref(B);
1755 base_virtual(no)inheritence_public(yes)base_offset(64),
1756 base_class_type_ref(C); etc...
1757
1758 .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt::32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
1759
1760
1761 @node Virtual Base Classes, , , Gnu C++ stabs
1762 @section Virtual Base Classes
1763
1764 A derived class object consists of a concatination in memory of the
1765 data areas defined by each base class, starting with the leftmost and
1766 ending with the rightmost in the list of base classes. The exception
1767 to this rule is for virtual inheritence. In the example above, class
1768 D inherits virtually from base class B. This means that an instance
1769 of a D object will not contain it's own B part but merely a pointer to
1770 a B part, known as a virtual base pointer.
1771
1772 In a derived class stab, the base offset part of the derivation
1773 information, described above, shows how the base class parts are
1774 ordered. The base offset for a virtual base class is always given as
1775 0. Notice that the base offset for B is given as 0 even though B is
1776 not the first base class. The first base class A starts at offset 0.
1777
1778 The field information part of the stab for class D describes the field
1779 which is the pointer to the virtual base class B. The vbase pointer
1780 name is $vb followed by a type reference to the virtual base class.
1781 Since the type id for B in this example is 25, the vbase pointer name
1782 is $vb25.
1783
1784 .stabs "D:Tt31=s32!3,000,20;100,25;0264,28;$vb25:24,128;Ddat:1,160,32;A_virt::32=##1;:i;2A*-2147483647;20;;B_virt::32:i;2A*-2147483647;25;;C_virt::32:i;2A*-2147483647;28;;D_virt::32:i;2A*-2147483646;31;;;~%20;",128,0,0,0
1785
1786 Following the name and a semicolon is a type reference describing the
1787 type of the virtual base class pointer, in this case 24. Type 24 was
1788 defined earlier as the type of the B class `this` pointer, $t. The
1789 `this' pointer for a class is a pointer to the class type.
1790
1791 .stabs "$t:P24=*25=xsB:",64,0,0,8
1792
1793 Finally the field offset part of the vbase pointer field description
1794 shows that the vbase pointer is the first field in the D object,
1795 before any data fields defined by the class. The layout of a D class
1796 object is a follows, Adat at 0, the vtable pointer for A at 32, Cdat
1797 at 64, the vtable pointer for C at 96, the virtual ase pointer for B
1798 at 128, and Ddat at 160.
1799
1800
1801 @node Static Members, , , Gnu C++ stabs
1802 @section Static Members
1803
1804 The data area for a class is a concatination of the space used by the
1805 data members of the class. If the class has virtual methods a vtable
1806 pointer follows the class data. The field offset part of each field
1807 description in the class stab shows this ordering.
1808
1809 << how is this reflected in stabs? >>
1810
1811 @node Example2.c, Example2.s, , Top
1812 @appendix Example2.c - source code for extended example
1813
1814 @example
1815 1 char g_foo = 'c';
1816 2 register int g_bar asm ("%g5");
1817 3 static int s_g_repeat = 2;
1818 4 int (*g_pf)();
1819 5
1820 6 struct s_tag @{
1821 7 int s_int;
1822 8 float s_float;
1823 9 char s_char_vec[8];
1824 10 struct s_tag* s_next;
1825 11 @} g_an_s;
1826 12
1827 13 typedef struct s_tag s_typedef;
1828 14
1829 15 char char_vec[3] = @{'a','b','c'@};
1830 16
1831 17 main (argc, argv)
1832 18 int argc;
1833 19 char* argv[];
1834 20 @{
1835 21 static float s_flap;
1836 22 int times;
1837 23 for (times=0; times < s_g_repeat; times++)@{
1838 24 int inner;
1839 25 printf ("Hello world\n");
1840 26 @}
1841 27 @};
1842 28
1843 29 enum e_places @{first,second=3,last@};
1844 30
1845 31 static s_proc (s_arg, s_ptr_arg, char_vec)
1846 32 s_typedef s_arg;
1847 33 s_typedef* s_ptr_arg;
1848 34 char* char_vec;
1849 35 @{
1850 36 union u_tag @{
1851 37 int u_int;
1852 38 float u_float;
1853 39 char* u_char;
1854 40 @} an_u;
1855 41 @}
1856 42
1857 43
1858 @end example
1859
1860 @node Example2.s, , Example2.c, Top
1861 @appendix Example2.s - assembly code for extended example
1862
1863 @example
1864 1 gcc2_compiled.:
1865 2 .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
1866 3 .stabs "example2.c",100,0,0,Ltext0
1867 4 .text
1868 5 Ltext0:
1869 6 .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,0
1870 7 .stabs "char:t2=r2;0;127;",128,0,0,0
1871 8 .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,0
1872 9 .stabs "unsigned int:t4=r1;0;-1;",128,0,0,0
1873 10 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,0
1874 11 .stabs "short int:t6=r1;-32768;32767;",128,0,0,0
1875 12 .stabs "long long int:t7=r1;0;-1;",128,0,0,0
1876 13 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0
1877 14 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,0
1878 15 .stabs "signed char:t10=r1;-128;127;",128,0,0,0
1879 16 .stabs "unsigned char:t11=r1;0;255;",128,0,0,0
1880 17 .stabs "float:t12=r1;4;0;",128,0,0,0
1881 18 .stabs "double:t13=r1;8;0;",128,0,0,0
1882 19 .stabs "long double:t14=r1;8;0;",128,0,0,0
1883 20 .stabs "void:t15=15",128,0,0,0
1884 21 .stabs "g_foo:G2",32,0,0,0
1885 22 .global _g_foo
1886 23 .data
1887 24 _g_foo:
1888 25 .byte 99
1889 26 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat
1890 27 .align 4
1891 28 _s_g_repeat:
1892 29 .word 2
1893 30 .stabs "s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;",128,0,0,0
1894 31 .stabs "s_typedef:t16",128,0,0,0
1895 32 .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
1896 33 .global _char_vec
1897 34 .align 4
1898 35 _char_vec:
1899 36 .byte 97
1900 37 .byte 98
1901 38 .byte 99
1902 39 .reserve _s_flap.0,4,"bss",4
1903 40 .text
1904 41 .align 4
1905 42 LC0:
1906 43 .ascii "Hello world\12\0"
1907 44 .align 4
1908 45 .global _main
1909 46 .proc 1
1910 47 _main:
1911 48 .stabn 68,0,20,LM1
1912 49 LM1:
1913 50 !#PROLOGUE# 0
1914 51 save %sp,-144,%sp
1915 52 !#PROLOGUE# 1
1916 53 st %i0,[%fp+68]
1917 54 st %i1,[%fp+72]
1918 55 call ___main,0
1919 56 nop
1920 57 LBB2:
1921 58 .stabn 68,0,23,LM2
1922 59 LM2:
1923 60 st %g0,[%fp-20]
1924 61 L2:
1925 62 sethi %hi(_s_g_repeat),%o0
1926 63 ld [%fp-20],%o1
1927 64 ld [%o0+%lo(_s_g_repeat)],%o0
1928 65 cmp %o1,%o0
1929 66 bge L3
1930 67 nop
1931 68 LBB3:
1932 69 .stabn 68,0,25,LM3
1933 70 LM3:
1934 71 sethi %hi(LC0),%o1
1935 72 or %o1,%lo(LC0),%o0
1936 73 call _printf,0
1937 74 nop
1938 75 .stabn 68,0,26,LM4
1939 76 LM4:
1940 77 LBE3:
1941 78 .stabn 68,0,23,LM5
1942 79 LM5:
1943 80 L4:
1944 81 ld [%fp-20],%o0
1945 82 add %o0,1,%o1
1946 83 st %o1,[%fp-20]
1947 84 b,a L2
1948 85 L3:
1949 86 .stabn 68,0,27,LM6
1950 87 LM6:
1951 88 LBE2:
1952 89 .stabn 68,0,27,LM7
1953 90 LM7:
1954 91 L1:
1955 92 ret
1956 93 restore
1957 94 .stabs "main:F1",36,0,0,_main
1958 95 .stabs "argc:p1",160,0,0,68
1959 96 .stabs "argv:p20=*21=*2",160,0,0,72
1960 97 .stabs "s_flap:V12",40,0,0,_s_flap.0
1961 98 .stabs "times:1",128,0,0,-20
1962 99 .stabn 192,0,0,LBB2
1963 100 .stabs "inner:1",128,0,0,-24
1964 101 .stabn 192,0,0,LBB3
1965 102 .stabn 224,0,0,LBE3
1966 103 .stabn 224,0,0,LBE2
1967 104 .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0
1968 105 .stabs "u_tag:T23=u4u_int:1,0,32;u_float:12,0,32;u_char:21,0,32;;",128,0,0,0
1969 106 .align 4
1970 107 .proc 1
1971 108 _s_proc:
1972 109 .stabn 68,0,35,LM8
1973 110 LM8:
1974 111 !#PROLOGUE# 0
1975 112 save %sp,-120,%sp
1976 113 !#PROLOGUE# 1
1977 114 mov %i0,%o0
1978 115 st %i1,[%fp+72]
1979 116 st %i2,[%fp+76]
1980 117 LBB4:
1981 118 .stabn 68,0,41,LM9
1982 119 LM9:
1983 120 LBE4:
1984 121 .stabn 68,0,41,LM10
1985 122 LM10:
1986 123 L5:
1987 124 ret
1988 125 restore
1989 126 .stabs "s_proc:f1",36,0,0,_s_proc
1990 127 .stabs "s_arg:p16",160,0,0,0
1991 128 .stabs "s_ptr_arg:p18",160,0,0,72
1992 129 .stabs "char_vec:p21",160,0,0,76
1993 130 .stabs "an_u:23",128,0,0,-20
1994 131 .stabn 192,0,0,LBB4
1995 132 .stabn 224,0,0,LBE4
1996 133 .stabs "g_bar:r1",64,0,0,5
1997 134 .stabs "g_pf:G24=*25=f1",32,0,0,0
1998 135 .common _g_pf,4,"bss"
1999 136 .stabs "g_an_s:G16",32,0,0,0
2000 137 .common _g_an_s,20,"bss"
2001 @end example
2002
2003
2004 @node Quick reference, Expanded reference, , Top
2005 @appendix Quick reference
2006
2007 @menu
2008 * Stab types:: Table A: Symbol types from stabs
2009 * Assembler types:: Table B: Symbol types from assembler and linker
2010 * Symbol descriptors:: Table C
2011 * Type Descriptors:: Table D
2012 @end menu
2013
2014 @node Stab types, Assembler types, , Quick reference
2015 @section Table A: Symbol types from stabs
2016
2017 Table A lists stab types sorted by type number. Stab type numbers are
2018 32 and greater. This is the full list of stab numbers, including stab
2019 types that are used in languages other than C.
2020
2021 The #define names for these stab types are defined in:
2022 devo/include/aout/stab.def
2023
2024 @example
2025 type type #define used to describe
2026 dec hex name source program feature
2027 -------------------------------------------------------------------------------
2028 32 0x20 N_GYSM global symbol
2029 34 0X22 N_FNAME function name (for BSD Fortran)
2030 36 0x24 N_FUN function name or text segment variable for C
2031 38 0x26 N_STSYM static symbol (data segment w/internal linkage)
2032 40 0x28 N_LCSYM .lcomm symbol(BSS-seg variable w/internal linkage)
2033 42 0x2a N_MAIN Name of main routine (not used in C)
2034 48 0x30 N_PC global symbol (for Pascal)
2035 50 0x32 N_NSYMS number of symbols (according to Ultrix V4.0)
2036 52 0x34 N_NOMAP no DST map for sym (according to Ultrix V4.0)
2037 64 0x40 N_RSYM register variable
2038 66 0x42 N_M2C Modula-2 compilation unit
2039 68 0x44 N_SLINE line number in text segment
2040 70 0x46 N_DSLINE line number in data segment
2041
2042 72 0x48 N_BSLINE line number in bss segment
2043 72 0x48 N_BROWS Sun source code browser, path to .cb file
2044
2045 74 0x4a N_DEFD Gnu Modula2 definition module dependency
2046
2047 80 0x50 N_EHDECL Gnu C++ exception variable
2048 80 0x50 N_MOD2 Modula2 info "for imc" (according to Ultrix V4.0)
2049
2050 84 0x54 N_CATCH Gnu C++ "catch" clause
2051 96 0x60 N_SSYM structure of union element
2052 100 0x64 N_SO path and name of source file
2053 128 0x80 N_LSYM automatic var in the stack (also used for type desc.)
2054 130 0x82 N_BINCL beginning of an include file (Sun only)
2055 132 0x84 N_SOL Name of sub-source (#include) file.
2056 160 0xa0 N_PSYM parameter variable
2057 162 0xa2 N_EINCL end of an include file
2058 164 0xa4 N_ENTRY alternate entry point
2059 192 0xc0 N_LBRAC beginning of a lexical block
2060 194 0xc2 N_EXCL place holder for a deleted include file
2061 196 0xc4 N_SCOPE modula2 scope information (Sun linker)
2062 224 0xe0 N_RBRAC end of a lexical block
2063 226 0xe2 N_BCOMM begin named common block
2064 228 0xe4 N_ECOMM end named common block
2065 232 0xe8 N_ECOML end common (local name)
2066
2067 << used on Gould systems for non-base registers syms >>
2068 240 0xf0 N_NBTEXT ??
2069 242 0xf2 N_NBDATA ??
2070 244 0xf4 N_NBBSS ??
2071 246 0xf6 N_NBSTS ??
2072 248 0xf8 N_NBLCS ??
2073 @end example
2074
2075 @node Assembler types, Symbol descriptors, Stab types, Quick reference
2076 @section Table B: Symbol types from assembler and linker
2077
2078 Table B shows the types of symbol table entries that hold assembler
2079 and linker symbols.
2080
2081 The #define names for these n_types values are defined in
2082 /include/aout/aout64.h
2083
2084 @example
2085 dec hex #define
2086 n_type n_type name used to describe
2087 -----------------------------------------------------------------------------
2088 1 0x0 N_UNDF undefined symbol
2089 2 0x2 N_ABS absolute symbol -- defined at a particular address
2090 3 0x3 extern " (vs. file scope)
2091 4 0x4 N_TEXT text symbol -- defined at offset in text segment
2092 5 0x5 extern " (vs. file scope)
2093 6 0x6 N_DATA data symbol -- defined at offset in data segment
2094 7 0x7 extern " (vs. file scope)
2095 8 0x8 N_BSS BSS symbol -- defined at offset in zero'd segment
2096 9 extern " (vs. file scope)
2097
2098 12 0x0C N_FN_SEQ func name for Sequent compilers (stab exception)
2099
2100 49 0x12 N_COMM common sym -- visable after shared lib dynamic link
2101 31 0x1f N_FN file name of a .o file
2102 @end example
2103
2104 @node Symbol descriptors, Type descriptors, Assembler types, Quick reference
2105 @section Table C: Symbol descriptors
2106
2107 @example
2108 descriptor meaning
2109 -------------------------------------------------
2110 (empty) local variable
2111 f local function
2112 F global function
2113 G global variable
2114 p value parameter
2115 r register variable
2116 S static global variable
2117 t type name
2118 T enumeration, struct or type tag
2119 V static local variable
2120 @end example
2121
2122 @node Type Descriptors, , Symbol descriptors, Quick reference
2123 @section Table D: Type Descriptors
2124
2125 @example
2126 descriptor meaning
2127 -------------------------------------
2128 (empty) type reference
2129 a array type
2130 e enumeration type
2131 f function type
2132 r range type
2133 s structure type
2134 u union specifications
2135 * pointer type
2136 @end example
2137
2138
2139 @node Expanded reference, , Quick reference, Top
2140 @appendix Expanded reference by stab type.
2141
2142 Format of an entry:
2143
2144 The first line is the symbol type expressed in decimal, hexadecimal,
2145 and as a #define (see devo/include/aout/stab.def).
2146
2147 The second line describes the language constructs the symbol type
2148 represents.
2149
2150 The third line is the stab format with the significant stab fields
2151 named and the rest NIL.
2152
2153 Subsequent lines expand upon the meaning and possible values for each
2154 significant stab field. # stands in for the type descriptor.
2155
2156 Finally, any further information.
2157
2158 ----------------------------------------------------------------------
2159 32 - 0x20 - N_GYSM
2160 Global variable.
2161
2162 .stabs "name", N_GSYM, NIL, NIL, NIL
2163
2164 "name" -> "symbol_name:#type"
2165 # -> G
2166
2167 Only the "name" field is significant. the location of the variable is
2168 obtained from the corresponding external symbol.
2169
2170 ----------------------------------------------------------------------
2171 34 - 0x22 - N_FNAME
2172 Function name (for BSD Fortran)
2173
2174 .stabs "name", N_FNAME, NIL, NIL, NIL
2175
2176 "name" -> "function_name"
2177
2178 Only the "name" field is significant. The location of the symbol is
2179 obtained from the corresponding extern symbol.
2180
2181 ----------------------------------------------------------------------
2182 36 - 0x24 - N_FUN
2183 Function name or text segment variable for C.
2184
2185 .stabs "name", N_FUN, NIL, desc, value
2186
2187 For functions:
2188 -------------
2189 "name" -> "proc_name:#return_type"
2190 # -> F (global function)
2191 f (local function)
2192 desc -> line num for proc start. (GCC doesn't set and DBX doesn't miss it.)
2193 value -> Code address of proc start.
2194
2195 For text segment variables:
2196 --------------------------
2197 <<How to create one?>>
2198
2199 ----------------------------------------------------------------------
2200 38 - 0x26 - N_STSYM
2201 Initialized static symbol (data segment w/internal linkage).
2202
2203 .stabs "name", N_STSYM, NIL, NIL, value
2204
2205 "name" -> "symbol_name#type"
2206 # -> S (scope global to compilation unit)
2207 -> V (scope local to a procedure)
2208 value -> Data Address
2209
2210 ----------------------------------------------------------------------
2211 40 - 0x28 - N_LCSYM
2212 Unitialized static (.lcomm) symbol(BSS segment w/internal linkage).
2213
2214 .stabs "name", N_LCLSYM, NIL, NIL, value
2215
2216 "name" -> "symbol_name#type"
2217 # -> S (scope global to compilation unit)
2218 -> V (scope local to procedure)
2219 value -> BSS Address
2220
2221 ----------------------------------------------------------------------
2222 42 - 0x2a - N_MAIN
2223 Name of main routine (not used in C)
2224
2225 .stabs "name", N_MAIN, NIL, NIL, NIL
2226
2227 "name" -> "name_of_main_routine"
2228
2229 ----------------------------------------------------------------------
2230 48 - 0x30 - N_PC
2231 Global symbol (for Pascal)
2232
2233 .stabs "name", N_PC, NIL, NIL, value
2234
2235 "name" -> "symbol_name" <<?>>
2236 value -> supposedly the line number (stab.def is skeptical)
2237
2238 stabdump.c says:
2239
2240 global pascal symbol: name,,0,subtype,line
2241 << subtype? >>
2242
2243 ----------------------------------------------------------------------
2244 50 - 0x32 - N_NSYMS
2245 Number of symbols (according to Ultrix V4.0)
2246
2247 0, files,,funcs,lines (stab.def)
2248
2249 ----------------------------------------------------------------------
2250
2251 52 - 0x34 - N_NOMAP
2252 no DST map for sym (according to Ultrix V4.0)
2253
2254 name, ,0,type,ignored (stab.def)
2255 ----------------------------------------------------------------------
2256 64 - 0x40 - N_RSYM
2257 register variable
2258
2259 .stabs "name:type",N_RSYM,0,RegSize,RegNumber (Sun doc)
2260
2261 ----------------------------------------------------------------------
2262 66 - 0x42 - N_M2C
2263 Modula-2 compilation unit
2264
2265 .stabs "name", N_M2C, 0, desc, value
2266
2267 "name" -> "unit_name,unit_time_stamp[,code_time_stamp]
2268 desc -> unit_number
2269 value -> 0 (main unit)
2270 1 (any other unit)
2271
2272 -----------------------------------------------------------------------
2273 68 - 0x44 - N_SLINE
2274 Line number in text segment
2275
2276 .stabn N_SLINE, 0, desc, value
2277
2278 desc -> line_number
2279 value -> code_address (relocatable addr where the corresponding code starts)
2280
2281 For single source lines that generate discontiguous code, such as flow
2282 of control statements, there may be more than one N_SLINE stab for the
2283 same source line. In this case there is a stab at the start of each
2284 code range, each with the same line number.
2285
2286 -----------------------------------------------------------------------
2287 70 - 0x46 - N_DSLINE
2288 Line number in data segment
2289
2290 .stabn N_DSLINE, 0, desc, value
2291
2292 desc -> line_number
2293 value -> data_address (relocatable addr where the corresponding code starts)
2294
2295 See comment for N_SLINE above.
2296
2297 -------------------------------------------------------------------------
2298 72 - 0x48 - N_BSLINE
2299 Line number in bss segment
2300
2301 .stabn N_BSLINE, 0, desc, value
2302
2303 desc -> line_number
2304 value -> bss_address (relocatable addr where the corresponding code starts)
2305
2306 See comment for N_SLINE above.
2307
2308 -------------------------------------------------------------------------
2309 72 0x48 N_BROWS
2310 Sun source code browser, path to .cb file
2311
2312 <<?>>
2313 "path to associated .cb file"
2314
2315 Note: type field value overlaps with N_BSLINE
2316
2317 -------------------------------------------------------------------------
2318 74 0x4a N_DEFD
2319 Gnu Modula2 definition module dependency
2320
2321 GNU Modula-2 definition module dependency. Value is the modification
2322 time of the definition file. Other is non-zero if it is imported with
2323 the GNU M2 keyword %INITIALIZE. Perhaps N_M2C can be used if there
2324 are enough empty fields?
2325
2326 -------------------------------------------------------------------------
2327 80 0x50 N_EHDECL
2328 Gnu C++ exception variable <<?>>
2329
2330 "name is variable name"
2331
2332 Note: conflicts with N_MOD2.
2333
2334 -------------------------------------------------------------------------
2335 80 0x50 N_MOD2 Modula2 info "for imc" (according to Ultrix V4.0)
2336
2337 Note: conflicts with N_EHDECL <<?>>
2338
2339 -------------------------------------------------------------------------
2340 84 0x54 N_CATCH Gnu C++ "catch" clause
2341
2342 GNU C++ `catch' clause. Value is its address. Desc is nonzero if
2343 this entry is immediately followed by a CAUGHT stab saying what
2344 exception was caught. Multiple CAUGHT stabs means that multiple
2345 exceptions can be caught here. If Desc is 0, it means all exceptions
2346 are caught here.
2347
2348 -------------------------------------------------------------------------
2349 96 - 0x60 - N_SSYM
2350 Structure or union element
2351
2352 Value is offset in the structure. <<?looking at structs and unions in C
2353 I didn't see these>>
2354
2355 -------------------------------------------------------------------------
2356 100 - 0x64 - N_SO
2357 Path and name of source file containing main routine
2358
2359 .stabs "name", N_SO, NIL, NIL, value
2360
2361 "name" -> /path/to/source/file
2362 -> source_file_terminal_name
2363
2364 value -> the starting text address of the compilation.
2365
2366 These are found two in a row. The name field of the first N_SO
2367 contains the path to the source file. The name field of the second
2368 N_SO contains the terminal name of the source file itself.
2369
2370 -------------------------------------------------------------------------
2371 128 - 0x80 - N_LSYM
2372 Automatic var in the stack (also used for type descriptors.)
2373
2374 .stabs "name" N_LSYM, NIL, NIL, value
2375
2376 For stack based local variables:
2377 --------------------------------
2378
2379 "name" -> name of the variable
2380 value -> offset from frame pointer (negative)
2381
2382 For type descriptors:
2383 ---------------------
2384
2385 "name" -> "name_of_the_type:#type"
2386 # -> t
2387
2388 type -> type_ref (or) type_def
2389
2390 type_ref -> type_number
2391 type_def -> type_number=type_desc etc.
2392
2393 Type may be either a type reference or a type definition. A type
2394 reference is a number that refers to a previously defined type. A
2395 type definition is the number that will refer to this type, followed
2396 by an equals sign, a type descriptor and the additional data that
2397 defines the type. See the Table D for type descriptors and the
2398 section on types for what data follows each type descriptor.
2399
2400 -------------------------------------------------------------------------
2401 130 - 0x82 - N_BINCL
2402
2403 Beginning of an include file (Sun only)
2404
2405 Beginning of an include file. Only Sun uses this. In an object file,
2406 only the name is significant. The Sun linker puts data into some of
2407 the other fields.
2408
2409 -------------------------------------------------------------------------
2410 132 - 0x84 - N_SOL
2411
2412 Name of a sub-source file (#include file). Value is starting address
2413 of the compilation.
2414 <<?>>
2415
2416 -------------------------------------------------------------------------
2417 160 - 0xa0 - N_PSYM
2418
2419 Parameter variable
2420
2421 stabs. "name", N_PSYM, NIL, NIL, value
2422
2423 "name" -> "param_name:#type"
2424 # -> p (value parameter)
2425 -> i (value parameter by reference, indirect access)
2426 -> v (variable parameter by reference)
2427 -> C ( read-only parameter, conformant array bound)
2428 -> x (confomant array value parameter)
2429 -> pP (<<??>>)
2430 -> pF (<<??>>)
2431 -> X (function result variable)
2432 -> b (based variable)
2433
2434 value -> offset from the argument pointer (positive).
2435
2436 On most machines the argument pointer is the same as the frame
2437 pointer.
2438
2439 -------------------------------------------------------------------------
2440 162 - 0xa2 - N_EINCL
2441
2442 End of an include file. This and N_BINCL act as brackets around the
2443 file's output. In an ojbect file, there is no significant data in
2444 this entry. The Sun linker p8uts data into some of the fields.
2445 <<?>>
2446
2447 -------------------------------------------------------------------------
2448 164 - 0xa4 - N_ENTRY
2449
2450 Alternate entry point.
2451 Value is its address.
2452 <<?>>
2453
2454 -------------------------------------------------------------------------
2455 192 - 0xc0 - N_LBRAC
2456
2457 Beginning of a lexical block (left brace). The variable defined
2458 inside the block precede the N_LBRAC symbol. Or can they follow as
2459 well as long as a new N_FUNC was not encountered. <<?>>
2460
2461 .stabn N_LBRAC, NIL, NIL, value
2462
2463 value -> code address of block start.
2464
2465 -------------------------------------------------------------------------
2466 194 - 0xc2 - N_EXCL
2467
2468 Place holder for a deleted include file. Replaces a N_BINCL and
2469 everything up to the corresponding N_EINCL. The Sun linker generates
2470 these when it finds multiple indentical copies of the symbols from an
2471 included file. This appears only in output from the Sun linker.
2472 <<?>>
2473
2474 -------------------------------------------------------------------------
2475 196 - 0xc4 - N_SCOPE
2476
2477 Modula2 scope information (Sun linker)
2478 <<?>>
2479
2480 -------------------------------------------------------------------------
2481 224 - 0xe0 - N_RBRAC
2482
2483 End of a lexical block (right brace)
2484
2485 .stabn N_RBRAC, NIL, NIL, value
2486
2487 value -> code address of the end of the block.
2488
2489 -------------------------------------------------------------------------
2490 226 - 0xe2 - N_BCOMM
2491
2492 Begin named common block.
2493
2494 Only the name is significant.
2495 <<?>>
2496
2497 -------------------------------------------------------------------------
2498 228 - 0xe4 - N_ECOMM
2499
2500 End named common block.
2501
2502 Only the name is significant and it should match the N_BCOMM
2503 <<?>>
2504
2505 -------------------------------------------------------------------------
2506 232 - 0xe8 - N_ECOML
2507
2508 End common (local name)
2509
2510 value is address.
2511 <<?>>
2512
2513 -------------------------------------------------------------------------
2514 << used on Gould systems for non-base registers syms, values assigned
2515 at random, need real info from Gould. >>
2516 <<?>>
2517
2518 240 0xf0 N_NBTEXT ??
2519 242 0xf2 N_NBDATA ??
2520 244 0xf4 N_NBBSS ??
2521 246 0xf6 N_NBSTS ??
2522 248 0xf8 N_NBLCS ??
2523
2524 -------------------------------------------------------------------------
2525 - 0xfe - N_LENG
2526
2527 Second symbol entry containing a length-value for the preceding entry.
2528 The value is the length.
2529
2530 @node Questions, , , Top
2531 @appendix Questions and anomolies
2532
2533 @itemize @bullet
2534 @item
2535 For GNU C stabs defining local and global variables (N_LSYM and
2536 N_GSYM), the desc field is supposed to contain the source line number
2537 on which the variable is defined. In reality the desc field is always
2538 0. (This behavour is defined in dbxout.c and putting a line number in
2539 desc is controlled by #ifdef WINNING_GDB which defaults to false). Gdb
2540 supposedly uses this information if you say 'list var'. In reality
2541 var can be a variable defined in the program and gdb says `function
2542 var not defined'
2543
2544 @item
2545 In Gnu C stabs there seems to be no way to differentiate tag types:
2546 structures, unions, and enums (symbol descriptor T) and typedefs
2547 (symbol descriptor t) defined at file scope from types defined locally
2548 to a procedure or other more local scope. They all use the N_LSYM
2549 stab type. Types defined at procedure scope are emited after the
2550 N_RBRAC of the preceeding function and before the code of the
2551 procedure in which they are defined. This is exactly the same as
2552 types defined in the source file between the two procedure bodies.
2553 GDB overcompensates by placing all types in block #1 the block for
2554 symbols of file scope. This is true for default, -ansi and
2555 -traditional compiler options. (p0001063-gcc, p0001066-gdb)
2556
2557 @item
2558 What ends the procedure scope? Is it the proc block's N_RBRAC or the
2559 next N_FUN? (I believe its the first.)
2560
2561 @item
2562 The comment in xcoff.h says DBX_STATIC_CONST_VAR_CODE is used for
2563 static const variables. DBX_STATIC_CONST_VAR_CODE is set to N_FUN by
2564 default, in dbxout.c. If included, xcoff.h redefines it to N_STSYM.
2565 But testing the default behaviour, my Sun4 native example shows
2566 N_STSYM not N_FUN is used to describe file static initialized
2567 variables. (the code tests for TREE_READONLY(decl) &&
2568 !TREE_THIS_VOLATILE(decl) and if true uses DBX_STATIC_CONST_VAR_CODE).
2569
2570 @item
2571 Global variable stabs don't have location information. This comes
2572 from the external symbol for the same variable. The external symbol
2573 has a leading underbar on the _name of the variable and the stab does
2574 not. How do we know these two symbol table entries are talking about
2575 the same symbol when their names are different?
2576
2577 @item
2578 Can gcc be configured to output stabs the way the Sun compiler
2579 does, so that their native debugging tools work? <NO?> It doesn't by
2580 default. GDB reads either format of stab. (gcc or SunC). How about
2581 dbx?
2582 @end itemize
2583
2584 @node xcoff-differences, Sun-differences, , Top
2585 @appendix Differences between GNU stabs in a.out and GNU stabs in xcoff
2586
2587 (The AIX/RS6000 native object file format is xcoff with stabs)
2588
2589 @itemize @bullet
2590 @item
2591 Instead of .stabs, xcoff uses .stabx.
2592
2593 @item
2594 The data fields of an xcoff .stabx are in a different order than an
2595 a.out .stabs. The order is: string, value, type. The desc and null
2596 fields present in a.out stabs are missing in xcoff stabs. For N_GSYM
2597 the value field is the name of the symbol.
2598
2599 @item
2600 BSD a.out stab types map to AIX xcoff storage classes. In general the
2601 mapping is N_STABTYPE becomes C_STABTYPE. Some stab types in a.out
2602 are not supported in xcoff. See Table E. for full mappings.
2603
2604 exception:
2605 initialised static N_STSYM and un-initialized static N_LCSYM both map
2606 to the C_STSYM storage class. But the destinction is preserved
2607 because in xcoff N_STSYM and N_LCSYM must be emited in a named static
2608 block. Begin the block with .bs s[RW] data_section_name for N_STSYM
2609 or .bs s bss_section_name for N_LCSYM. End the block with .es
2610
2611 @item
2612 xcoff stabs describing tags and typedefs use the N_DECL (0x8c)instead
2613 of N_LSYM stab type.
2614
2615 @item
2616 xcoff uses N_RPSYM (0x8e) instead of the N_RSYM stab type for register
2617 variables. If the register variable is also a value parameter, then
2618 use R instead of P for the symbol descriptor.
2619
2620 6.
2621 xcoff uses negative numbers as type references to the basic types.
2622 There are no boilerplate type definitions emited for these basic
2623 types. << make table of basic types and type numbers for C >>
2624
2625 @item
2626 xcoff .stabx sometimes don't have the name part of the string field.
2627
2628 @item
2629 xcoff uses a .file stab type to represent the source file name. There
2630 is no stab for the path to the source file.
2631
2632 @item
2633 xcoff uses a .line stab type to represent source lines. The format
2634 is: .line line_number.
2635
2636 @item
2637 xcoff emits line numbers relative to the start of the current
2638 function. The start of a function is marked by .bf. If a function
2639 includes lines from a seperate file, then those line numbers are
2640 absolute line numbers in the <<sub-?>> file being compiled.
2641
2642 @item
2643 The start of current include file is marked with: .bi "filename" and
2644 the end marked with .ei "filename"
2645
2646 @item
2647 If the xcoff stab is a N_FUN (C_FUN) then follow the string field with
2648 ,. instead of just ,
2649
2650 @item
2651 The symbol descriptor for register parameters is P for a.out and R for
2652 xcoff.
2653 @end itemize
2654
2655
2656 (I think that's it for .s file differences. They could stand to be
2657 better presented. This is just a list of what I have noticed so far.
2658 There are a *lot* of differences in the information in the symbol
2659 tables of the executable and object files.)
2660
2661 Table E: mapping a.out stab types to xcoff storage classes
2662
2663 @example
2664 stab type storage class
2665 -------------------------------
2666 N_GSYM C_GSYM
2667 N_FNAME unknown
2668 N_FUN C_FUN
2669 N_STSYM C_STSYM
2670 N_LCSYM C_STSYM
2671 N_MAIN unkown
2672 N_PC unknown
2673 N_RSYM C_RSYM
2674 N_RPSYM (0x8e) C_RPSYM
2675 N_M2C unknown
2676 N_SLINE unknown
2677 N_DSLINE unknown
2678 N_BSLINE unknown
2679 N_BROWSE unchanged
2680 N_CATCH unknown
2681 N_SSYM unknown
2682 N_SO unknown
2683 N_LSYM C_LSYM
2684 N_DECL (0x8c) C_DECL
2685 N_BINCL unknown
2686 N_SOL unknown
2687 N_PSYM C_PSYM
2688 N_EINCL unknown
2689 N_ENTRY C_ENTRY
2690 N_LBRAC unknown
2691 N_EXCL unknown
2692 N_SCOPE unknown
2693 N_RBRAC unknown
2694 N_BCOMM C_BCOMM
2695 N_ECOMM C_ECOMM
2696 N_ECOML C_ECOML
2697
2698 N_LENG unknown
2699 @end example
2700
2701 @node Sun-differences, , xcoff-differences, Top
2702 @appendix Differences between GNU stabs and Sun native stabs.
2703
2704 @itemize @bullet
2705 @item
2706 Gnu C stabs define *all* types, file or procedure scope, as
2707 N_LSYM. Sun doc talks about using N_GSYM too.
2708
2709 @item
2710 Gnu C stabs use `ar' as type descriptor when defining arrays vs. just
2711 `a' in Sun doc.
2712
2713 @item
2714 Stabs describing block scopes, N_LBRAC and N_RBRAC are supposed to
2715 contain the nesting level of the block in the desc field, re Sun doc.
2716 GNU stabs always have 0 in that field.
2717
2718 @item
2719 Sun C stabs use type number pairs in the format (a,b) where a is a
2720 number starting with 1 and incremented for each sub-source file in the
2721 compilation. b is a number starting with 1 and incremented for each
2722 new type defined in the compilation. Gnu C stabs use the type number
2723 alone, with no source file number.
2724 @end itemize
2725
2726 @contents
2727 @bye