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-2021 Free Software Foundation, Inc.
4Contributed by Cygnus Support.  Written by Julia Menapace, Jim Kingdon,
5and David MacKenzie.
6
7Permission is granted to copy, distribute and/or modify this document
8under the terms of the GNU Free Documentation License, Version 1.3 or
9any later version published by the Free Software Foundation; with no
10Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
11Texts.  A copy of the license is included in the section entitled "GNU
12Free Documentation License". -->
13<!-- Created by GNU Texinfo 5.1, http://www.gnu.org/software/texinfo/ -->
14<head>
15<title>STABS: Arrays</title>
16
17<meta name="description" content="STABS: Arrays">
18<meta name="keywords" content="STABS: Arrays">
19<meta name="resource-type" content="document">
20<meta name="distribution" content="global">
21<meta name="Generator" content="makeinfo">
22<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
23<link href="index.html#Top" rel="start" title="Top">
24<link href="Symbol-Types-Index.html#Symbol-Types-Index" rel="index" title="Symbol Types Index">
25<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
26<link href="Types.html#Types" rel="up" title="Types">
27<link href="Strings.html#Strings" rel="next" title="Strings">
28<link href="Subranges.html#Subranges" rel="previous" title="Subranges">
29<style type="text/css">
30<!--
31a.summary-letter {text-decoration: none}
32blockquote.smallquotation {font-size: smaller}
33div.display {margin-left: 3.2em}
34div.example {margin-left: 3.2em}
35div.indentedblock {margin-left: 3.2em}
36div.lisp {margin-left: 3.2em}
37div.smalldisplay {margin-left: 3.2em}
38div.smallexample {margin-left: 3.2em}
39div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
40div.smalllisp {margin-left: 3.2em}
41kbd {font-style:oblique}
42pre.display {font-family: inherit}
43pre.format {font-family: inherit}
44pre.menu-comment {font-family: serif}
45pre.menu-preformatted {font-family: serif}
46pre.smalldisplay {font-family: inherit; font-size: smaller}
47pre.smallexample {font-size: smaller}
48pre.smallformat {font-family: inherit; font-size: smaller}
49pre.smalllisp {font-size: smaller}
50span.nocodebreak {white-space:nowrap}
51span.nolinebreak {white-space:nowrap}
52span.roman {font-family:serif; font-weight:normal}
53span.sansserif {font-family:sans-serif; font-weight:normal}
54ul.no-bullet {list-style: none}
55-->
56</style>
57
58
59</head>
60
61<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
62<a name="Arrays"></a>
63<div class="header">
64<p>
65Next: <a href="Strings.html#Strings" accesskey="n" rel="next">Strings</a>, Previous: <a href="Subranges.html#Subranges" accesskey="p" rel="previous">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>
66</div>
67<hr>
68<a name="Array-Types"></a>
69<h3 class="section">5.5 Array Types</h3>
70
71<p>Arrays use the &lsquo;<samp>a</samp>&rsquo; type descriptor.  Following the type descriptor
72is the type of the index and the type of the array elements.  If the
73index type is a range type, it ends in a semicolon; otherwise
74(for example, if it is a type reference), there does not
75appear to be any way to tell where the types are separated.  In an
76effort to clean up this mess, IBM documents the two types as being
77separated by a semicolon, and a range type as not ending in a semicolon
78(but this is not right for range types which are not array indexes,
79see <a href="Subranges.html#Subranges">Subranges</a>).  I think probably the best solution is to specify
80that a semicolon ends a range type, and that the index type and element
81type of an array are separated by a semicolon, but that if the index
82type is a range type, the extra semicolon can be omitted.  GDB (at least
83through version 4.9) doesn&rsquo;t support any kind of index type other than a
84range anyway; I&rsquo;m not sure about dbx.
85</p>
86<p>It is well established, and widely used, that the type of the index,
87unlike most types found in the stabs, is merely a type definition, not
88type information (see <a href="String-Field.html#String-Field">String Field</a>) (that is, it need not start with
89&lsquo;<samp><var>type-number</var>=</samp>&rsquo; if it is defining a new type).  According to a
90comment in GDB, this is also true of the type of the array elements; it
91gives &lsquo;<samp>ar1;1;10;ar1;1;10;4</samp>&rsquo; as a legitimate way to express a two
92dimensional array.  According to AIX documentation, the element type
93must be type information.  GDB accepts either.
94</p>
95<p>The type of the index is often a range type, expressed as the type
96descriptor &lsquo;<samp>r</samp>&rsquo; and some parameters.  It defines the size of the
97array.  In the example below, the range &lsquo;<samp>r1;0;2;</samp>&rsquo; defines an index
98type which is a subrange of type 1 (integer), with a lower bound of 0
99and an upper bound of 2.  This defines the valid range of subscripts of
100a three-element C array.
101</p>
102<p>For example, the definition:
103</p>
104<div class="example">
105<pre class="example">char char_vec[3] = {'a','b','c'};
106</pre></div>
107
108<p>produces the output:
109</p>
110<div class="example">
111<pre class="example">.stabs &quot;char_vec:G19=ar1;0;2;2&quot;,32,0,0,0
112     .global _char_vec
113     .align 4
114_char_vec:
115     .byte 97
116     .byte 98
117     .byte 99
118</pre></div>
119
120<p>If an array is <em>packed</em>, the elements are spaced more
121closely than normal, saving memory at the expense of speed.  For
122example, an array of 3-byte objects might, if unpacked, have each
123element aligned on a 4-byte boundary, but if packed, have no padding.
124One way to specify that something is packed is with type attributes
125(see <a href="String-Field.html#String-Field">String Field</a>).  In the case of arrays, another is to use the
126&lsquo;<samp>P</samp>&rsquo; type descriptor instead of &lsquo;<samp>a</samp>&rsquo;.  Other than specifying a
127packed array, &lsquo;<samp>P</samp>&rsquo; is identical to &lsquo;<samp>a</samp>&rsquo;.
128</p>
129<p>An open array is represented by the &lsquo;<samp>A</samp>&rsquo; type descriptor followed by
130type information specifying the type of the array elements.
131</p>
132<p>An N-dimensional dynamic array is represented by
133</p>
134<div class="example">
135<pre class="example">D <var>dimensions</var> ; <var>type-information</var>
136</pre></div>
137
138<p><var>dimensions</var> is the number of dimensions; <var>type-information</var>
139specifies the type of the array elements.
140</p>
141<p>A subarray of an N-dimensional array is represented by
142</p>
143<div class="example">
144<pre class="example">E <var>dimensions</var> ; <var>type-information</var>
145</pre></div>
146
147<p><var>dimensions</var> is the number of dimensions; <var>type-information</var>
148specifies the type of the array elements.
149</p>
150<hr>
151<div class="header">
152<p>
153Next: <a href="Strings.html#Strings" accesskey="n" rel="next">Strings</a>, Previous: <a href="Subranges.html#Subranges" accesskey="p" rel="previous">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>
154</div>
155
156
157
158</body>
159</html>
160