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.

159 lines
7.2 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>Arrays (STABS)</title>
<meta name="description" content="Arrays (STABS)">
<meta name="keywords" content="Arrays (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="Strings.html#Strings" rel="next" title="Strings">
<link href="Subranges.html#Subranges" rel="prev" title="Subranges">
<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="Arrays"></a>
<div class="header">
<p>
Next: <a href="Strings.html#Strings" accesskey="n" rel="next">Strings</a>, Previous: <a href="Subranges.html#Subranges" accesskey="p" rel="prev">Subranges</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>
</div>
<hr>
<a name="Array-Types"></a>
<h3 class="section">5.5 Array Types</h3>
<p>Arrays use the &lsquo;<samp>a</samp>&rsquo; type descriptor. Following the type descriptor
is the type of the index and the type of the array elements. If the
index type is a range type, it ends in a semicolon; otherwise
(for example, if it is a type reference), there does not
appear to be any way to tell where the types are separated. In an
effort to clean up this mess, IBM documents the two types as being
separated by a semicolon, and a range type as not ending in a semicolon
(but this is not right for range types which are not array indexes,
see <a href="Subranges.html#Subranges">Subranges</a>). I think probably the best solution is to specify
that a semicolon ends a range type, and that the index type and element
type of an array are separated by a semicolon, but that if the index
type is a range type, the extra semicolon can be omitted. GDB (at least
through version 4.9) doesn&rsquo;t support any kind of index type other than a
range anyway; I&rsquo;m not sure about dbx.
</p>
<p>It is well established, and widely used, that the type of the index,
unlike most types found in the stabs, is merely a type definition, not
type information (see <a href="String-Field.html#String-Field">String Field</a>) (that is, it need not start with
&lsquo;<samp><var>type-number</var>=</samp>&rsquo; if it is defining a new type). According to a
comment in GDB, this is also true of the type of the array elements; it
gives &lsquo;<samp>ar1;1;10;ar1;1;10;4</samp>&rsquo; as a legitimate way to express a two
dimensional array. According to AIX documentation, the element type
must be type information. GDB accepts either.
</p>
<p>The type of the index is often a range type, expressed as the type
descriptor &lsquo;<samp>r</samp>&rsquo; and some parameters. It defines the size of the
array. In the example below, the range &lsquo;<samp>r1;0;2;</samp>&rsquo; defines an index
type which is a subrange of type 1 (integer), with a lower bound of 0
and an upper bound of 2. This defines the valid range of subscripts of
a three-element C array.
</p>
<p>For example, the definition:
</p>
<div class="example">
<pre class="example">char char_vec[3] = {'a','b','c'};
</pre></div>
<p>produces the output:
</p>
<div class="example">
<pre class="example">.stabs &quot;char_vec:G19=ar1;0;2;2&quot;,32,0,0,0
.global _char_vec
.align 4
_char_vec:
.byte 97
.byte 98
.byte 99
</pre></div>
<p>If an array is <em>packed</em>, the elements are spaced more
closely than normal, saving memory at the expense of speed. For
example, an array of 3-byte objects might, if unpacked, have each
element aligned on a 4-byte boundary, but if packed, have no padding.
One way to specify that something is packed is with type attributes
(see <a href="String-Field.html#String-Field">String Field</a>). In the case of arrays, another is to use the
&lsquo;<samp>P</samp>&rsquo; type descriptor instead of &lsquo;<samp>a</samp>&rsquo;. Other than specifying a
packed array, &lsquo;<samp>P</samp>&rsquo; is identical to &lsquo;<samp>a</samp>&rsquo;.
</p>
<p>An open array is represented by the &lsquo;<samp>A</samp>&rsquo; type descriptor followed by
type information specifying the type of the array elements.
</p>
<p>An N-dimensional dynamic array is represented by
</p>
<div class="example">
<pre class="example">D <var>dimensions</var> ; <var>type-information</var>
</pre></div>
<p><var>dimensions</var> is the number of dimensions; <var>type-information</var>
specifies the type of the array elements.
</p>
<p>A subarray of an N-dimensional array is represented by
</p>
<div class="example">
<pre class="example">E <var>dimensions</var> ; <var>type-information</var>
</pre></div>
<p><var>dimensions</var> is the number of dimensions; <var>type-information</var>
specifies the type of the array elements.
</p>
<hr>
<div class="header">
<p>
Next: <a href="Strings.html#Strings" accesskey="n" rel="next">Strings</a>, Previous: <a href="Subranges.html#Subranges" accesskey="p" rel="prev">Subranges</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>
</div>
</body>
</html>