⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stabs.texinfo

📁 早期freebsd实现
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
\input texinfo@setfilename stabs.info@ifinfo@formatSTART-INFO-DIR-ENTRY* Stabs: (stabs).               The "stabs" debugging information format.END-INFO-DIR-ENTRY@end format@end ifinfo@ifinfoThis document describes GNU stabs (debugging symbol tables) in a.out files.Copyright 1992 Free Software Foundation, Inc.Contributed by Cygnus Support.  Written by Julia Menapace.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.@ignorePermission is granted to process this file through Tex and print theresults, provided the printed document carries copying permissionnotice identical to this one except for the removal of this paragraph(this paragraph not being relevant to the printed manual).@end ignorePermission is granted to copy or distribute modified versions of thismanual under the terms of the GPL (for which purpose this text may beregarded as a program in the language TeX).@end ifinfo@setchapternewpage odd@settitle STABS@titlepage@title The ``stabs'' debug format@author Julia Menapace@author Cygnus Support@page@tex\def\$#1${{#1}}  % Kluge: collect RCS revision info without $...$\xdef\manvers{\$Revision: 2.10 $}  % For use in headers, footers too{\parskip=0pt\hfill Cygnus Support\par\hfill \manvers\par\hfill \TeX{}info \texinfoversion\par}@end tex@vskip 0pt plus 1filllCopyright @copyright{} 1992 Free Software Foundation, Inc.Contributed by Cygnus Support.Permission is granted to make and distribute verbatim copies ofthis manual provided the copyright notice and this permission noticeare preserved on all copies.@end titlepage@ifinfo@node Top@top The "stabs" representation of debugging informationThis document describes the GNU stabs debugging format in a.out files.@menu* Overview::                    Overview of stabs* Program structure::           Encoding of the structure of the program* Simple types::* Example::                     A comprehensive example in C * Variables::* Aggregate types::* Symbol tables::               Symbol information in symbol tables* GNU C++ stabs::Appendixes:* Example2.c::                  Source code for extended example* Example2.s::                  Assembly code for extended example* Quick reference::             Various refernce tables* Expanded reference::          Reference information by stab type* Questions::                   Questions and anomolies* xcoff-differences::           Differences between GNU stabs in a.out                                and GNU stabs in xcoff* Sun-differences::             Differences between GNU stabs and Sun                                native stabs@end menu@end ifinfo@node Overview@chapter Overview of stabs@dfn{Stabs} refers to a format for information that describes a programto a debugger.  This format was apparently invented by@c FIXME! <<name of inventor>> atthe University of California at Berkeley, for the @code{pdx} Pascaldebugger; the format has spread widely since then.@menu* Flow:: Overview of debugging information flow* Stabs format:: Overview of stab format* C example:: A simple example in C source* Assembly code:: The simple example at the assembly level@end menu@node Flow@section Overview of debugging information flowThe GNU C compiler compiles C source in a @file{.c} file into assemblylanguage in a @file{.s} file, which is translated by the assembler intoa @file{.o} file, and then linked with other @file{.o} files andlibraries to produce an executable file.With the @samp{-g} option, GCC puts additional debugging information inthe @file{.s} file, which is slightly transformed by the assembler andlinker, and carried through into the final executable.  This debugginginformation describes features of the source file like line numbers,the types and scopes of variables, and functions, their parameters andtheir scopes.For some object file formats, the debugging information isencapsulated in assembler directives known collectively as `stab' (symboltable) directives, interspersed with the generated code.  Stabs arethe native format for debugging information in the a.out and xcoffobject file formats.  The GNU tools can also emit stabs in the coffand ecoff object file formats.The assembler adds the information from stabs to the symbol informationit places by default in the symbol table and the string table of the@file{.o} file it is building.  The linker consolidates the @file{.o}files into one executable file, with one symbol table and one stringtable.  Debuggers use the symbol and string tables in the executable asa source of debugging information about the program.@node Stabs format@section Overview of stab formatThere are three overall formats for stab assembler directivesdifferentiated by the first word of the stab.  The name of the directivedescribes what combination of four possible data fields will follow.  Itis either @code{.stabs} (string), @code{.stabn} (number), or@code{.stabd} (dot).The overall format of each class of stab is:@example.stabs "@var{string}",@var{type},0,@var{desc},@var{value}.stabn          @var{type},0,@var{desc},@var{value}.stabd          @var{type},0,@var{desc}@end exampleIn general, in @code{.stabs} the @var{string} field contains name and typeinformation.  For @code{.stabd} the value field is implicit and has the valueof the current file location.  Otherwise the value field oftencontains a relocatable address, frame pointer offset, or registernumber, that maps to the source code element described by the stab.The real key to decoding the meaning of a stab is the number in its typefield.  Each possible type number defines a different stab type.  Thestab type further defines the exact interpretation of, and possiblevalues for, any remaining @code{"@var{string}"}, @var{desc}, or@var{value} fields present in the stab.  Table A (@pxref{Stabtypes,,Table A: Symbol types from stabs}) lists in numeric orderthe possible type field values for stab directives.  The referencesection that follows Table A describes the meaning of the fields foreach stab type in detail.  The examples that follow this overviewintroduce the stab types in terms of the source code elements theydescribe.For @code{.stabs} the @code{"@var{string}"} field holds the meat of thedebugging information.  The generally unstructured nature of this fieldis what makes stabs extensible.  For some stab types the string fieldcontains only a name.  For other stab types the contents can be a greatdeal more complex.The overall format is of the @code{"@var{string}"} field is:@example"@var{name}@r{[}:@var{symbol_descriptor}@r{]}     @r{[}@var{type_number}@r{[}=@var{type_descriptor} @r{@dots{}]]}"@end example@var{name} is the name of the symbol represented by the stab.The @var{symbol_descriptor} following the @samp{:} is an alphabeticcharacter that tells more specifically what kind of symbol the stabrepresents. If the @var{symbol_descriptor} is omitted, but typeinformation follows, then the stab represents a local variable.  For alist of symbol_descriptors, see @ref{Symbol descriptors,,Table C: Symboldescriptors}.Type information is either a @var{type_number}, or a@samp{@var{type_number}=}.  The @var{type_number} alone is a typereference, referring directly to a type that has already been defined.The @samp{@var{type_number}=} is a type definition, where the numberrepresents a new type which is about to be defined.  The type definitionmay refer to other types by number, and those type numbers may befollowed by @samp{=} and nested definitions.In a type definition, if the character that follows the equals sign isnon-numeric then it is a @var{type_descriptor}, and tells what kind oftype is about to be defined.  Any other values following the@var{type_descriptor} vary, depending on the @var{type_descriptor}.  Ifa number follows the @samp{=} then the number is a @var{type_reference}.This is described more thoroughly in the section on types.  @xref{TypeDescriptors,,Table D: Type Descriptors}, for a list of@var{type_descriptor} values.@c FIXME! "too long" below introduced at J Gilmore's request; used to@c say "more than 80 chars".  Why is vaguer better?All this can make the @code{"@var{string}"} field quite long.  When the@code{"@var{string}"} part of a stab is too long, the compiler splitsthe @code{.stabs} directive into two @code{.stabs} directives.  Bothstabs duplicate exactly all but the @code{"@var{string}"} field.  The@code{"@var{string}"} field of the first stab contains the first part ofthe overlong string, marked as continued with a double-backslash at theend.  The @code{"@var{string}"} field of the second stab holds thesecond half of the overlong string.@node C example@section A simple example in C sourceTo get the flavor of how stabs describe source information for a Cprogram, let's look at the simple program:@examplemain() @{        printf("Hello world");@}@end exampleWhen compiled with @samp{-g}, the program above yields the following@file{.s} file.  Line numbers have been added to make it easier to referto parts of the @file{.s} file in the description of the stabs thatfollows.@node Assembly code@section The simple example at the assembly level@example1  gcc2_compiled.:2  .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext03  .stabs "hello.c",100,0,0,Ltext04  .text5  Ltext0:6  .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,07  .stabs "char:t2=r2;0;127;",128,0,0,08  .stabs "long int:t3=r1;-2147483648;2147483647;",128,0,0,09  .stabs "unsigned int:t4=r1;0;-1;",128,0,0,010 .stabs "long unsigned int:t5=r1;0;-1;",128,0,0,011 .stabs "short int:t6=r1;-32768;32767;",128,0,0,012 .stabs "long long int:t7=r1;0;-1;",128,0,0,013 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,014 .stabs "long long unsigned int:t9=r1;0;-1;",128,0,0,015 .stabs "signed char:t10=r1;-128;127;",128,0,0,016 .stabs "unsigned char:t11=r1;0;255;",128,0,0,017 .stabs "float:t12=r1;4;0;",128,0,0,018 .stabs "double:t13=r1;8;0;",128,0,0,019 .stabs "long double:t14=r1;8;0;",128,0,0,020 .stabs "void:t15=15",128,0,0,021      .align 422 LC0:23      .ascii "Hello, world!\12\0"24      .align 425      .global _main26      .proc 127 _main:28 .stabn 68,0,4,LM129 LM1:30      !#PROLOGUE# 031      save %sp,-136,%sp32      !#PROLOGUE# 133      call ___main,034      nop35 .stabn 68,0,5,LM236 LM2:37 LBB2:38      sethi %hi(LC0),%o139      or %o1,%lo(LC0),%o040      call _printf,041      nop42 .stabn 68,0,6,LM343 LM3:44 LBE2:45 .stabn 68,0,6,LM446 LM4:47 L1:48      ret49      restore50 .stabs "main:F1",36,0,0,_main51 .stabn 192,0,0,LBB252 .stabn 224,0,0,LBE2@end exampleThis simple ``hello world'' example demonstrates several of the stabtypes used to describe C language source files.  @node Program structure@chapter Encoding for the structure of the program@menu* Source file:: The path and name of the source file* Line numbers::* Procedures::* Block structure::@end menu@node Source file@section The path and name of the source file@table @strong@item Directive:@code{.stabs}@item Type:@code{N_SO} @end table      The first stabs in the .s file contain the name and path of the sourcefile that was compiled to produce the .s file.  This information iscontained in two records of stab type N_SO (100). @example   .stabs "path_name", N_SO, NIL, NIL, Code_address_of_program_start   .stabs "file_name:", N_SO, NIL, NIL, Code_address_of_program_start@end example@example2  .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext03  .stabs "hello.c",100,0,0,Ltext04       .text5  Ltext0:@end example@node Line numbers@section Line Numbers @table @strong@item Directive:@code{.stabn}@item Type:@code{N_SLINE}@end tableThe start of source lines is represented by the @code{N_SLINE} (68) stabtype.@example.stabn N_SLINE, NIL, @var{line}, @var{address}@end example@var{line} is a source line number; @var{address} represents the codeaddress for the start of that source line.@example27 _main:28 .stabn 68,0,4,LM129 LM1:30      !#PROLOGUE# 0@end example@node Procedures@section Procedures @table @strong@item Directive:@code{.stabs}@item Type:@code{N_FUN}@item Symbol Descriptors:@code{f} (local), @code{F} (global)@end tableProcedures are described by the @code{N_FUN} stab type.  The symboldescriptor for a procedure is @samp{F} if the procedure is globallyscoped and @samp{f} if the procedure is static (locally scoped).The @code{N_FUN} stab representing a procedure is located immediatelyfollowing the code of the procedure.  The @code{N_FUN} stab is in turndirectly followed by a group of other stabs describing elements of theprocedure.  These other stabs describe the procedure's parameters, itsblock local variables and its block structure. @example48      ret49      restore@end exampleThe @code{.stabs} entry after this code fragment shows the @var{name} ofthe procedure (@code{main}); the type descriptor @var{desc} (@code{F},for a global procedure); a reference to the predefined type @code{int}for the return type; and the starting @var{address} of the procedure.Here is an exploded summary (with whitespace introduced for clarity),followed by line 50 of our sample assembly output, which has this form:@example.stabs "@var{name}:        @var{desc}  @r{(global proc @samp{F})}        @var{return_type_ref}  @r{(int)}       ",N_FUN, NIL, NIL,       @var{address}@end example@example50 .stabs "main:F1",36,0,0,_main@end example@node Block Structure@section Block Structure@table @strong@item Directive:@code{.stabn}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -