You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

139 line
6.5KB

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2. <html>
  3. <!-- Copyright (C) 1992-2020 Free Software Foundation, Inc.
  4. Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
  5. and David MacKenzie.
  6. Permission is granted to copy, distribute and/or modify this document
  7. under the terms of the GNU Free Documentation License, Version 1.3 or
  8. any later version published by the Free Software Foundation; with no
  9. Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
  10. Texts. A copy of the license is included in the section entitled "GNU
  11. Free Documentation License". -->
  12. <!-- Created by GNU Texinfo 6.5, http://www.gnu.org/software/texinfo/ -->
  13. <head>
  14. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  15. <title>Structures (STABS)</title>
  16. <meta name="description" content="Structures (STABS)">
  17. <meta name="keywords" content="Structures (STABS)">
  18. <meta name="resource-type" content="document">
  19. <meta name="distribution" content="global">
  20. <meta name="Generator" content="makeinfo">
  21. <link href="index.html#Top" rel="start" title="Top">
  22. <link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
  23. <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
  24. <link href="Types.html#Types" rel="up" title="Types">
  25. <link href="Typedefs.html#Typedefs" rel="next" title="Typedefs">
  26. <link href="Enumerations.html#Enumerations" rel="prev" title="Enumerations">
  27. <style type="text/css">
  28. <!--
  29. a.summary-letter {text-decoration: none}
  30. blockquote.indentedblock {margin-right: 0em}
  31. blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
  32. blockquote.smallquotation {font-size: smaller}
  33. div.display {margin-left: 3.2em}
  34. div.example {margin-left: 3.2em}
  35. div.lisp {margin-left: 3.2em}
  36. div.smalldisplay {margin-left: 3.2em}
  37. div.smallexample {margin-left: 3.2em}
  38. div.smalllisp {margin-left: 3.2em}
  39. kbd {font-style: oblique}
  40. pre.display {font-family: inherit}
  41. pre.format {font-family: inherit}
  42. pre.menu-comment {font-family: serif}
  43. pre.menu-preformatted {font-family: serif}
  44. pre.smalldisplay {font-family: inherit; font-size: smaller}
  45. pre.smallexample {font-size: smaller}
  46. pre.smallformat {font-family: inherit; font-size: smaller}
  47. pre.smalllisp {font-size: smaller}
  48. span.nolinebreak {white-space: nowrap}
  49. span.roman {font-family: initial; font-weight: normal}
  50. span.sansserif {font-family: sans-serif; font-weight: normal}
  51. ul.no-bullet {list-style: none}
  52. -->
  53. </style>
  54. </head>
  55. <body lang="en">
  56. <a name="Structures"></a>
  57. <div class="header">
  58. <p>
  59. Next: <a href="Typedefs.html#Typedefs" accesskey="n" rel="next">Typedefs</a>, Previous: <a href="Enumerations.html#Enumerations" accesskey="p" rel="prev">Enumerations</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
  60. </div>
  61. <hr>
  62. <a name="Structures-1"></a>
  63. <h3 class="section">5.8 Structures</h3>
  64. <p>The encoding of structures in stabs can be shown with an example.
  65. </p>
  66. <p>The following source code declares a structure tag and defines an
  67. instance of the structure in global scope. Then a <code>typedef</code> equates the
  68. structure tag with a new type. Separate stabs are generated for the
  69. structure tag, the structure <code>typedef</code>, and the structure instance. The
  70. stabs for the tag and the <code>typedef</code> are emitted when the definitions are
  71. encountered. Since the structure elements are not initialized, the
  72. stab and code for the structure variable itself is located at the end
  73. of the program in the bss section.
  74. </p>
  75. <div class="example">
  76. <pre class="example">struct s_tag {
  77. int s_int;
  78. float s_float;
  79. char s_char_vec[8];
  80. struct s_tag* s_next;
  81. } g_an_s;
  82. typedef struct s_tag s_typedef;
  83. </pre></div>
  84. <p>The structure tag has an <code>N_LSYM</code> stab type because, like the
  85. enumeration, the symbol has file scope. Like the enumeration, the
  86. symbol descriptor is &lsquo;<samp>T</samp>&rsquo;, for enumeration, structure, or tag type.
  87. The type descriptor &lsquo;<samp>s</samp>&rsquo; following the &lsquo;<samp>16=</samp>&rsquo; of the type
  88. definition narrows the symbol type to structure.
  89. </p>
  90. <p>Following the &lsquo;<samp>s</samp>&rsquo; type descriptor is the number of bytes the
  91. structure occupies, followed by a description of each structure element.
  92. The structure element descriptions are of the form
  93. &lsquo;<samp><var>name</var>:<var>type</var>, <var>bit offset from the start of the
  94. struct</var>, <var>number of bits in the element</var></samp>&rsquo;.
  95. </p>
  96. <div class="example">
  97. <pre class="example"># <span class="roman">128 is N_LSYM</span>
  98. .stabs &quot;s_tag:T16=s20s_int:1,0,32;s_float:12,32,32;
  99. s_char_vec:17=ar1;0;7;2,64,64;s_next:18=*16,128,32;;&quot;,128,0,0,0
  100. </pre></div>
  101. <p>In this example, the first two structure elements are previously defined
  102. types. For these, the type following the &lsquo;<samp><var>name</var>:</samp>&rsquo; part of the
  103. element description is a simple type reference. The other two structure
  104. elements are new types. In this case there is a type definition
  105. embedded after the &lsquo;<samp><var>name</var>:</samp>&rsquo;. The type definition for the
  106. array element looks just like a type definition for a stand-alone array.
  107. The <code>s_next</code> field is a pointer to the same kind of structure that
  108. the field is an element of. So the definition of structure type 16
  109. contains a type definition for an element which is a pointer to type 16.
  110. </p>
  111. <p>If a field is a static member (this is a C<tt>++</tt> feature in which a single
  112. variable appears to be a field of every structure of a given type) it
  113. still starts out with the field name, a colon, and the type, but then
  114. instead of a comma, bit position, comma, and bit size, there is a colon
  115. followed by the name of the variable which each such field refers to.
  116. </p>
  117. <p>If the structure has methods (a C<tt>++</tt> feature), they follow the non-method
  118. fields; see <a href="Cplusplus.html#Cplusplus">Cplusplus</a>.
  119. </p>
  120. <hr>
  121. <div class="header">
  122. <p>
  123. Next: <a href="Typedefs.html#Typedefs" accesskey="n" rel="next">Typedefs</a>, Previous: <a href="Enumerations.html#Enumerations" accesskey="p" rel="prev">Enumerations</a>, Up: <a href="Types.html#Types" accesskey="u" rel="up">Types</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Symbol-Types-Index.html#Symbol-Types-Index" title="Index" rel="index">Index</a>]</p>
  124. </div>
  125. </body>
  126. </html>