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

📄 stabs.texinfo

📁 早期freebsd实现
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
        N_GSYM, NIL, NIL, NIL21 .stabs "g_foo:G2",32,0,0,022      .global _g_foo23      .data24 _g_foo:25      .byte 99@end exampleThe address of the variable represented by the @code{N_GSYM} is not containedin the @code{N_GSYM} stab.  The debugger gets this information from theexternal symbol for the global variable.@node Register variables@section Global register variables @table @strong@item Directive:@code{.stabs}@item Type:@code{N_RSYM}@item Symbol Descriptor:@code{r}@end tableThe following source line defines a global variable, @code{g_bar}, which isexplicitly allocated in global register @code{%g5}.  @example2  register int g_bar asm ("%g5");@end exampleRegister variables have their own stab type, @code{N_RSYM}, and their ownsymbol descriptor, @code{r}.  The stab's value field contains the number ofthe register where the variable data will be stored.  Since thevariable was not initialized in this compilation unit, the stab isemited at the end of the object file, with the stabs for otheruninitialized globals (@code{bcc}).@example@exdent @code{N_RSYM} (64): register variable.stabs "@var{name}:        @var{descriptor}        @var{type-ref}",       N_RSYM, NIL, NIL,       @var{register} 133 .stabs "g_bar:r1",64,0,0,5@end example@node Initialized statics@section Initialized static variables @table @strong@item Directive:@code{.stabs}@item Type:@code{N_STSYM}@item Symbol Descriptors:@code{S} (file scope), @code{V} (procedure scope)@end tableInitialized static variables are represented by the @code{N_STSYM} stabtype.  The symbol descriptor part of the string field shows if thevariable is file scope static (@samp{S}) or procedure scope static(@samp{V}). The source line@example3  static int s_g_repeat = 2; @end example@noindentyields the following code.  The stab is located immediately precedingthe storage for the variable it represents.  Since the variable inthis example is file scope static the symbol descriptor is @samp{S}.@example@exdent @code{N_STSYM} (38): initialized static variable (data seg w/internal linkage).stabs "@var{name}:        @var{descriptor}        @var{type-ref}",       N_STSYM,NIL,NIL,       @var{address}        26 .stabs "s_g_repeat:S1",38,0,0,_s_g_repeat27      .align 428 _s_g_repeat:29      .word 2@end example@node Un-initialized statics@section Un-initialized static variables@table @strong@item Directive:@code{.stabs}@item Type:@code{N_LCSYM}@item Symbol Descriptors:@code{S} (file scope), @code{V} (procedure scope)@end tableUn-initialized static variables are represented by the @code{N_LCSYM}stab type.  The symbol descriptor part of the string shows if thevariable is file scope static (@samp{S}) or procedure scope static(@samp{V}).  In this example it is procedure scope static.  The sourceline allocating @code{s_flap} immediately follows the open brace for theprocedure @code{main}.@example20 @{21      static float s_flap;@end exampleThe code that reserves storage for the variable @code{s_flap} precedes thebody of body of @code{main}.  @example39      .reserve _s_flap.0,4,"bss",4@end exampleBut since @code{s_flap} is scoped locally to @code{main}, its stab islocated with the other stabs representing symbols local to @code{main}.The stab for @code{s_flap} is located just before the @code{N_LBRAC} for@code{main}.@example@exdent @code{N_LCSYM} (40): uninitialized static var (BSS seg w/internal linkage).stabs "@var{name}:        @var{descriptor}        @var{type-ref}",        N_LCSYM, NIL, NIL,        @var{address}97 .stabs "s_flap:V12",40,0,0,_s_flap.098 .stabs "times:1",128,0,0,-2099 .stabn 192,0,0,LBB2                  # N_LBRAC for main.@end example@c ............................................................@node Parameters@section Parameters @table @strong@item Directive: @code{.stabs}@item Type:@code{N_PSYM}@item Symbol Descriptor:@code{p}@end tableProcedure parameters are represented by the N_PSYM stab type.  Thefollowing source lines show the parameters of the main routine.@example17 main (argc, argv)18      int argc;19      char* argv[];20 @{@end exampleThe N_PSYM stabs describing parameters to a function directly followthe N_FUN stab that represents the procedure itself.  The N_FUN stabimmediately follows the code of the procedure it describes.  Followingthe N_PSYM parameter stabs are any N_LSYM stabs representing localvariables.@example@exdent <36> N_FUN - describing the procedure main94 .stabs "main:F1",36,0,0,_main@exdent <160> N_PSYM - parameters@exdent .stabs "name:sym_desc(value_param)type_ref(int)", N_PSYM,@exdent NIL, NIL, frame_ptr_offset95 .stabs "argc:p1",160,0,0,68    @exdent <160> N_PSYM - parameter@exdent .stabs "name:sym_desc(value_param)type_def(20)=ptr_to type_def(21)=@exdent ptr_to type_ref(char)96 .stabs "argv:p20=*21=*2",160,0,0,72@end exampleThe type definition of argv is interesting because it defines two newtypes in terms of an existing one.  The array argv contains characterpointers.  The type of the array name is a pointer to the type thearray holds. Thus the type of argv is ptr to ptr to char.  The stabfor argv contains nested type_definitions.  Type 21 is ptr to type 2(char) and argv (type 20) is ptr to type 21. @node Aggregate Types@chapter Aggregate Types Now let's look at some variable definitions involving complex types.This involves understanding better how types are described.  In theexamples so far types have been described as references to previouslydefined types or defined in terms of subranges of or pointers topreviously defined types.  The section that follows will talk aboutthe various other type descriptors that may follow the = sign in atype definition.@menu* Arrays::* Enumerations::* Structure tags::* Typedefs::* Unions::* Function types::@end menu@node Arrays@section Array types @table @strong@item Directive:@code{.stabs}@item Types:@code{N_GSYM}, @code{N_LSYM}@item Symbol Descriptor:@code{T}@item Type Descriptor:@code{ar}@end tableAs an example of an array type consider the global variable below.@example15 char char_vec[3] = @{'a','b','c'@};@end exampleSince the array is a global variable, it is described by the N_GSYMstab type.  The symbol descriptor G, following the colon in stab'sstring field, also says the array is a global variable.  Following theG is a definition for type (19) as shown by the equals sign after thetype number.  After the equals sign is a type descriptor, ar, which says that thetype being defined is an array.  Following the type descriptor for anarray is the type of the index, a null field, the upper bound of thearray indexing, and the type of the array elements.The array definition above generates the assembly language thatfollows.@example@exdent <32> N_GSYM - global variable@exdent .stabs "name:sym_desc(global)type_def(19)=type_desc(array)@exdent index_type_ref(int);NIL;high_bound(2);element_type_ref(char)";@exdent N_GSYM, NIL, NIL, NIL32 .stabs "char_vec:G19=ar1;0;2;2",32,0,0,033      .global _char_vec34      .align 435 _char_vec:36      .byte 9737      .byte 9838      .byte 99@end example@node Enumerations@section Enumerations @table @strong@item Directive:@code{.stabs}@item Type:@code{N_LSYM}@item Symbol Descriptor:@code{T}@item Type Descriptor:@code{e}@end tableThe source line below declares an enumeration type.  It is defined atfile scope between the bodies of main and s_proc in example2.c.Because the N_LSYM is located after the N_RBRAC that marks the end ofthe previous procedure's block scope, and before the N_FUN that marksthe beginning of the next procedure's block scope, the N_LSYM does notdescribe a block local symbol, but a file local one.  The source line:@example29 enum e_places @{first,second=3,last@};@end example@noindentgenerates the following stab, located just after the N_RBRAC (closebrace stab) for main.  The type definition is in an N_LSYM stabbecause type definitions are file scope not global scope.@display    <128> N_LSYM - local symbol    .stab "name:sym_dec(type)type_def(22)=sym_desc(enum)           enum_name:value(0),enum_name:value(3),enum_name:value(4),;",           N_LSYM, NIL, NIL, NIL@end display@example104 .stabs "e_places:T22=efirst:0,second:3,last:4,;",128,0,0,0@end exampleThe symbol descriptor (T) says that the stab describes a structure,enumeration, or type tag.  The type descriptor e, following the 22= ofthe type definition narrows it down to an enumeration type.  Followingthe e is a list of the elements of the enumeration.  The format isname:value,. The list of elements ends with a ;.@node Structure tags@section Structure Tags@table @strong@item Directive:@code{.stabs}@item Type:@code{N_LSYM}@item Symbol Descriptor:@code{T}@item Type Descriptor:@code{s}@end tableThe following source code declares a structure tag and defines aninstance of  the structure in global scope. Then a typedef equates thestructure tag with a new type.  A seperate stab is generated for thestructure tag, the structure typedef, and the structure instance.  Thestabs for the tag and the typedef are emited when the definitions areencountered.  Since the structure elements are not initialized, thestab and code for the structure variable itself is located at the endof the program in .common.@example6  struct s_tag @{7    int   s_int;8    float s_float;9    char  s_char_vec[8];10   struct s_tag* s_next;11 @} g_an_s;12 13 typedef struct s_tag s_typedef;@end exampleThe structure tag is an N_LSYM stab type because, like the enum, thesymbol is file scope.  Like the enum, the symbol descriptor is T, forenumeration, struct or tag type.  The symbol descriptor s followingthe 16= of the type definition narrows the symbol type to struct.Following the struct symbol descriptor is the number of bytes thestruct occupies, followed by a description of each structure element.The structure element descriptions are of the form name:type, bitoffset from the start of the struct, and number of bits in theelement.@example   <128> N_LSYM - type definition    .stabs "name:sym_desc(struct tag) Type_def(16)=type_desc(struct type)         struct_bytes        elem_name:type_ref(int),bit_offset,field_bits;        elem_name:type_ref(float),bit_offset,field_bits;        elem_name:type_def(17)=type_desc(dynamic array) index_type(int);NIL;        high_bound(7);element_type(char),bit_offset,field_bits;;",        N_LSYM,NIL,NIL,NIL30 .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@end example In this example, two of the structure elements are previously definedtypes.  For these, the type following the name: part of the elementdescription is a simple type reference.  The other two structureelements are new types.  In this case there is a type definitionembedded after the name:.  The type definition for the array elementlooks just like a type definition for a standalone array.  The s_nextfield is a pointer to the same kind of structure that the field is anelement of.  So the definition of structure type 16 contains an typedefinition for an element which is a pointer to type 16. @node Typedefs@section Typedefs@table @strong@item Directive:@code{.stabs}@item Type:@code{N_LSYM}@item Symbol Descriptor:@code{t}@end tableHere is the stab for the typedef equating the structure tag with atype.@display    <128> N_LSYM - type definition     .stabs "name:sym_desc(type name)type_ref(struct_tag)",N_LSYM,NIL,NIL,NIL@end display@example31 .stabs "s_typedef:t16",128,0,0,0@end exampleAnd here is the code generated for the structure variable.@display    <32> N_GSYM - global symbol     .stabs "name:sym_desc(global)type_ref(struct_tag)",N_GSYM,NIL,NIL,NIL@end display

⌨️ 快捷键说明

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