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