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

📄 stabs.texinfo

📁 早期freebsd实现
💻 TEXINFO
📖 第 1 页 / 共 5 页
字号:
@item Types:@code{N_LBRAC}, @code{N_RBRAC}@end tableThe program's block structure is represented by the @code{N_LBRAC} (leftbrace) and the @code{N_RBRAC} (right brace) stab types.  The following coderange, which is the body of @code{main}, is labeled with @samp{LBB2:} at thebeginning and @samp{LBE2:} at the end.  @example37 LBB2:38      sethi %hi(LC0),%o139      or %o1,%lo(LC0),%o040      call _printf,041      nop42 .stabn 68,0,6,LM343 LM3:44 LBE2:@end exampleThe @code{N_LBRAC} and @code{N_RBRAC} stabs that describe the blockscope of the procedure are located after the @code{N_FUNC} stab thatrepresents the procedure itself.  The @code{N_LBRAC} uses the@code{LBB2} label as the code address in its value field, and the@code{N_RBRAC} uses @code{LBE2}.@example50 .stabs "main:F1",36,0,0,_main@end example@example   .stabn N_LBRAC, NIL, NIL, @var{left-brace-address}   .stabn N_RBRAC, NIL, NIL, @var{right-brace-address}@end example@example51 .stabn 192,0,0,LBB252 .stabn 224,0,0,LBE2@end example@node Simple types@chapter Simple types@menu* Basic types:: Basic type definitions* Range types:: Range types defined by min and max value * Bit-ranges:: Range type defined by number of bits@end menu@node Basic types@section Basic type definitions@table @strong@item Directive:@code{.stabs}@item Type:@code{N_LSYM}@item Symbol Descriptor:@code{t}@end tableThe basic types for the language are described using the @code{N_LSYM} stabtype.  They are boilerplate and are emited by the compiler for eachcompilation unit.  Basic type definitions are not always a completedescription of the type and are sometimes circular.  The debuggerrecognizes the type anyway, and knows how to read bits as that type.Each language and compiler defines a slightly different set of basictypes.  In this example we are looking at the basic types for C emitedby the GNU compiler targeting the Sun4.  Here the basic types aremostly defined as range types.  @node Range types@section Range types defined by min and max value @table @strong@item Type Descriptor:@code{r}@end tableWhen defining a range type, if the number after the first semicolon issmaller than the number after the second one, then the two numbersrepresent the smallest and the largest values in the range.  @example4  .text5  Ltext0:.stabs "@var{name}:        @var{descriptor}  @r{(type)}        @var{type-def}=        @var{type-desc}        @var{type-ref};        @var{low-bound};        @var{high-bound};       ",       N_LSYM, NIL, NIL, NIL6  .stabs "int:t1=r1;-2147483648;2147483647;",128,0,0,07  .stabs "char:t2=r2;0;127;",128,0,0,0@end exampleHere the integer type (@code{1}) is defined as a range of the integertype (@code{1}).  Likewise @code{char} is a range of @code{char}.  Thispart of the definition is circular, but at least the high and low boundvalues of the range hold more information about the type.Here short unsigned int is defined as type number 8 and described as arange of type @code{int}, with a minimum value of 0 and a maximum of 65535.@example13 .stabs "short unsigned int:t8=r1;0;65535;",128,0,0,0@end example@node Bit-ranges@section Range type defined by number of bits@table @strong@item Type Descriptor:@code{r}@end tableIn a range definition, if the number after the second semicolon is 0,then the number after the first semicolon is the number of bits neededto represent the type.@example.stabs "@var{name}:        @var{desc}        @var{type-def}=        @var{type-desc}        @var{type-ref};        @var{bit-count};        0;       ",       N_LSYM, NIL, NIL, NIL17 .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,0@end exampleCosmically enough, the @code{void} type is defined directly in terms ofitself.@example.stabs "@var{name}:        @var{symbol-desc}        @var{type-def}=        @var{type-ref}       ",N_LSYM,NIL,NIL,NIL20 .stabs "void:t15=15",128,0,0,0@end example@node Example@chapter A Comprehensive Example in C Now we'll examine a second program, @code{example2}, which builds on thefirst example to introduce the rest of the stab types, symboldescriptors, and type descriptors used in C.@xref{Example2.c} for the complete @file{.c} source,and @pxref{Example2.s} for the @file{.s} assembly code.This description includes parts of those files.@section Flow of control and nested scopes @table @strong@item Directive:@code{.stabn}@item Types:@code{N_SLINE}, @code{N_LBRAC}, @code{N_RBRAC} (cont.)@end tableConsider the body of @code{main}, from @file{example2.c}.  It shows moreabout how @code{N_SLINE}, @code{N_RBRAC}, and @code{N_LBRAC} stabs are used.  @example20 @{21      static float s_flap;22      int times;23      for (times=0; times < s_g_repeat; times++)@{24        int inner;25        printf ("Hello world\n");26      @}27 @};@end exampleHere we have a single source line, the @samp{for} line, that generatesnon-linear flow of control, and non-contiguous code.  In this case, an@code{N_SLINE} stab with the same line number proceeds each block ofnon-contiguous code generated from the same source line.The example also shows nested scopes.  The @code{N_LBRAC} and@code{N_LBRAC} stabs that describe block structure are nested in thesame order as the corresponding code blocks, those of the for loopinside those for the body of main.@noindentThis is the label for the @code{N_LBRAC} (left brace) stab marking thestart of @code{main}. @example57 LBB2:@end example@noindentIn the first code range for C source line 23, the @code{for} loopinitialize and test, @code{N_SLINE} (68) records the line number:@example.stabn N_SLINE, NIL,       @var{line},       @var{address}58 .stabn 68,0,23,LM259 LM2:60      st %g0,[%fp-20]61 L2:62      sethi %hi(_s_g_repeat),%o063      ld [%fp-20],%o164      ld [%o0+%lo(_s_g_repeat)],%o065      cmp %o1,%o066      bge L367      nop@exdent label for the @code{N_LBRAC} (start block) marking the start of @code{for} loop68 LBB3:69 .stabn 68,0,25,LM370 LM3:71      sethi %hi(LC0),%o172      or %o1,%lo(LC0),%o073      call _printf,074      nop75 .stabn 68,0,26,LM476 LM4:@exdent label for the @code{N_RBRAC} (end block) stab marking the end of the @code{for} loop77 LBE3:@end example@noindentNow we come to the second code range for source line 23, the @code{for}loop increment and return.  Once again, @code{N_SLINE} (68) records thesource line number:@example.stabn, N_SLINE, NIL,        @var{line},        @var{address}78 .stabn 68,0,23,LM579 LM5:80 L4:81      ld [%fp-20],%o082      add %o0,1,%o183      st %o1,[%fp-20]84      b,a L285 L3:86 .stabn 68,0,27,LM687 LM6:@exdent label for the @code{N_RBRAC} (end block) stab marking the end of the @code{for} loop88 LBE2:89 .stabn 68,0,27,LM790 LM7:91 L1:92      ret93      restore94 .stabs "main:F1",36,0,0,_main95 .stabs "argc:p1",160,0,0,6896 .stabs "argv:p20=*21=*2",160,0,0,7297 .stabs "s_flap:V12",40,0,0,_s_flap.098 .stabs "times:1",128,0,0,-20@end example@noindentHere is an illustration of stabs describing nested scopes.  The scopenesting is reflected in the nested bracketing stabs (@code{N_LBRAC},192, appears here).@example.stabn N_LBRAC,NIL,NIL,       @var{block-start-address}99  .stabn 192,0,0,LBB2      ## begin proc label100 .stabs "inner:1",128,0,0,-24101 .stabn 192,0,0,LBB3      ## begin for label@end example@noindent@code{N_RBRAC} (224), ``right brace'' ends a lexical block (scope).@example.stabn N_RBRAC,NIL,NIL,       @var{block-end-address}102 .stabn 224,0,0,LBE3      ## end for label103 .stabn 224,0,0,LBE2      ## end proc label@end example@node Variables@chapter Variables@menu* Automatic variables:: locally scoped* Global variables::* Register variables::* Initialized statics::* Un-initialized statics::* Parameters::@end menu@node Automatic variables@section Locally scoped automatic variables@table @strong@item Directive:@code{.stabs}@item Type:@code{N_LSYM} @item Symbol Descriptor:none@end tableIn addition to describing types, the @code{N_LSYM} stab type alsodescribes locally scoped automatic variables.  Refer again to the bodyof @code{main} in @file{example2.c}.  It allocates two automaticvariables: @samp{times} is scoped to the body of @code{main}, and@samp{inner} is scoped to the body of the @code{for} loop.@samp{s_flap} is locally scoped but not automatic, and will be discussedlater.@example20 @{21      static float s_flap;22      int times;23      for (times=0; times < s_g_repeat; times++)@{24        int inner;25        printf ("Hello world\n");26      @}27 @};@end exampleThe @code{N_LSYM} stab for an automatic variable is located just before the@code{N_LBRAC} stab describing the open brace of the block to which it isscoped. @example@exdent @code{N_LSYM} (128): automatic variable, scoped locally to @code{main}.stabs "@var{name}:        @var{type-ref}",       N_LSYM, NIL, NIL,       @var{frame-pointer-offset}98  .stabs "times:1",128,0,0,-2099  .stabn 192,0,0,LBB2      ## begin `main' N_LBRAC@exdent @code{N_LSYM} (128): automatic variable, scoped locally to the @code{for} loop.stabs "@var{name}:        @var{type-ref}",        N_LSYM, NIL, NIL,       @var{frame-pointer-offset}100 .stabs "inner:1",128,0,0,-24101 .stabn 192,0,0,LBB3      ## begin `for' loop N_LBRAC@end exampleSince the character in the string field following the colon is not aletter, there is no symbol descriptor.  This means that the stabdescribes a local variable, and that the number after the colon is atype reference.  In this case it a a reference to the basic type @code{int}.Notice also that the frame pointer offset is negative number forautomatic variables.@node Global Variables@section Global Variables@table @strong@item Directive:@code{.stabs}@item Type:@code{N_GSYM}@item Symbol Descriptor:@code{G}@end tableGlobal variables are represented by the @code{N_GSYM} stab type.  The symboldescriptor, following the colon in the string field, is @samp{G}.  Followingthe @samp{G} is a type reference or type definition.  In this example it is atype reference to the basic C type, @code{char}.  The first source line in@file{example2.c},  @example1  char g_foo = 'c';@end example@noindentyields the following stab.  The stab immediately precedes the code thatallocates storage for the variable it describes.@example@exdent @code{N_GSYM} (32): global symbol.stabs "@var{name}:        @var{descriptor}        @var{type-ref}",

⌨️ 快捷键说明

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