Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / stabs / Arrays.html
blob517ebcda84b6ca28013f36ab5b9576453e6d58d3
1 <html lang="en">
2 <head>
3 <title>STABS</title>
4 <meta http-equiv="Content-Type" content="text/html">
5 <meta name="description" content="STABS">
6 <meta name="generator" content="makeinfo 4.3">
7 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home">
8 </head>
9 <body>
10 <div class="node">
11 <p>
12 Node:<a name="Arrays">Arrays</a>,
13 Next:<a rel="next" accesskey="n" href="Strings.html#Strings">Strings</a>,
14 Previous:<a rel="previous" accesskey="p" href="Subranges.html#Subranges">Subranges</a>,
15 Up:<a rel="up" accesskey="u" href="Types.html#Types">Types</a>
16 <hr><br>
17 </div>
19 <h3 class="section">Array Types</h3>
21 <p>Arrays use the <code>a</code> type descriptor. Following the type descriptor
22 is the type of the index and the type of the array elements. If the
23 index type is a range type, it ends in a semicolon; otherwise
24 (for example, if it is a type reference), there does not
25 appear to be any way to tell where the types are separated. In an
26 effort to clean up this mess, IBM documents the two types as being
27 separated by a semicolon, and a range type as not ending in a semicolon
28 (but this is not right for range types which are not array indexes,
29 see <a href="Subranges.html#Subranges">Subranges</a>). I think probably the best solution is to specify
30 that a semicolon ends a range type, and that the index type and element
31 type of an array are separated by a semicolon, but that if the index
32 type is a range type, the extra semicolon can be omitted. GDB (at least
33 through version 4.9) doesn't support any kind of index type other than a
34 range anyway; I'm not sure about dbx.
36 <p>It is well established, and widely used, that the type of the index,
37 unlike most types found in the stabs, is merely a type definition, not
38 type information (see <a href="String-Field.html#String%20Field">String Field</a>) (that is, it need not start with
39 <code></code><var>type-number</var><code>=</code> if it is defining a new type). According to a
40 comment in GDB, this is also true of the type of the array elements; it
41 gives <code>ar1;1;10;ar1;1;10;4</code> as a legitimate way to express a two
42 dimensional array. According to AIX documentation, the element type
43 must be type information. GDB accepts either.
45 <p>The type of the index is often a range type, expressed as the type
46 descriptor <code>r</code> and some parameters. It defines the size of the
47 array. In the example below, the range <code>r1;0;2;</code> defines an index
48 type which is a subrange of type 1 (integer), with a lower bound of 0
49 and an upper bound of 2. This defines the valid range of subscripts of
50 a three-element C array.
52 <p>For example, the definition:
54 <pre class="example"> char char_vec[3] = {'a','b','c'};
55 </pre>
57 <p>produces the output:
59 <pre class="example"> .stabs "char_vec:G19=ar1;0;2;2",32,0,0,0
60 .global _char_vec
61 .align 4
62 _char_vec:
63 .byte 97
64 .byte 98
65 .byte 99
66 </pre>
68 <p>If an array is <dfn>packed</dfn>, the elements are spaced more
69 closely than normal, saving memory at the expense of speed. For
70 example, an array of 3-byte objects might, if unpacked, have each
71 element aligned on a 4-byte boundary, but if packed, have no padding.
72 One way to specify that something is packed is with type attributes
73 (see <a href="String-Field.html#String%20Field">String Field</a>). In the case of arrays, another is to use the
74 <code>P</code> type descriptor instead of <code>a</code>. Other than specifying a
75 packed array, <code>P</code> is identical to <code>a</code>.
77 <p>An open array is represented by the <code>A</code> type descriptor followed by
78 type information specifying the type of the array elements.
80 <p>An N-dimensional dynamic array is represented by
82 <pre class="example"> D <var>dimensions</var> ; <var>type-information</var>
83 </pre>
85 <p><var>dimensions</var> is the number of dimensions; <var>type-information</var>
86 specifies the type of the array elements.
88 <p>A subarray of an N-dimensional array is represented by
90 <pre class="example"> E <var>dimensions</var> ; <var>type-information</var>
91 </pre>
93 <p><var>dimensions</var> is the number of dimensions; <var>type-information</var>
94 specifies the type of the array elements.
96 </body></html>