You cannot 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 lines
6.5 KiB
HTML
139 lines
6.5 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<!-- Copyright (C) 1992-2019 Free Software Foundation, Inc.
|
|
Contributed by Cygnus Support. Written by Julia Menapace, Jim Kingdon,
|
|
and David MacKenzie.
|
|
|
|
Permission is granted to copy, distribute and/or modify this document
|
|
under the terms of the GNU Free Documentation License, Version 1.3 or
|
|
any later version published by the Free Software Foundation; with no
|
|
Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
|
|
Texts. A copy of the license is included in the section entitled "GNU
|
|
Free Documentation License". -->
|
|
<!-- Created by GNU Texinfo 6.4, http://www.gnu.org/software/texinfo/ -->
|
|
<head>
|
|
<title>Structures (STABS)</title>
|
|
|
|
<meta name="description" content="Structures (STABS)">
|
|
<meta name="keywords" content="Structures (STABS)">
|
|
<meta name="resource-type" content="document">
|
|
<meta name="distribution" content="global">
|
|
<meta name="Generator" content="makeinfo">
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
|
<link href="index.html#Top" rel="start" title="Top">
|
|
<link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
|
|
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
|
|
<link href="Types.html#Types" rel="up" title="Types">
|
|
<link href="Typedefs.html#Typedefs" rel="next" title="Typedefs">
|
|
<link href="Enumerations.html#Enumerations" rel="prev" title="Enumerations">
|
|
<style type="text/css">
|
|
<!--
|
|
a.summary-letter {text-decoration: none}
|
|
blockquote.indentedblock {margin-right: 0em}
|
|
blockquote.smallindentedblock {margin-right: 0em; font-size: smaller}
|
|
blockquote.smallquotation {font-size: smaller}
|
|
div.display {margin-left: 3.2em}
|
|
div.example {margin-left: 3.2em}
|
|
div.lisp {margin-left: 3.2em}
|
|
div.smalldisplay {margin-left: 3.2em}
|
|
div.smallexample {margin-left: 3.2em}
|
|
div.smalllisp {margin-left: 3.2em}
|
|
kbd {font-style: oblique}
|
|
pre.display {font-family: inherit}
|
|
pre.format {font-family: inherit}
|
|
pre.menu-comment {font-family: serif}
|
|
pre.menu-preformatted {font-family: serif}
|
|
pre.smalldisplay {font-family: inherit; font-size: smaller}
|
|
pre.smallexample {font-size: smaller}
|
|
pre.smallformat {font-family: inherit; font-size: smaller}
|
|
pre.smalllisp {font-size: smaller}
|
|
span.nolinebreak {white-space: nowrap}
|
|
span.roman {font-family: initial; font-weight: normal}
|
|
span.sansserif {font-family: sans-serif; font-weight: normal}
|
|
ul.no-bullet {list-style: none}
|
|
-->
|
|
</style>
|
|
|
|
|
|
</head>
|
|
|
|
<body lang="en">
|
|
<a name="Structures"></a>
|
|
<div class="header">
|
|
<p>
|
|
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> [<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>
|
|
</div>
|
|
<hr>
|
|
<a name="Structures-1"></a>
|
|
<h3 class="section">5.8 Structures</h3>
|
|
|
|
<p>The encoding of structures in stabs can be shown with an example.
|
|
</p>
|
|
<p>The following source code declares a structure tag and defines an
|
|
instance of the structure in global scope. Then a <code>typedef</code> equates the
|
|
structure tag with a new type. Separate stabs are generated for the
|
|
structure tag, the structure <code>typedef</code>, and the structure instance. The
|
|
stabs for the tag and the <code>typedef</code> are emitted when the definitions are
|
|
encountered. Since the structure elements are not initialized, the
|
|
stab and code for the structure variable itself is located at the end
|
|
of the program in the bss section.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example">struct s_tag {
|
|
int s_int;
|
|
float s_float;
|
|
char s_char_vec[8];
|
|
struct s_tag* s_next;
|
|
} g_an_s;
|
|
|
|
typedef struct s_tag s_typedef;
|
|
</pre></div>
|
|
|
|
<p>The structure tag has an <code>N_LSYM</code> stab type because, like the
|
|
enumeration, the symbol has file scope. Like the enumeration, the
|
|
symbol descriptor is ‘<samp>T</samp>’, for enumeration, structure, or tag type.
|
|
The type descriptor ‘<samp>s</samp>’ following the ‘<samp>16=</samp>’ of the type
|
|
definition narrows the symbol type to structure.
|
|
</p>
|
|
<p>Following the ‘<samp>s</samp>’ type descriptor is the number of bytes the
|
|
structure occupies, followed by a description of each structure element.
|
|
The structure element descriptions are of the form
|
|
‘<samp><var>name</var>:<var>type</var>, <var>bit offset from the start of the
|
|
struct</var>, <var>number of bits in the element</var></samp>’.
|
|
</p>
|
|
<div class="example">
|
|
<pre class="example"># <span class="roman">128 is N_LSYM</span>
|
|
.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
|
|
</pre></div>
|
|
|
|
<p>In this example, the first two structure elements are previously defined
|
|
types. For these, the type following the ‘<samp><var>name</var>:</samp>’ part of the
|
|
element description is a simple type reference. The other two structure
|
|
elements are new types. In this case there is a type definition
|
|
embedded after the ‘<samp><var>name</var>:</samp>’. The type definition for the
|
|
array element looks just like a type definition for a stand-alone array.
|
|
The <code>s_next</code> field is a pointer to the same kind of structure that
|
|
the field is an element of. So the definition of structure type 16
|
|
contains a type definition for an element which is a pointer to type 16.
|
|
</p>
|
|
<p>If a field is a static member (this is a C<tt>++</tt> feature in which a single
|
|
variable appears to be a field of every structure of a given type) it
|
|
still starts out with the field name, a colon, and the type, but then
|
|
instead of a comma, bit position, comma, and bit size, there is a colon
|
|
followed by the name of the variable which each such field refers to.
|
|
</p>
|
|
<p>If the structure has methods (a C<tt>++</tt> feature), they follow the non-method
|
|
fields; see <a href="Cplusplus.html#Cplusplus">Cplusplus</a>.
|
|
</p>
|
|
<hr>
|
|
<div class="header">
|
|
<p>
|
|
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> [<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>
|
|
</div>
|
|
|
|
|
|
|
|
</body>
|
|
</html>
|