Initial bulk commit for "Git on MSys"
[msysgit/historical-msysgit.git] / mingw / info / stabs / Stack-Variables.html
blobb19f3fa2e0b882227ec567b05aae77a18aa9fff1
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="Stack%20Variables">Stack Variables</a>,
13 Next:<a rel="next" accesskey="n" href="Global-Variables.html#Global%20Variables">Global Variables</a>,
14 Up:<a rel="up" accesskey="u" href="Variables.html#Variables">Variables</a>
15 <hr><br>
16 </div>
18 <h3 class="section">Automatic Variables Allocated on the Stack</h3>
20 <p>If a variable's scope is local to a function and its lifetime is only as
21 long as that function executes (C calls such variables
22 <dfn>automatic</dfn>), it can be allocated in a register (see <a href="Register-Variables.html#Register%20Variables">Register Variables</a>) or on the stack.
24 <p>Each variable allocated on the stack has a stab with the symbol
25 descriptor omitted. Since type information should begin with a digit,
26 <code>-</code>, or <code>(</code>, only those characters precluded from being used
27 for symbol descriptors. However, the Acorn RISC machine (ARM) is said
28 to get this wrong: it puts out a mere type definition here, without the
29 preceding <code></code><var>type-number</var><code>=</code>. This is a bad idea; there is no
30 guarantee that type descriptors are distinct from symbol descriptors.
31 Stabs for stack variables use the <code>N_LSYM</code> stab type, or
32 <code>C_LSYM</code> for XCOFF.
34 <p>The value of the stab is the offset of the variable within the
35 local variables. On most machines this is an offset from the frame
36 pointer and is negative. The location of the stab specifies which block
37 it is defined in; see <a href="Block-Structure.html#Block%20Structure">Block Structure</a>.
39 <p>For example, the following C code:
41 <pre class="example"> int
42 main ()
44 int x;
46 </pre>
48 <p>produces the following stabs:
50 <pre class="example"> .stabs "main:F1",36,0,0,_main # 36 is N_FUN
51 .stabs "x:1",128,0,0,-12 # 128 is N_LSYM
52 .stabn 192,0,0,LBB2 # 192 is N_LBRAC
53 .stabn 224,0,0,LBE2 # 224 is N_RBRAC
54 </pre>
56 <p>See <a href="Procedures.html#Procedures">Procedures</a> for more information on the <code>N_FUN</code> stab, and
57 <a href="Block-Structure.html#Block%20Structure">Block Structure</a> for more information on the <code>N_LBRAC</code> and
58 <code>N_RBRAC</code> stabs.
60 </body></html>